How mrin9/angular-springboot-rest-jwt works
Main Components
• Frontend (Angular):
– Represent the Angular application found under the “webui” folder (with its source files in webui/src and production files in webui/dist).
– Show core subcomponents such as Angular Components, Services (e.g., API request, customer/employee/order/product services), Directives, and Pages (like Login, Dashboard, Orders, Customers, etc.).
– Include Angular routing and guards (authentication routes and lazy data load).
• Backend (Spring Boot):
– Highlight the Service and Model layers (e.g., “UserService”, various model packages such as model/customer, model/order, etc.).
– Include the Repository layer (found in “com/app/repo”) that uses Spring Data/JPA to interact with an H2 in-memory database.
– Illustrate the Configuration components (e.g., SecurityConfig, CorsFilter, SwaggerConfig, VerifyTokenFilter) that set up API security (with JWT token generation/validation) and API documentation.
– Include Identity management classes (TokenUtil, TokenUser, UserAuthentication) for managing token-based authentication.
• Database:
• API Documentation:
– Show integration with Swagger and ReDoc (via the Swagger UI assets and endpoints) to document and test APIs.
• Build/Deployment Artifacts:
– Include build scripts (pom.xml, build.gradle) and describe how the frontend (webui/dist) is statically served by the backend via the “src/main/resources/public” path.
– Note that the backend, when built, packages the static Angular build, so both front and backend run on the same port (9119).
Relationships and Data Flow
• Authentication flow: The client sends a login request, receives a JWT, and then includes the token in headers to access secured endpoints.
• From the controller layer in the backend, show how requests flow to the service layer and then to the repository layer, culminating in the database interactions.
• Additional cross-cutting components like the GlobalExceptionHandler and CORS configuration that maintain system robustness and security.
Architectural Patterns and Design Principles
• Layered architecture – clearly separate Presentation (Angular client), Business Logic (Spring controllers/services), and Data Access (JPA repositories).
• Use of token-based security enforced via Spring Security and JWT.
• Integration pattern where the compiled Angular distribution is served as static content by the Spring Boot backend (through the “public” directory).
• Pattern for documentation and testing (Swagger/ReDoc integration).