How chandru2002-2/campusflow-backend works
1. Overall shape
- This is a single Spring Boot 3 backend service built with Maven and Java 17.
- It exposes REST APIs for campus user management, with authentication, authorization, and database-backed CRUD.
2. Entry point and runtime
- CampusFlowBackendApplication is the Spring Boot bootstrap class.
- application.properties is the main runtime configuration surface, likely holding MySQL connection details and security-related settings.
3. Request boundary: controllers
- The API layer is split into AuthController, UserController, and AdminController.
- These controllers form the external HTTP boundary and map requests into service calls.
- The README indicates /auth/* handles login/register, while /users/* handles CRUD with role-based access.
4. Application business layer
- UserService is the main business logic layer.
- It sits between controllers and persistence, handling user registration, login-related workflows, and user CRUD behavior.
- The service layer is the natural place where validation, role checks, password handling, and DTO mapping are coordinated.
5. Persistence boundary
- UserRepository is the Spring Data JPA interface for database access.
- User is the JPA entity representing the users table described in the README.
- The database is MySQL, and the repository is the only direct persistence abstraction visible in the tree.
6. API contract and data shaping
- The dto package contains LoginDTO, UserRequestDTO, and UserResponseDTO.
- This indicates the API does not expose entities directly; instead, requests and responses are normalized through DTOs.
- That creates a clean boundary between external payloads and internal persistence models.
7. Authentication flow
- AuthController likely accepts login/register requests, delegates to the service, and returns JWT-bearing responses.
- JwtUtil is responsible for token creation and validation.
- JwtFilter sits in the Spring Security filter chain and validates incoming bearer tokens before protected endpoints execute.
8. Authorization model
- SecurityConfig defines the security rules for public and protected routes.
- The README describes two roles: ADMIN and USER.
- Access control is endpoint-level: user read/update APIs are available to both roles, while delete is admin-only.
9. Error handling and API resilience
- GlobalExceptionHandler centralizes exception-to-response translation.
- This suggests controllers/services throw domain or validation exceptions that are converted into consistent HTTP error responses rather than leaking stack details.
10. Data flow across the system
- A typical request enters a controller, is authorized by Spring Security/JWT filter, then processed by the service, which uses the repository to read/write MySQL.
- Responses are converted into DTOs before leaving the service/controller boundary.
- Registration hashes passwords with BCrypt, and login produces a JWT that becomes the caller’s credential for future requests.
11. Operational and delivery tooling
- The repo includes the Maven wrapper and a GitHub Actions workflow under .github/workflows/maven.yml, so it is set up for repeatable builds and CI.
- Tests exist under src/test, though only the Spring Boot context test is visible in the tree.
12. Architecture diagram boundaries to draw
- External clients: curl/Postman/frontend calling REST endpoints.
- Security boundary: JWT bearer token validation and role enforcement.
- Application boundary: controllers → service → repository.
- Infrastructure boundary: MySQL database, Maven build, and CI workflow.
Main entry points: UserService.java User service · SecurityConfig.java Security config · CampusFlowBackendApplication.java Boot app · AuthController.java Auth API
Components 18
HTTP API
External request boundary and REST controllers
- API client · Frontend, curl, or Postman using the REST API
- Auth API · Handles login and registration endpoints
src/main/java/com/example/CamplusFlow/controller/AuthController.java - User API · Handles user CRUD endpoints
src/main/java/com/example/CamplusFlow/controller/UserController.java - Admin API · Admin-focused endpoints and privileged operations
src/main/java/com/example/CamplusFlow/controller/AdminController.java
Application
Core service and shared API contracts
- User service · Coordinates registration, login, validation, and user CRUD
src/main/java/com/example/CamplusFlow/service/UserService.java - Login DTO · Login request payload
src/main/java/com/example/CamplusFlow/dto/LoginDTO.java - User request · Create and update payloads
src/main/java/com/example/CamplusFlow/dto/UserRequestDTO.java - User response · Public user response shape
src/main/java/com/example/CamplusFlow/dto/UserResponseDTO.java - Exception handler · Converts failures into HTTP responses
src/main/java/com/example/CamplusFlow/exception/GlobalExceptionHandler.java
Security
JWT authentication and access control
- JWT filter · Validates bearer tokens on protected requests
src/main/java/com/example/CamplusFlow/security/JwtFilter.java - JWT util · Creates and validates JWTs
src/main/java/com/example/CamplusFlow/security/JwtUtil.java - Security config · Defines protected routes and role rules
src/main/java/com/example/CamplusFlow/config/SecurityConfig.java
Infrastructure
Persistence, runtime config, and delivery tooling
- User entity · Database-backed user model
src/main/java/com/example/CamplusFlow/model/User.java - User repo · Persistence abstraction for users
src/main/java/com/example/CamplusFlow/repository/UserRepository.java - MySQL · Primary persistent store
- Boot app · Application startup entry point
src/main/java/com/example/CamplusFlow/CampusFlowBackendApplication.java - App config · Main application properties and environment settings
src/main/resources/application.properties - Build & CI · Maven wrapper and GitHub Actions workflow
Connections 22
- API client → Security config: allowed by · Requests are governed by security rules before reaching controllers
- API client → JWT filter: bearer token · Authenticated calls present JWTs
- JWT filter → JWT util: verifies · Filter delegates token validation to JWT utility
- Security config → Auth API: permits · Public auth endpoints are exposed
- Security config → User API: protects · User routes require authentication and role checks
- Security config → Admin API: protects · Admin routes enforce privileged access
- Auth API → User service: delegates · Login and registration flow into application logic
- User API → User service: delegates · CRUD requests go through the service layer
- Admin API → User service: delegates · Admin operations reuse user management logic
- User service → Login DTO: uses · Consumes login payloads
- User service → User request: uses · Consumes user write payloads
- User service → User response: returns · Shapes responses for API consumers
- User service → User repo: reads/writes · Persists and loads users
- User repo → User entity: maps · Repository operates on the JPA entity
- User entity → MySQL: stored in · User records live in MySQL
- Auth API → Exception handler: errors to · Controller failures are normalized into responses
- User API → Exception handler: errors to · Controller failures are normalized into responses
- User service → Exception handler: throws · Business and validation exceptions are translated centrally
- Boot app → App config: loads · Bootstraps from runtime configuration
- Boot app → Security config: wires · Starts the security setup
- Boot app → User service: starts with · Application bootstraps the service graph
- Build & CI → Boot app: builds · CI and Maven wrapper compile and test the app