# krzysztofmarciniak/mrs-funding-software architecture

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

- Interactive diagram: https://gitdiagram.com/krzysztofmarciniak/mrs-funding-software
- Repository: https://github.com/krzysztofmarciniak/mrs-funding-software

## Overview

##### Main Components

a) Frontend Layer:
- Static content delivery (HTML/CSS)
- Theme management system
- View templates (located in src/views)
- No JavaScript (as highlighted in features)

b) Backend Layer:
- Rust-based web server
- Controller layer (src/controllers)
- Middleware components (CSRF protection)
- Route handling (src/routes.rs)

c) Data Layer:
- SQLite database
- Database interface (src/db.rs)

d) Infrastructure:
- Nginx reverse proxy with WAF
- Docker containerization
- Environment configuration

**┌─────────────────────────────────────────────┐**
- Client Layer                │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Nginx Reverse Proxy            │
- (with ModSecurity WAF)              │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Rust Application              │
- ┬─────────────────────┐
- View Layer       │   Controller Layer   │
- (Templates)      │   (Route Handlers)   │
- ┴─────────────────────┤
- Middleware (CSRF)                │
- ┤
- Database Interface               │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- SQLite Database               │
- ┘

##### Important Flows to Highlight

a) Authentication Flow:
- Login controller (src/controllers/login.rs)
- CSRF protection (src/middleware/csrf.rs)
- Session management

b) Campaign Management Flow:
- Campaign creation/management (src/controllers/campaigns.rs)
- Dashboard interactions (src/controllers/dashboard.rs)

c) Theme Management Flow:
- Theme selection (src/views/themes/theme_manager.rs)
- CSS delivery system

##### Additional Details

- View blocks (footer, header, head)
- Theme management
- Controller interactions
- Route mapping

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph Infrastructure
        Nginx["Nginx Reverse Proxy"]:::proxy
        WAF["ModSecurity WAF"]:::security
    end

    subgraph "Application Server"
        Server["Server"]:::server
        click Server "https://github.com/KrzysztofMarciniak/MRS-Funding-Software/blob/main/src/server.rs"

        subgraph "View Layer"
            Templates["View Templates"]:::view
            click Templates "https://github.com/KrzysztofMarciniak/MRS-Funding-Software/tree/main/src/views/"
            ThemeManager["Theme Manager"]:::view
            click ThemeManager "https://github.com/KrzysztofMarciniak/MRS-Funding-Software/blob/main/src/views/themes/theme_manager.rs"
            Layout["Layout System"]:::view
            click Layout "https://github.com/KrzysztofMarciniak/MRS-Funding-Software/blob/main/src/views/layout.rs"
            
            subgraph "View Blocks"
                Header["Header Block"]:::view
                click Header "https://github.com/KrzysztofMarciniak/MRS-Funding-Software/blob/main/src/views/blocks/header.rs"
                Footer["Footer Block"]:::view
                click Footer "https://github.com/KrzysztofMarciniak/MRS-Funding-Software/blob/main/src/views/blocks/footer.rs"
                Head["Head Block"]:::view
                click Head "https://github.com/KrzysztofMarciniak/MRS-Funding-Software/blob/main/src/views/blocks/head.rs"
            end

            subgraph "Themes"
                DefaultTheme["Default Theme"]:::theme
                click DefaultTheme "https://github.com/KrzysztofMarciniak/MRS-Funding-Software/blob/main/src/views/themes/default.css"
                MinimalTheme["Minimal Theme"]:::theme
                click MinimalTheme "https://github.com/KrzysztofMarciniak/MRS-Funding-Software/blob/main/src/views/themes/minimal.css"
                MoneroTheme["Monero Theme"]:::theme
                click MoneroTheme "https://github.com/KrzysztofMarciniak/MRS-Funding-Software/blob/main/src/views/themes/monero.css"
            end
        end

        subgraph "Controller Layer"
            Routes["Route Handler"]:::controller
            click Routes "https://github.com/KrzysztofMarciniak/MRS-Funding-Software/blob/main/src/routes.rs"
            
            subgraph "Controllers"
                LoginController["Authentication Controller"]:::controller
                click LoginController "https://github.com/KrzysztofMarciniak/MRS-Funding-Software/blob/main/src/controllers/login.rs"
                CampaignController["Campaign Controller"]:::controller
                click CampaignController "https://github.com/KrzysztofMarciniak/MRS-Funding-Software/blob/main/src/controllers/campaigns.rs"
                DashboardController["Dashboard Controller"]:::controller
                click DashboardController "https://github.com/KrzysztofMarciniak/MRS-Funding-Software/blob/main/src/controllers/dashboard.rs"
            end
        end

        subgraph "Middleware Layer"
            CSRF["CSRF Protection"]:::security
            click CSRF "https://github.com/KrzysztofMarciniak/MRS-Funding-Software/blob/main/src/middleware/csrf.rs"
        end

        subgraph "Data Layer"
            DBInterface["Database Interface"]:::data
            click DBInterface "https://github.com/KrzysztofMarciniak/MRS-Funding-Software/blob/main/src/db.rs"
        end
    end

    subgraph "Storage Layer"
        SQLite[(SQLite Database)]:::database
    end

    Browser --> Nginx
    Nginx --> WAF
    WAF --> Server
    Server --> Routes
    Routes --> Controllers
    Routes --> CSRF
    Controllers --> Templates
    Templates --> ThemeManager
    ThemeManager --> Themes
    Templates --> Layout
    Layout --> Header
    Layout --> Footer
    Layout --> Head
    Controllers --> DBInterface
    DBInterface --> SQLite

    classDef proxy fill:#6B8E23,stroke:#333,stroke-width:2px
    classDef security fill:#FFD700,stroke:#333,stroke-width:2px
    classDef server fill:#4682B4,stroke:#333,stroke-width:2px
    classDef view fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef controller fill:#32CD32,stroke:#333,stroke-width:2px
    classDef data fill:#FF6B6B,stroke:#333,stroke-width:2px
    classDef database fill:#DC143C,stroke:#333,stroke-width:2px
    classDef theme fill:#DDA0DD,stroke:#333,stroke-width:2px
```
