# peppertechdev/peppercrm-api architecture

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

- Interactive diagram: https://gitdiagram.com/peppertechdev/peppercrm-api
- Repository: https://github.com/peppertechdev/peppercrm-api

## Overview

##### Project Type and Purpose
- This is a backend RESTful API developed using Spring Boot with Java 17 and managed by Maven. Its purpose is to serve as the CRM API for PepperTech, with distinct modules for handling user management, security (authentication/authorization), mail communication, and documentation (via Swagger).
- The README emphasizes deployment using Docker and Render.com, so the project is built as a containerized microservice exposing API endpoints.

##### Analyzing the File Structure
- At the root level, files like Dockerfile, pom.xml, .env.example, and CI/CD configurations indicate a cloud-deployed, containerized Java application.
- Under src/main/java/peppertech/crm/api, the code is modularly organized into packages such as Mail, Users, Security, and Documentation, following a layered or modular approach:
- Controllers manage incoming HTTP requests.
- Services encapsulate business logic (e.g., EmailService, SUser).
- Repositories handle data persistence.
- Mappers and DTOs help to convert between domain models and transfer objects.
- Configuration packages (e.g., SecurityConfiguration, SwaggerConfig) define security, cross-origin rules, and documentation details.
- Additional directories like Exceptions and Validator indicate custom error handling and validation logic.

##### Final Recommendations
- External interactions (e.g., notifications from the Mail module, database connectivity, external email services).
- Incorporate infrastructure elements from the README such as Docker and CI/CD workflow as part of the overall deployment/operations view.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global External Nodes
    HTTPReq("Incoming HTTP Request"):::external
    Database("Database"):::external
    EmailServer("Email Server"):::external

    %% Deployment Cluster
    subgraph "Deployment / Build"
        Docker("Dockerfile"):::deployment
        CICD(".github/workflows/deployment.yml"):::deployment
        Maven("pom.xml"):::deployment
        Env(".env.example"):::deployment
    end

    %% Main Application Container
    subgraph "PepperCRM API"
        APIGW("PepperCrmApiApplication"):::gateway

        %% Security Module
        subgraph "Security Module"
            AuthCtrl("Auth Controller"):::controller
            JWTService("JWT Service"):::service
            JwtFilter("JWT Authentication Filter"):::filter
            RateLimit("Rate Limiting Filter"):::filter
            SecConfig("Security Configuration"):::config
            CorsConf("CORS Configuration"):::config
        end

        %% Users Module
        subgraph "Users Module"
            UserCtrl("User Controller"):::controller
            UserServ("User Service"):::service
            UserRepo("User Repository"):::repository
            UserMap("User Mapper"):::mapper
            %% User Validators as individual nodes
            UserRegex("UserRegex"):::validator
            VUser("VUser"):::validator
            VUserI("VUserI"):::validator
        end

        %% Mail Module
        subgraph "Mail Module"
            MailCtrl("Mail Controller"):::controller
            MailServ("Mail Service"):::service
            MailRepo("Mail Repository"):::repository
            MailMap("Mail Mapper"):::mapper
        end

        %% Documentation Module
        subgraph "Documentation Module"
            Swagger("Swagger Configuration"):::config
        end

        %% Exception Handling
        subgraph "Exception Handling"
            InvalidToken("InvalidTokenException"):::exception
        end
    end

    %% Inbound flow
    HTTPReq -->|"calls"| APIGW
    APIGW -->|"filters"| JwtFilter
    JwtFilter --> RateLimit

    %% Security Module flow
    RateLimit -->|"routes"| AuthCtrl
    AuthCtrl -->|"uses"| JWTService
    SecConfig -->|"configures"| JwtFilter
    SecConfig -->|"configures"| RateLimit
    CorsConf -->|"applies to"| AuthCtrl

    %% Users Module flow
    RateLimit -->|"routes"| UserCtrl
    UserCtrl -->|"delegates"| UserServ
    UserServ -->|"accesses"| UserRepo
    UserCtrl -->|"maps DTOs with"| UserMap
    UserCtrl -->|"validates via"| UserRegex
    UserCtrl -->|"validates via"| VUser
    UserCtrl -->|"validates via"| VUserI
    UserRepo -->|"persists to"| Database

    %% Mail Module flow
    RateLimit -->|"routes"| MailCtrl
    MailCtrl -->|"delegates"| MailServ
    MailServ -->|"accesses"| MailRepo
    MailCtrl -->|"maps DTOs with"| MailMap
    MailRepo -->|"persists to"| Database
    MailServ -->|"sends via"| EmailServer

    %% Documentation Module flow (for API docs)
    APIGW -->|"documents"| Swagger

    %% Exception Handling linkage (used by Security)
    JwtFilter -->|"throws"| InvalidToken

    %% Deployment linkage
    APIGW ---|"containerized in"| Docker
    Maven ---|"builds project"| APIGW
    Env ---|"configures"| APIGW
    CICD ---|"deploys to"| Docker

    %% Click Events
    click APIGW "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/PepperCrmApiApplication.java"
    click MailCtrl "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Mail/Controller/EmailController.java"
    click MailServ "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Mail/Service/EmailService.java"
    click MailRepo "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Mail/Repository/EmailRepository.java"
    click MailMap "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Mail/Mapper/EmailMapper.java"
    click UserCtrl "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Users/Controller/UserController.java"
    click UserServ "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Users/Service/SUser.java"
    click UserRepo "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Users/Repository/RUser.java"
    click UserMap "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Users/Mapper/MUser.java"
    click UserRegex "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Users/Validator/UserRegex.java"
    click VUser "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Users/Validator/VUser.java"
    click VUserI "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Users/Validator/VUserI.java"
    click AuthCtrl "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Security/Controller/AuthController.java"
    click JWTService "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Security/Service/JwtService.java"
    click JwtFilter "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Security/Config/Filters/JwtAuthFilter.java"
    click RateLimit "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Security/Config/Filters/RateLimitingFilter.java"
    click SecConfig "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Security/Config/SecurityConfiguration.java"
    click CorsConf "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Security/Config/headers/CorsConfig.java"
    click Swagger "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Documentation/SwaggerConfig.java"
    click InvalidToken "https://github.com/peppertechdev/peppercrm-api/blob/main/src/main/java/peppertech/crm/api/Exceptions/InvalidTokenException.java"
    click Docker "https://github.com/peppertechdev/peppercrm-api/tree/main/Dockerfile"
    click CICD "https://github.com/peppertechdev/peppercrm-api/blob/main/github/workflows/deployment.yml"
    click Maven "https://github.com/peppertechdev/peppercrm-api/blob/main/pom.xml"
    click Env "https://github.com/peppertechdev/peppercrm-api/blob/main/.env.example"

    %% Styles
    classDef gateway fill:#f9c,stroke:#333,stroke-width:2px;
    classDef controller fill:#bbf,stroke:#333,stroke-width:2px;
    classDef service fill:#bfb,stroke:#333,stroke-width:2px;
    classDef repository fill:#ffe4b5,stroke:#333,stroke-width:2px;
    classDef mapper fill:#d3d3d3,stroke:#333,stroke-width:2px;
    classDef validator fill:#fdfd96,stroke:#333,stroke-width:2px;
    classDef filter fill:#ffc0cb,stroke:#333,stroke-width:2px;
    classDef config fill:#e6e6fa,stroke:#333,stroke-width:2px;
    classDef exception fill:#ffa07a,stroke:#333,stroke-width:2px;
    classDef deployment fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef external fill:#dcdcdc,stroke:#333,stroke-dasharray: 5, 5;
```
