# skolavsky/diplom_mrs architecture

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

- Interactive diagram: https://gitdiagram.com/skolavsky/diplom_mrs
- Repository: https://github.com/skolavsky/diplom_mrs

## Overview

##### Main System Components

a) Web Layer:
- Nginx (reverse proxy/static files server)
- Gunicorn (WSGI server)

b) Application Layer (Django Apps):
- Webhandler (Main app handling authentication and base pages)
- Clients (Core business logic app)
- Blog (Content management)
- Account (User management)
- AI Module (Machine learning integration)

c) Database Layer:
- SQLite (development)
- Production database (likely PostgreSQL based on configuration)

##### Component Relationships

**[Client Browser] → [Nginx] → [Gunicorn] → [Django Apps]**
- ↓
- [Database]

##### Detailed Architecture

Webhandler:
- Authentication
- Base templates
- Static file handling

Clients:
- Client management
- Data processing
- AI integration
- Excel import/export

Blog:
- Post management
- Comments
- RSS feeds
- Sitemaps

Account:
- User management
- Profile handling
- Password reset

##### Special Features to Highlight

- AI Model integration (clients/AI/)
- Data import/export functionality
- Client data visualization
- Authentication flow
- Static file handling

##### Technical Details

Annotations for:
- Docker containerization
- Nginx configuration
- Gunicorn settings
- Development vs Production environments

##### Data Flow

- User request flow
- Data processing flow
- AI model interaction
- Static file serving
- Database operations

##### Environment Separation

A section showing:
- Development environment
- Production environment
- Docker container structure

This system design should reflect the project's Django-based architecture while highlighting its unique features like AI integration and client data management capabilities.

## Diagram (Mermaid)

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

    subgraph "Web Layer"
        Nginx["Nginx Server"]:::webserver
        Gunicorn["Gunicorn WSGI"]:::webserver
    end

    subgraph "Django Applications"
        direction TB
        WebHandler["Webhandler App"]:::django
        Clients["Clients App"]:::django
        Blog["Blog App"]:::django
        Account["Account App"]:::django

        subgraph "Webhandler Components"
            Auth["Authentication"]:::component
            BaseTemplates["Base Templates"]:::component
            StaticFiles["Static Files"]:::component
        end

        subgraph "Clients Components"
            ClientMgmt["Client Management"]:::component
            DataProc["Data Processing"]:::component
            ExcelIO["Excel Import/Export"]:::component
            
            subgraph "AI Module"
                AIMod["AI Model"]:::ai
                AIViews["AI Views"]:::ai
                AISerial["AI Serializers"]:::ai
            end
        end

        subgraph "Blog Components"
            Posts["Post Management"]:::component
            Comments["Comments System"]:::component
            RSS["RSS Feeds"]:::component
            Sitemap["Sitemaps"]:::component
        end

        subgraph "Account Components"
            UserMgmt["User Management"]:::component
            Profile["Profile Handling"]:::component
            PassReset["Password Reset"]:::component
        end
    end

    subgraph "Database Layer"
        DB[(Database)]:::database
    end

    Browser --> Nginx
    Nginx --> Gunicorn
    Gunicorn --> WebHandler
    WebHandler --> DB
    Clients --> DB
    Blog --> DB
    Account --> DB

    WebHandler --> Auth
    WebHandler --> BaseTemplates
    WebHandler --> StaticFiles

    Clients --> ClientMgmt
    Clients --> DataProc
    Clients --> ExcelIO
    Clients --> AIMod
    AIMod --> AIViews
    AIMod --> AISerial

    Blog --> Posts
    Blog --> Comments
    Blog --> RSS
    Blog --> Sitemap

    Account --> UserMgmt
    Account --> Profile
    Account --> PassReset

    %% Click events for component mapping
    click Nginx "https://github.com/skolavsky/diplom_mrs/blob/main/nginx/nginx.conf"
    click Gunicorn "https://github.com/skolavsky/diplom_mrs/blob/main/gunicorn.conf.py"
    click WebHandler "https://github.com/skolavsky/diplom_mrs/tree/main/mrs_proj/webhandler/"
    click Auth "https://github.com/skolavsky/diplom_mrs/blob/main/mrs_proj/webhandler/authentication.py"
    click BaseTemplates "https://github.com/skolavsky/diplom_mrs/blob/main/mrs_proj/webhandler/templates/base.html"
    click Clients "https://github.com/skolavsky/diplom_mrs/tree/main/mrs_proj/clients/"
    click ClientMgmt "https://github.com/skolavsky/diplom_mrs/blob/main/mrs_proj/clients/models.py"
    click DataProc "https://github.com/skolavsky/diplom_mrs/blob/main/mrs_proj/clients/ClientDataDownloader.py"
    click ExcelIO "https://github.com/skolavsky/diplom_mrs/blob/main/mrs_proj/clients/management/commands/excel_import.py"
    click AIMod "https://github.com/skolavsky/diplom_mrs/blob/main/mrs_proj/clients/AI/ai_model.py"
    click AIViews "https://github.com/skolavsky/diplom_mrs/blob/main/mrs_proj/clients/AI/views.py"
    click AISerial "https://github.com/skolavsky/diplom_mrs/blob/main/mrs_proj/clients/AI/serializers.py"
    click Blog "https://github.com/skolavsky/diplom_mrs/tree/main/mrs_proj/blog/"
    click RSS "https://github.com/skolavsky/diplom_mrs/blob/main/mrs_proj/blog/feeds.py"
    click Sitemap "https://github.com/skolavsky/diplom_mrs/blob/main/mrs_proj/blog/sitemaps.py"
    click Comments "https://github.com/skolavsky/diplom_mrs/blob/main/mrs_proj/blog/components/comments.py"
    click Account "https://github.com/skolavsky/diplom_mrs/tree/main/mrs_proj/account/"
    click UserMgmt "https://github.com/skolavsky/diplom_mrs/blob/main/mrs_proj/account/models.py"
    click Profile "https://github.com/skolavsky/diplom_mrs/blob/main/mrs_proj/account/views.py"
    click PassReset "https://github.com/skolavsky/diplom_mrs/tree/main/mrs_proj/account/templates/registration/"

    classDef webserver fill:#68a063,stroke:#333,stroke-width:2px
    classDef django fill:#44b78b,stroke:#333,stroke-width:2px
    classDef component fill:#3498db,stroke:#333,stroke-width:2px
    classDef database fill:#f1c40f,stroke:#333,stroke-width:2px
    classDef ai fill:#9b59b6,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["Web Server"]:::webserver
        L2["Django App"]:::django
        L3["Component"]:::component
        L4["Database"]:::database
        L5["AI Module"]:::ai
    end
```
