# bumbumz/01-java-spring-jobhunter-starter-master architecture

> Architecture diagram of the GitHub repository bumbumz/01-java-spring-jobhunter-starter-master, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bumbumz/01-java-spring-jobhunter-starter-master
- Repository: https://github.com/bumbumz/01-java-spring-jobhunter-starter-master

## Overview

##### Main Components

a) API Layer
- Controllers by domain: Job, Company, User, Resume, etc.
- Authentication/security endpoints separately

b) Service Layer
- Specialized services like EmailService, FileService, TokenService
- To corresponding controllers

c) Repository Layer
- Database interaction layer
- Repositories: JobRepository, CompanyRepository, UserRepository, etc.
- To corresponding services

d) Domain Model
- Main entities: User, Company, Job, Resume, Role, Permission
- Relationships between entities

e) Configuration & Security
- Security configuration components
- CORS configuration
- Authentication flow
- Permission interceptors

##### Component Relationships

- Client/External Requests → Controllers
- Controllers → Services
- Services → Repositories
- Repositories → Database
- Cross-cutting concerns like security and interceptors spanning all layers

##### Specific Elements

a) External Components:
- Database (likely a relational database given JPA repositories)
- Email Service Integration
- File Storage System
- Authentication System

b) Security Flow:
- JWT/Token flow
- Permission checking process
- Role-based access control

**[External Clients] → [Security Layer (JWT, CORS)]**
- ↓
**[Controllers Layer] → [Permission Interceptor]**
- ↓
**[Service Layer] ←→ [File Service, Email Service]**
- ↓
**[Repository Layer] → [Database]**

##### Additional Details

- Error handling flow
- File upload/download paths
- Demonstrate email notification flow
- User authentication/authorization process

##### Technical Stack Indicators

- Spring Boot Framework
- Spring Security
- JPA/Hibernate
- RESTful API architecture
- Email Service Integration
- File Storage System

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Clients
    Client(("External Client"))

    %% Security Layer
    subgraph Security["Security Layer"]
        direction TB
        JWT["JWT Authentication"]
        CORS["CORS Config"]:::config
        PermInt["Permission Interceptor"]:::config
    end

    %% Controllers Layer
    subgraph Controllers["API Controllers"]
        direction TB
        LoginCtrl["Login Controller"]:::controller
        JobCtrl["Job Controller"]:::controller
        UserCtrl["User Controller"]:::controller
        FileCtrl["File Controller"]:::controller
        EmailCtrl["Email Controller"]:::controller
    end

    %% Services Layer
    subgraph Services["Service Layer"]
        direction TB
        TokenSvc["Token Service"]:::service
        JobSvc["Job Service"]:::service
        UserSvc["User Service"]:::service
        FileSvc["File Service"]:::service
        EmailSvc["Email Service"]:::service
    end

    %% Repository Layer
    subgraph Repositories["Repository Layer"]
        direction TB
        JobRepo["Job Repository"]:::repo
        UserRepo["User Repository"]:::repo
        CompanyRepo["Company Repository"]:::repo
    end

    %% Domain Models
    subgraph Domain["Domain Models"]
        direction TB
        UserEntity["User Entity"]:::entity
        JobEntity["Job Entity"]:::entity
        CompanyEntity["Company Entity"]:::entity
    end

    %% Error Handling
    subgraph ErrorHandling["Error Handling"]
        direction TB
        GlobalEx["Global Exception"]:::error
        PermEx["Permission Exception"]:::error
    end

    %% External Systems
    Database[(Database)]
    FileStorage[("File Storage")]
    EmailSystem[("Email System")]

    %% Connections
    Client --> Security
    Security --> Controllers
    
    LoginCtrl --> TokenSvc
    JobCtrl --> JobSvc
    UserCtrl --> UserSvc
    FileCtrl --> FileSvc
    EmailCtrl --> EmailSvc
    
    JobSvc --> JobRepo
    UserSvc --> UserRepo
    
    JobRepo --> Database
    UserRepo --> Database
    CompanyRepo --> Database
    
    FileSvc --> FileStorage
    EmailSvc --> EmailSystem

    %% Click Events
    click LoginCtrl "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/controller/LoginController.java"
    click JobCtrl "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/controller/JobController.java"
    click UserCtrl "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/controller/UserController.java"
    click FileCtrl "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/controller/FileController.java"
    click EmailCtrl "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/controller/EmailController.java"
    
    click TokenSvc "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/service/TokenService.java"
    click FileSvc "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/service/FileService.java"
    click EmailSvc "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/service/EmailService.java"
    
    click JobRepo "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/repository/JobRepository.java"
    click UserRepo "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/repository/UserRepository.java"
    click CompanyRepo "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/repository/CompanyRepository.java"
    
    click UserEntity "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/domain/User.java"
    click JobEntity "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/domain/Job.java"
    click CompanyEntity "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/domain/Company.java"
    
    click CORS "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/config/CorsConfig.java"
    click PermInt "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/config/PermissionInterceptor.java"
    
    click GlobalEx "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/util/error/GlobalException.java"
    click PermEx "https://github.com/bumbumz/01-java-spring-jobhunter-starter-master/blob/main/src/main/java/vn/hoidanit/jobhunter/util/error/PermissionException.java"

    %% Styling
    classDef controller fill:#2196F3,stroke:#fff,stroke-width:2px,color:#fff
    classDef service fill:#4CAF50,stroke:#fff,stroke-width:2px,color:#fff
    classDef repo fill:#FFC107,stroke:#fff,stroke-width:2px,color:#000
    classDef entity fill:#9C27B0,stroke:#fff,stroke-width:2px,color:#fff
    classDef config fill:#607D8B,stroke:#fff,stroke-width:2px,color:#fff
    classDef error fill:#F44336,stroke:#fff,stroke-width:2px,color:#fff
```
