# faramarzaf/indish architecture

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

- Interactive diagram: https://gitdiagram.com/faramarzaf/indish
- Repository: https://github.com/faramarzaf/indish

## Overview

##### Main Components

a. API Layer
- UserController
- FoodPostController
- CommentController
- IngredientController
- WebController

b. Security Layer
- JWT Authentication Filter
- JWT Token Provider
- Security Config
- Custom User Details Service

c. Service Layer
- User Service
- Food Post Service
- Comment Service
- Ingredient Service
- Email Sender Service
- Confirmation Token Service

d. Data Access Layer
- User Repository
- Food Post Repository
- Comment Repository
- Ingredient Repository
- Role Repository
- Confirmation Token Repository

e. Database
- A database symbol showing the SQL database (evident from the SQL files in resources/db)

f. External Services
- An "External Services" section for:
- Email Service (indicated by EmailSenderService)

##### Component Relationships

- Client → API Controllers
- Controllers → Security Layer (for authentication)
- Controllers → Services
- Services → Repositories
- Repositories → Database
- Services → External Services

##### Cross-Cutting Concerns

- Exception Handling (GlobalExceptionHandler)
- DTO Mappers (UserMapper, FoodMapper, etc.)
- Utility Services (BadWordChecker, HashData)

##### Additional Elements

Symbols for:
- Configuration components (SwaggerConfig)
- Security filters
- Database migrations/seed data
- Entity relationships

##### Specific Implementation Details

Relationship between:
- Users and Food Posts
- Food Posts and Comments
- Food Posts and Ingredients
- Users and Roles

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        CL[Client Applications]
    end

    subgraph API_Layer
        UC["UserController"]:::controller
        FC["FoodPostController"]:::controller
        CC["CommentController"]:::controller
        IC["IngredientController"]:::controller
        WC["WebController"]:::controller
    end

    subgraph Security_Layer
        JF["JWT Filter"]:::security
        JT["JWT Token Provider"]:::security
        SC["Security Config"]:::security
        UD["User Details Service"]:::security
    end

    subgraph Service_Layer
        US["User Service"]:::service
        FPS["Food Post Service"]:::service
        CS["Comment Service"]:::service
        IS["Ingredient Service"]:::service
        ES["Email Sender Service"]:::service
        CTS["Confirmation Token Service"]:::service
    end

    subgraph Repository_Layer
        UR["User Repository"]:::repo
        FPR["Food Post Repository"]:::repo
        CR["Comment Repository"]:::repo
        IR["Ingredient Repository"]:::repo
        RR["Role Repository"]:::repo
        CTR["Confirmation Token Repository"]:::repo
    end

    subgraph Cross_Cutting
        GEH["Global Exception Handler"]:::utility
        DTM["DTO Mappers"]:::utility
        BWC["Bad Word Checker"]:::utility
        HD["Hash Data"]:::utility
        SWC["Swagger Config"]:::utility
    end

    subgraph External
        EMS[Email Service]:::external
    end

    DB[(SQL Database)]:::database

    %% Relationships
    CL --> API_Layer
    API_Layer --> Security_Layer
    Security_Layer --> Service_Layer
    Service_Layer --> Repository_Layer
    Repository_Layer --> DB
    ES --> EMS
    
    %% Cross-cutting relationships
    API_Layer -.-> Cross_Cutting
    Service_Layer -.-> Cross_Cutting

    %% Styling
    classDef controller fill:#2196F3,stroke:#1565C0,color:white
    classDef security fill:#FDD835,stroke:#F9A825,color:black
    classDef service fill:#4CAF50,stroke:#2E7D32,color:white
    classDef repo fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef utility fill:#9E9E9E,stroke:#424242,color:white
    classDef external fill:#F44336,stroke:#C62828,color:white
    classDef database fill:#795548,stroke:#4E342E,color:white

    %% Click events
    click UC "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/controller/UserController.java"
    click FC "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/controller/FoodPostController.java"
    click CC "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/controller/CommentController.java"
    click IC "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/controller/IngredientController.java"
    click WC "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/controller/WebController.java"
    click JF "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/security/JwtAuthenticationFilter.java"
    click JT "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/security/JwtTokenProvider.java"
    click SC "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/security/SecurityConfig.java"
    click ES "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/service/EmailSenderService.java"
    click CTS "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/service/ConfirmationTokenService.java"
    click UR "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/repository/UserRepository.java"
    click FPR "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/repository/FoodPostRepository.java"
    click CR "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/repository/CommentRepository.java"
    click IR "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/repository/IngredientRepository.java"
    click RR "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/repository/RoleRepository.java"
    click CTR "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/repository/ConfirmationTokenRepository.java"
    click GEH "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/config/GlobalExceptionHandler.java"
    click DTM "https://github.com/faramarzaf/InDish/tree/main/Indish/src/main/java/com/faraf/mapper/"
    click SWC "https://github.com/faramarzaf/InDish/blob/main/Indish/src/main/java/com/faraf/config/SwaggerConfig.java"
    click DB "https://github.com/faramarzaf/InDish/tree/main/Indish/src/main/resources/db/"
```
