# culesbao/find-job-be architecture

> Architecture diagram of the GitHub repository culesbao/find-job-be, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/culesbao/find-job-be
- Repository: https://github.com/culesbao/find-job-be

## Overview

##### Project type and purpose
- This is a Spring Boot–based backend RESTful API for a job‐finding platform (“find-job-be”).
- It exposes endpoints for account management, job postings, profiles, applications, followers, chat, and file uploads.
- It uses JWT‐based security, OAuth2 social login, Cloudinary for file storage, email service, and a Gemini AI integration.

##### File structure
- Top-level:
- Dockerfile & docker-compose.yml for containerizing the app plus its backing services (database, message broker, etc.).
- pom.xml and .mvn wrapper for Maven build.
- src/main/java/com/findjobbe/findjobbe:
- config: Spring beans, security setup, password encoding, message bundles.
- controller: REST controllers (AccountController, JobController, ChatController, etc.).
- service (and impl): business logic interfaces and implementations.
- repository: Spring Data JPA repositories.
- model: JPA entities.
- mapper: DTO ↔ request/response mappers.
- security: JWT filter, entry point, token manager, OAuth2 success handler.
- factory: factory classes to pick follower/profile services.
- exception: custom exception types and global error handler.
- utils: small helpers (e.g., code generation).
- resources: application.properties, SQL seed files, email template.
- test: one smoke test for the Spring context.

##### Key README insights
- Minimal README, so no built-in architecture doc. We must infer a layered, monolithic microservice.

a. Client(s)—Web or Mobile UI (external to this repo)
b. API Gateway / HTTP Layer—Spring MVC controllers + Spring Security filters (JWT, OAuth2)
c. Business Layer—Service interfaces and implementations
d. Data Layer—Spring Data repositories + JPA entities + SQL seed scripts
e. External Services:
- Cloudinary (file storage)
- SMTP server (email verification)
- OAuth2 Providers (Google, Facebook, etc.)
- (Optionally) Gemini AI service
f. Infrastructure:
- Docker container running the Spring Boot app
- docker-compose orchestrating the app, database (MySQL/Postgres), possibly Redis or RabbitMQ (if used)

##### Relationships and interactions
- Client → HTTP request → Security Filter Chain (JWTAuthenticationFilter) → Controller
- Controller → calls Service → Service → Repository → Database
- Service → calls external APIs (Cloudinary, MailServiceImpl→SMTP, OAuth2ServiceImpl→OAuth provider, GeminiServiceImpl→AI endpoint)
- Errors bubble up as custom exceptions handled by GlobalExceptionHandler
- Data flows back via DTO mappers into JSON responses

##### Architectural patterns & principles
- Layered (Controller → Service → Repository)
- Dependency Injection via Spring
- Factory pattern for follower/profile services
- JWT stateless authentication + OAuth2 social login
- Use of DTOs & mappers to decouple domain from API
- Externalized configuration (application.properties, CloudinaryConfig)

##### Technologies & frameworks to annotate
- Java 17 (or configured JDK) + Spring Boot
- Spring MVC, Spring Security, Spring Data JPA
- Maven build
- Docker & Docker Compose
- Cloudinary SDK, JavaMailSender, OAuth2Client, JWT library
- H2/MySQL/PostgreSQL (depending on compose file)
- (Optional) Gemini AI HTTP client

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client
    Client["Web/Mobile Client"]:::external

    %% Security Layer
    subgraph "Security Layer"
        direction TB
        JwtFilter["JwtAuthenticationFilter"]:::security
        JwtEntry["JwtAuthenticationEntryPoint"]:::security
        JwtManager["JwtTokenManager"]:::security
        OAuth2Handler["CustomOAuth2SuccessHandler"]:::security
        JwtProps["JwtProperties"]:::security
        SecConfig["SecurityConfiguration"]:::security
    end

    %% Controllers Layer
    Controllers["Controllers"]:::controller

    %% Service Layer
    Services["Service Layer"]:::service

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Repos["Repositories"]:::repository
        Entities["Entities (JPA Models)"]:::repository
        SQLScripts["SQL Seed Scripts"]:::database
    end

    %% Config & Utils
    subgraph "Configuration"
        direction TB
        CloudConfig["CloudinaryConfig"]:::config
        PassEnc["PasswordEncoderConfiguration"]:::config
        MsgConfig["MessageConfiguration"]:::config
        CurrUser["CurrentUser"]:::config
        AppProps["application.properties"]:::config
        Messages["Exception/Validation Messages"]:::config
        EmailTemplate["SendVerifyCodeTemplate.html"]:::config
    end

    %% DTO Mappers
    DTOs["DTO Mappers"]:::dto

    %% Factories
    Factories["Factories"]:::factory

    %% Exception Handling
    Exceptions["Exception Handling"]:::exception

    %% Infrastructure
    Infra["Infrastructure"]:::infra

    %% External Services
    subgraph "External Services"
        direction TB
        Cloudinary["Cloudinary Storage"]:::external
        SMTP["SMTP Email Service"]:::external
        OAuth2Prov["OAuth2 Providers"]:::external
        Gemini["Gemini AI Service"]:::external
    end

    %% Database
    Database["Database"]:::database

    %% Data Flows
    Client -->|HTTP/REST| JwtFilter
    JwtFilter --> JwtEntry
    JwtFilter --> JwtManager
    JwtFilter -->|passes| Controllers
    JwtFilter --> OAuth2Handler
    JwtFilter --> JwtProps
    JwtFilter --> SecConfig

    Controllers -->|calls| Services
    Services -->|uses| Repos
    Services -->|uses| Entities
    Repos -->|JPA/JDBC| Database
    Services -->|HTTP/SDK| Cloudinary
    Services -->|SMTP| SMTP
    Services -->|OAuth2| OAuth2Prov
    Services -->|HTTP| Gemini

    Services --> DTOs
    Controllers --> Exceptions
    Services --> Exceptions

    %% Config relationships
    Controllers --> MsgConfig
    Services --> CloudConfig
    Services --> PassEnc
    Services --> CurrUser
    Infra -->|Docker Compose| Database
    Infra -->|runs| Controllers

    Factories --> Services
    DTOs --> Controllers

    Database --> SQLScripts

    %% Click Events
    click Controllers "https://github.com/culesbao/find-job-be/tree/main/src/main/java/com/findjobbe/findjobbe/controller"
    click JwtFilter "https://github.com/culesbao/find-job-be/blob/main/src/main/java/com/findjobbe/findjobbe/security/JwtAuthenticationFilter.java"
    click JwtEntry "https://github.com/culesbao/find-job-be/blob/main/src/main/java/com/findjobbe/findjobbe/security/JwtAuthenticationEntryPoint.java"
    click JwtManager "https://github.com/culesbao/find-job-be/blob/main/src/main/java/com/findjobbe/findjobbe/security/JwtTokenManager.java"
    click OAuth2Handler "https://github.com/culesbao/find-job-be/blob/main/src/main/java/com/findjobbe/findjobbe/security/CustomOAuth2SuccessHandler.java"
    click JwtProps "https://github.com/culesbao/find-job-be/blob/main/src/main/java/com/findjobbe/findjobbe/security/JwtProperties.java"
    click SecConfig "https://github.com/culesbao/find-job-be/blob/main/src/main/java/com/findjobbe/findjobbe/config/SecurityConfiguration.java"
    click Services "https://github.com/culesbao/find-job-be/tree/main/src/main/java/com/findjobbe/findjobbe/service"
    click Repos "https://github.com/culesbao/find-job-be/tree/main/src/main/java/com/findjobbe/findjobbe/repository"
    click Entities "https://github.com/culesbao/find-job-be/tree/main/src/main/java/com/findjobbe/findjobbe/model"
    click SQLScripts "https://github.com/culesbao/find-job-be/blob/main/src/main/resources/static/vietnamese-province-dataset.sql"
    click CloudConfig "https://github.com/culesbao/find-job-be/blob/main/src/main/java/com/findjobbe/findjobbe/config/CloudinaryConfig.java"
    click PassEnc "https://github.com/culesbao/find-job-be/blob/main/src/main/java/com/findjobbe/findjobbe/config/PasswordEncoderConfiguration.java"
    click MsgConfig "https://github.com/culesbao/find-job-be/blob/main/src/main/java/com/findjobbe/findjobbe/config/MessageConfiguration.java"
    click CurrUser "https://github.com/culesbao/find-job-be/blob/main/src/main/java/com/findjobbe/findjobbe/config/CurrentUser.java"
    click AppProps "https://github.com/culesbao/find-job-be/blob/main/src/main/resources/application.properties"
    click Messages "https://github.com/culesbao/find-job-be/blob/main/src/main/resources/messages/ExceptionMessage.properties"
    click EmailTemplate "https://github.com/culesbao/find-job-be/blob/main/src/main/resources/templates/SendVerifyCodeTemplate.html"
    click DTOs "https://github.com/culesbao/find-job-be/tree/main/src/main/java/com/findjobbe/findjobbe/mapper/dto"
    click Factories "https://github.com/culesbao/find-job-be/tree/main/src/main/java/com/findjobbe/findjobbe/factory"
    click Exceptions "https://github.com/culesbao/find-job-be/tree/main/src/main/java/com/findjobbe/findjobbe/exception"
    click Infra "https://github.com/culesbao/find-job-be/blob/main/docker-compose.yml"

    %% Styles
    classDef security fill:#f9f,stroke:#333,stroke-width:1px
    classDef controller fill:#bbf,stroke:#333,stroke-width:1px
    classDef service fill:#bfb,stroke:#333,stroke-width:1px
    classDef repository fill:#ffb,stroke:#333,stroke-width:1px
    classDef database fill:#fbb,stroke:#333,stroke-width:1px
    classDef external fill:#dfd,stroke:#333,stroke-width:1px
    classDef infra fill:#ddd,stroke:#333,stroke-width:1px
    classDef config fill:#fdc,stroke:#333,stroke-width:1px
    classDef dto fill:#cfd,stroke:#333,stroke-width:1px
    classDef factory fill:#fdd,stroke:#333,stroke-width:1px
    classDef exception fill:#dff,stroke:#333,stroke-width:1px
```
