How ham222/sep3 works
Project type and purpose
• This is a multi‐tier, full‐stack energy-conservation application called “WE/Save.”
• It uses a Blazor WebAssembly front end (Tier 1), a .NET Core Web API for authentication (also Tier 1), a Java Spring Boot REST/gRPC façade (Tier 2), and a Java Spring Boot gRPC service with a database backend (Tier 3).
• Users log in via the JWT auth server, then view and submit water/electric usage and advice via REST endpoints, which in turn call gRPC services that persist data to a database.
Main components
a. Frontend (Tier 1)
• Blazor WASM project (BlazorWasm/)
• UI pages (.razor), shared layouts, custom auth provider
• HTTP service wrappers (AdviceHttpService, UsageHttpService, UserHttpService, JwtAuthService)
b. Authentication Server (Tier 1)
• ASP.NET Core Web API (WebApi/)
• AuthController, AuthService, JWT issuance & validation
• Uses Domain/Models and Shared/Dtos for user, credentials
c. REST API Server (Tier 2)
• Java Spring Boot (tier2/src/main/java/via/sep3/tier2/)
• REST controllers (AuthController, RestApiController)
• Spring Security (JWTFilter/JWTUtil/MyUserDetailsService/SecurityConfig)
• Logic layer (interfaces + servicesImpl)
• Repository interfaces + gRPC‐based implementations
• Protobuf stubs under generatedprotos/ for calling Tier 3
d. gRPC Service Server (Tier 3)
• Java Spring Boot (tier3/)
• gRPC service implementations (AdviceManagement, ResourcesConsumption, UserManagement)
• Database service layer (entity, repository, service implementations)
• Connects to relational DB (configured in application.properties)
e. Shared artifacts
• Protobuf definitions (tier2/src…, tier3/src/main/proto)
• .NET “Shared” and “Domain” libraries for models & DTOs
• .NET HttpClients library (ClientInterface + Implementations)
Relationships and data flow
1. User interacts with Blazor UI →
2. Blazor calls ASP.NET Auth API over HTTPS → JWT token returned →
3. Blazor attaches JWT → calls Java Spring REST API endpoints over HTTPS →
4. REST API controllers invoke business services →
5. Business services call repositoryImpl classes →
6. repositoryImpl uses gRPC stubs → calls Tier 3 gRPC services →
7. gRPC service layer interacts with DB →
8. Data flows back up the chain to the frontend.
Architectural patterns and principles
• Separation of concerns: UI, auth, API façade, data service
• Backend‐for‐Frontend: Tier 2 provides a tailored REST API for Blazor
• Layered architecture: controllers → services → repositories → data source
• Client‐Server with JWT: stateless auth via bearer tokens
• Service‐oriented / microservice style using gRPC for inter-tier calls
• Shared contracts via Protobuf to ensure strong typing across services