Skip to content

Latest commit

 

History

History

README.md

Build Status CI/CD Pipeline Quality Gate Status Spring Boot Java Maven Jakarta EE Hibernate MapStruct Lombok License NAESB

OpenESPI-DataCustodian

A modern Spring Boot 3.5 implementation of the Open Energy Services Provider Interface (ESPI) Data Custodian, providing OAuth2 Resource Server capabilities for secure energy usage data access according to the North American Energy Standards Board (NAESB) REQ.21 ESPI specification.

Overview

The OpenESPI-DataCustodian serves as a secure OAuth2 Resource Server that:

  • Protects energy usage data with scope-based authorization (FB=1_3_4_5_13_14_15_39, FB=4_5_15)
  • Provides RESTful APIs for retail customers and third-party applications
  • Implements ESPI 4.0 specification with ATOM XML data formats
  • Supports multiple databases (MySQL, PostgreSQL, H2) with Flyway migrations
  • Offers modern web interface with Thymeleaf templates and Spring Security 6

Architecture

Built on Spring Boot 3.5 with modern architectural patterns:

  • OAuth2 Resource Server with opaque token introspection
  • Entity-based data model with UUID primary keys (48-bit+ ESPI compliance)
  • Service layer architecture with DTO mapping via MapStruct
  • Multi-profile configuration for development, testing, and production
  • Comprehensive testing with TestContainers and Cucumber BDD

Quick Start

Prerequisites

  • Java 21+ (OpenJDK recommended)
  • Maven 3.9+
  • MySQL 8.0+ or PostgreSQL 15+ (for production)
  • OpenESPI-Common-java dependency (built automatically)

Clone and Build

git clone https://github.com/GreenButtonAlliance/OpenESPI-DataCustodian-java.git
cd OpenESPI-DataCustodian-java

# Build with default MySQL profile
mvn clean install

# Or skip tests for faster build
mvn clean install -DskipTests

Run Application

# Start with MySQL (default)
mvn spring-boot:run

# Start with PostgreSQL
mvn spring-boot:run -Pdev-postgresql

# Start with H2 (local development)
mvn spring-boot:run -Plocal

The application will be available at: http://localhost:8080

Configuration Profiles

Profile Database Use Case
dev-mysql MySQL Default development (active by default)
dev-postgresql PostgreSQL PostgreSQL development
local H2 Local development/testing
prod MySQL Production deployment
docker MySQL Container deployment
aws-sandbox MySQL AWS GBA Sandbox

Testing

Unit Tests

mvn test

Integration Tests with TestContainers

# MySQL integration tests
mvn verify -Ptestcontainers-mysql

# PostgreSQL integration tests  
mvn verify -Ptestcontainers-postgresql

BDD Tests with Cucumber

mvn verify

Code Coverage

mvn verify jacoco:report
# Reports available in target/site/jacoco/

API Documentation

Interactive API documentation is available via Swagger UI:

Security

This implementation follows OAuth2 Resource Server patterns:

  • Opaque access tokens (no JWT) per ESPI specification
  • Scope-based authorization with fine-grained permissions
  • Spring Security 6 with modern security configurations
  • OWASP dependency scanning integrated in CI/CD

Development

IDE Setup

IntelliJ IDEA (Recommended):

# Open project
File → Open → select pom.xml

# Enable annotation processing for Lombok/MapStruct
Settings → Build → Compiler → Annotation Processors → Enable

Eclipse/Spring Tool Suite:

File → Import → Maven → Existing Maven Projects

Code Quality

# Run OWASP security scan
mvn org.owasp:dependency-check-maven:check

# Static analysis with SpotBugs
mvn compile spotbugs:check

Deployment

Docker

# Build application JAR
mvn clean package -DskipTests

# Run with Docker profile
java -jar target/OpenESPI-DataCustodian.jar --spring.profiles.active=docker

Production

Configure production database and OAuth2 authorization server endpoints in:

  • src/main/resources/application-prod.yml
  • Environment variables or external configuration

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Follow code style and add tests
  4. Commit changes (git commit -m 'Add amazing feature')
  5. Push to branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

License

Licensed under the Apache License 2.0. See LICENSE for details.

Support