# rajaaltus/peppermint architecture

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

- Interactive diagram: https://gitdiagram.com/rajaaltus/peppermint
- Repository: https://github.com/rajaaltus/peppermint

## Overview

##### Main System Components

a) Frontend Layer:
- Next.js Client Application (apps/client)
- Documentation Site (apps/docs)
- Landing Page (apps/landing)

b) Backend Layer:
- API Server (apps/api)
- Authentication Services
- Email Processing System
- File Storage System

c) Database Layer:
- PostgreSQL Database (indicated by Prisma schema and migrations)

##### Key Architectural Elements

a) Client-Side Architecture:
**[Web Clients] → [Next.js Frontend]**
- ↓
- [Component Layer]
- ↓
- [State Management]
- ↓
- [API Integration]

b) Server-Side Architecture:
**[API Layer (Express.js)]**
- ↓
**[Controller Layer]**
- ↓
**[Service Layer]**
- ↓
**[Data Access Layer (Prisma)]**
- ↓
**[PostgreSQL Database]**

##### Integration Points

Crucial integrations:
- Authentication flows (OAuth, OIDC, SAML)
- Email integration (IMAP, SMTP)
- Webhook system
- File storage system
- Notification system

##### Specific Implementation Details

Key features:
- Ticket management flow
- User role management (RBAC)
- Email queue system
- Notification pipeline
- Document/file handling

**[Client Layer]**
- ↓
**[API Gateway]**
- ↓
**[Service Layer]**
- ↓
**[Data Layer]**

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black
    classDef security fill:#e74c3c,stroke:#c0392b,color:white

    %% Frontend Layer
    subgraph Frontend
        Client["Next.js Client"]
        Docs["Documentation Site"]
        Landing["Landing Page"]
        
        ComponentLayer["Component Layer"]
        StateManagement["State Management"]
        APIIntegration["API Integration"]
        
        Client --> ComponentLayer
        ComponentLayer --> StateManagement
        StateManagement --> APIIntegration
    end

    %% Backend Layer
    subgraph Backend
        APIGateway["API Gateway"]
        AuthService["Authentication Service"]
        EmailProcessor["Email Processing System"]
        FileStorage["File Storage System"]
        NotificationSystem["Notification System"]
        WebhookSystem["Webhook System"]
        QueueSystem["Email Queue System"]
        RoleManager["Role Management (RBAC)"]
        TicketController["Ticket Management"]
    end

    %% Database Layer
    subgraph Data
        Prisma["Data Access Layer (Prisma)"]
        PostgreSQL[(PostgreSQL Database)]
    end

    %% External Integrations
    subgraph Integrations
        OAuth["OAuth"]
        OIDC["OIDC"]
        SAML["SAML"]
        IMAP["IMAP"]
        SMTP["SMTP"]
    end

    %% Connections
    APIIntegration --> APIGateway
    APIGateway --> AuthService
    APIGateway --> EmailProcessor
    APIGateway --> FileStorage
    APIGateway --> NotificationSystem
    APIGateway --> WebhookSystem
    APIGateway --> QueueSystem
    APIGateway --> RoleManager
    APIGateway --> TicketController

    AuthService --> OAuth
    AuthService --> OIDC
    AuthService --> SAML
    EmailProcessor --> IMAP
    EmailProcessor --> SMTP

    TicketController --> Prisma
    RoleManager --> Prisma
    FileStorage --> Prisma
    NotificationSystem --> Prisma
    WebhookSystem --> Prisma
    QueueSystem --> Prisma
    
    Prisma --> PostgreSQL

    %% Click Events
    click Client "https://github.com/rajaaltus/peppermint/tree/main/apps/client"
    click Docs "https://github.com/rajaaltus/peppermint/tree/main/apps/docs"
    click Landing "https://github.com/rajaaltus/peppermint/tree/main/apps/landing"
    click APIGateway "https://github.com/rajaaltus/peppermint/tree/main/apps/api"
    click AuthService "https://github.com/rajaaltus/peppermint/blob/main/apps/api/src/controllers/auth.ts"
    click EmailProcessor "https://github.com/rajaaltus/peppermint/tree/main/apps/api/src/lib/nodemailer"
    click FileStorage "https://github.com/rajaaltus/peppermint/blob/main/apps/api/src/controllers/storage.ts"
    click NotificationSystem "https://github.com/rajaaltus/peppermint/tree/main/apps/api/src/lib/notifications"
    click Prisma "https://github.com/rajaaltus/peppermint/tree/main/apps/api/src/prisma"
    click OAuth "https://github.com/rajaaltus/peppermint/blob/main/apps/api/src/lib/utils/oauth_client.ts"
    click OIDC "https://github.com/rajaaltus/peppermint/blob/main/apps/api/src/lib/utils/oidc_client.ts"
    click SAML "https://github.com/rajaaltus/peppermint/blob/main/apps/api/src/lib/utils/saml_client.ts"
    click TicketController "https://github.com/rajaaltus/peppermint/blob/main/apps/api/src/controllers/ticket.ts"
    click RoleManager "https://github.com/rajaaltus/peppermint/blob/main/apps/api/src/controllers/roles.ts"
    click WebhookSystem "https://github.com/rajaaltus/peppermint/blob/main/apps/api/src/controllers/webhooks.ts"
    click QueueSystem "https://github.com/rajaaltus/peppermint/blob/main/apps/api/src/controllers/queue.ts"

    %% Style Applications
    class Client,Docs,Landing,ComponentLayer,StateManagement,APIIntegration frontend
    class APIGateway,AuthService,EmailProcessor,FileStorage,NotificationSystem,WebhookSystem,QueueSystem,RoleManager,TicketController backend
    class Prisma,PostgreSQL database
    class OAuth,OIDC,SAML,IMAP,SMTP external
```
