# eugleo/request2-service architecture

> Architecture diagram of the GitHub repository eugleo/request2-service, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eugleo/request2-service
- Repository: https://github.com/eugleo/request2-service

## Overview

##### Main System Components

a) Frontend Layer:
- React-based web application (from the frontend submodule)
- Form rendering system for custom request types
- User interface for request management and tracking

b) Backend Layer:
- Haskell-based API server
- Authentication/Authorization system
- Email notification service (using ssmtp)

c) Storage Layer:
- PostgreSQL database for request data and user information
- File storage system for uploaded files

##### External Dependencies
- Mail server (SMTP) for notifications
- Docker container environment

**[Client Browser] → [Frontend (React)] → [Backend (Haskell)] → [Storage]**

##### User form submission flow
Client → Frontend → Backend → Database
##### File upload flow
Client → Frontend → Backend → File Storage
##### Notification flow
Backend → SMTP Server → User Email

##### Important Subsystems

a) Form Management:
- Relationship between RequestTypes directory and frontend form rendering
- How custom forms are compiled and served

b) Request Processing:
- Workflow of request creation, tracking, and updates
- Changelog system

c) Authentication Flow:
- Token-based authentication system
- Password reset flow

##### Configuration Components

A section showing configuration dependencies:
- request2.cfg (backend configuration)
- ssmtp.conf (email configuration)
- Docker configuration

##### Specific Details

Annotations for:
- Port 8080 for backend service
- Mounted storage at /srv/data
- Database connection
- Email notification system

##### Integration Points

Clearly mark:
- API endpoints between frontend and backend
- Database connection points
- File storage mount points
- Email service integration

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]:::client
    end

    subgraph Frontend
        ReactApp["React Application"]:::frontend
        FormRenderer["Form Rendering System"]:::frontend
        UIComponents["User Interface Components"]:::frontend
    end

    subgraph Backend
        HaskellAPI["Haskell API Server"]:::backend
        AuthSystem["Authentication System"]:::backend
        EmailService["Email Notification Service"]:::backend
    end

    subgraph Storage
        DB[(PostgreSQL Database)]:::storage
        FileStore[("File Storage<br>/srv/data")]:::storage
    end

    subgraph External
        SMTP{"SMTP Server"}:::external
    end

    subgraph Configuration
        Config["System Configuration"]:::config
    end

    %% Connections
    Browser --> ReactApp
    ReactApp --> FormRenderer
    ReactApp --> UIComponents
    FormRenderer --> HaskellAPI
    UIComponents --> HaskellAPI
    HaskellAPI --> AuthSystem
    HaskellAPI --> EmailService
    HaskellAPI --> DB
    HaskellAPI --> FileStore
    EmailService --> SMTP
    Config --> HaskellAPI
    Config --> EmailService

    %% Click Events
    click ReactApp "https://github.com/Eugleo/request2-service/tree/main/frontend"
    click HaskellAPI "https://github.com/Eugleo/request2-service/tree/main/backend"
    click FormRenderer "https://github.com/Eugleo/request2-service/tree/main/RequestTypes"
    click Config "https://github.com/Eugleo/request2-service/tree/main/config"
    click Config "https://github.com/Eugleo/request2-service/blob/main/config/request2.cfg"
    click EmailService "https://github.com/Eugleo/request2-service/blob/main/config/ssmtp.conf"

    %% Styles
    classDef client fill:#f9f,stroke:#333,stroke-width:2px
    classDef frontend fill:#69b3a2,stroke:#333,stroke-width:2px
    classDef backend fill:#3498db,stroke:#333,stroke-width:2px
    classDef storage fill:#f1c40f,stroke:#333,stroke-width:2px
    classDef external fill:#95a5a6,stroke:#333,stroke-width:2px
    classDef config fill:#e74c3c,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        Client_L["Client"]:::client
        Frontend_L["Frontend Components"]:::frontend
        Backend_L["Backend Services"]:::backend
        Storage_L["Storage Systems"]:::storage
        External_L["External Services"]:::external
        Config_L["Configuration"]:::config
    end
```
