# caonguyen-tran/epm_spring architecture

> Architecture diagram of the GitHub repository caonguyen-tran/epm_spring, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/caonguyen-tran/epm_spring
- Repository: https://github.com/caonguyen-tran/epm_spring

## Overview

##### Main Components
- Web Server / Dispatcher: At the core, there is the web container (Tomcat 9) running the Spring MVC application. The Dispatcher Servlet (configured in DispatcherServletInit.java) acts as the front controller.
- Controller Layer: Include all HTTP controllers (“controllers” package, e.g., AdminActivityController, ApiUserController, etc.) that handle incoming web requests.
- Service Layer: Represent the services (both interfaces and their implementations in “services” and “services/imp” packages) that contain business logic.
- Repository/DAO Layer: Represent the data access layer (repositories and their implementations) which interacts with the database.
- Domain Models: The “pojo” package contains the core entities like Activity, Student, User, etc.
- Configurations: There are numerous configurations (in the “configs” package) that configure Spring MVC, Spring Security, Hibernate, Firebase, Mail, Tiles, etc.
- Security Components: Highlight components such as JwtService, JwtAuthenticationTokenFilter, and the various Spring Security configurations.
- Persistence: Include the database (as indicated by the epmdb.sql file and databases.properties) used by Hibernate (configured via HibernateConfig.java and persistence.xml).
- Utility Components: These include utility packages for data conversion, timestamp conversion, and status handling.

##### Out Relationships and Data Flow
- From controllers, indicate the invocation of service methods to process business logic.
- From services, indicate calls to the repository layer for database CRUD operations.
- Flow from database queries returning data back through the repositories, services, and controllers to the client.
- Security intercepts: Show how incoming requests pass through security filters (JWT filters and access handlers) before reaching controllers.
- External integrations: For example, Firebase and Mail configurations should be shown as interactions from the backend components that need to contact external services.

##### Architectural Patterns
- MVC Pattern: Clearly distinguish between the Model (domain entities in “pojo”), View (JSP pages in the “WEB-INF/pages” directory and possibly ReactJS views if they are considered separately), and Controller (in “controllers”).
- Layered Architecture: Separate the application into Controller, Service, and Repository layers.

##### Relevant Technologies and Frameworks
- Spring MVC, Spring Security, Spring Beans/DI, Hibernate (with associated persistence.xml and configurations), and integration tools (Firebase, Mail).
- The front end is built with ReactJS and communicates via REST APIs provided by the Spring backend.
- Tomcat 9 is the deployment server.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["ReactJS Frontend"]:::frontend
    B["Dispatcher Servlet"]:::backend
    D["API Controllers"]:::controller
    E["Service Layer"]:::service
    F["Repository Layer"]:::repository
    I["Persistence (Database)"]:::database

    C1["JWT Service"]:::security
    C2["JWT Filters"]:::security
    H["Configurations"]:::config
    G["Domain Models"]:::domain
    J["Utility Components"]:::utility
    K["External Integrations"]:::external

    %% Main vertical flow
    A -->|"HTTP_Request"| B
    B -->|"Routes_Request"| D
    D -->|"Invokes_Service"| E
    E -->|"Calls_DataAccess"| F
    F -->|"DB_Operations"| I

    %% Additional relationships
    B ---|"Secured_by"| C1
    B ---|"Secured_by"| C2
    H ---|"Configures"| B
    H ---|"Secures"| C1
    H ---|"Secures"| C2
    H ---|"Hibernate_Config"| I
    E -- "Uses" --> G
    E -- "Integrates" --> K
    E ---|"Utility_Functions"| J

    %% Styling classes
    classDef frontend fill:#FFE0B2,stroke:#E65100,stroke-width:2px;
    classDef backend fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef controller fill:#C8E6C9,stroke:#1B5E20,stroke-width:2px;
    classDef service fill:#FFF9C4,stroke:#F57F17,stroke-width:2px;
    classDef repository fill:#B2DFDB,stroke:#004D40,stroke-width:2px;
    classDef database fill:#FFCDD2,stroke:#B71C1C,stroke-width:2px;
    classDef security fill:#F8BBD0,stroke:#880E4F,stroke-width:2px;
    classDef config fill:#D1C4E9,stroke:#4A148C,stroke-width:2px;
    classDef domain fill:#D7CCC8,stroke:#3E2723,stroke-width:2px;
    classDef utility fill:#FFF59D,stroke:#F57F17,stroke-width:2px;
    classDef external fill:#DCEDC8,stroke:#33691E,stroke-width:2px;

    %% Click Events
    click B "https://github.com/caonguyen-tran/epm_spring/blob/main/EPMWebSpring/src/main/java/com/epm/configs/DispatcherServletInit.java"
    click D "https://github.com/caonguyen-tran/epm_spring/tree/main/EPMWebSpring/src/main/java/com/epm/controllers"
    click E "https://github.com/caonguyen-tran/epm_spring/tree/main/EPMWebSpring/src/main/java/com/epm/services"
    click F "https://github.com/caonguyen-tran/epm_spring/tree/main/EPMWebSpring/src/main/java/com/epm/repositories"
    click G "https://github.com/caonguyen-tran/epm_spring/tree/main/EPMWebSpring/src/main/java/com/epm/pojo"
    click H "https://github.com/caonguyen-tran/epm_spring/tree/main/EPMWebSpring/src/main/java/com/epm/configs"
    click C1 "https://github.com/caonguyen-tran/epm_spring/blob/main/EPMWebSpring/src/main/java/com/epm/components/JwtService.java"
    click C2 "https://github.com/caonguyen-tran/epm_spring/blob/main/EPMWebSpring/src/main/java/com/epm/filters/JwtAuthenticationTokenFilter.java"
    click I "https://github.com/caonguyen-tran/epm_spring/blob/main/epmdb.sql"
    click J "https://github.com/caonguyen-tran/epm_spring/tree/main/EPMWebSpring/src/main/java/com/epm/utils"
```
