How eric8900/weneedabudget-backend works
Project Type and Purpose
• This is a Java Spring Boot monolithic backend service exposing RESTful CRUD endpoints for a budgeting app (“We Need A Budget” clone).
• It handles user management, account/category/transaction CRUD, authentication (JWT and Google OAuth2), and persists data in PostgreSQL.
Key Directory/Component Analysis
• src/main/java/com/example/wnabudgetbackend
• config: security configuration, JWT utilities, OAuth2 success handler
• controller: REST controllers (Account, Category, Transaction, User, Auth, Ping)
• service: business logic for each domain entity
• repository: Spring Data JPA repositories for persistence
• dto: request/response models and PATCH payloads
• model: JPA entity definitions (User, Account, CategoryGroup, Category, Transaction)
• WnabudgetBackendApplication.java: Spring Boot entry point
• StreamLambdaHandler.java & template.yml: AWS Lambda / SAM packaging (optional serverless deployment)
• pom.xml & Maven wrapper: build and dependency management
• application.properties: externalized configuration (DB URL, AWS, security)
• Tests: one integration test class
Architectural Overview
a. Main Components
• Client (Web or Mobile UI)
• API Gateway / Load Balancer (e.g., AWS API Gateway or ELB)
• Spring Boot Application (hosted on AWS EC2, Container, or Lambda)
• Security Layer (JWT filter, OAuth2 filter)
• Controllers (REST endpoints)
• Service Layer
• Repository Layer
• PostgreSQL Database (AWS RDS)
• External Auth Provider (Google OAuth2)
b. Data Flows & Interactions
1. Client → API Gateway/Load Balancer → Spring Boot Security Filters
2. JWT Authentication Filter validates tokens; if login/signup, AuthController issues JWT via JwtUtil
3. For OAuth logins, Spring’s OAuth2SuccessHandler exchanges Google code for tokens
4. Controller receives requests → calls corresponding Service → invokes Repository → reads/writes DB
5. Database responses propagate back up through layers to client
c. Optional Serverless Variation
• API Gateway → AWS Lambda (StreamLambdaHandler) → Spring Boot function adapter → same service/repo layers → RDS
d. Architectural Patterns & Principles
• Layered Architecture (Controller → Service → Repository)
• Separation of Concerns (DTO layer for transport, model layer for persistence)
• Externalized Configuration (application.properties for environment-specific settings)
• Security as a Cross-Cutting Concern (filters, handlers, beans in config package)
Final Checklist for Detailed Coverage
• All REST controllers mapped to their domain entities.
• Security flow: JWT issuance & validation, OAuth2 integration.
• Data persistence path into PostgreSQL on RDS.
• Build/deployment artifacts (Maven wrapper, pom.xml, template.yml).
• Environment/configuration layering (application.properties).
• Optional vs. primary deployment topology (EC2 container vs. Lambda).