# foxy4096/vitary-classic architecture

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

- Interactive diagram: https://gitdiagram.com/foxy4096/vitary-classic
- Repository: https://github.com/foxy4096/vitary-classic

## Overview

##### Project type and purpose
- This is a monolithic, full-stack Django web application (“Vitary”) implementing a simple social media platform.
- The README describes user registration, posting, feeds, chat, notifications, GraphQL API, file uploads (via Google Drive storage), and email features.

##### File structure
- Top-level:
- manage.py – Django CLI entry point
- Vitary/ – Django project settings, URL conf, WSGI/ASGI
- apps/ – seven Django apps (account, api, blog, chat, core, feed, notification)
- media/ – user-uploaded files (images, videos)
- templates/ – global error pages and admin/fallback templates
- req.txt – Python dependencies
- Each app follows standard Django conventions: models, migrations, views, templates, urls, tests.
- apps/api contains both REST and GraphQL endpoints.
- Vitary/asgi.py indicates support for asynchronous protocols (e.g., WebSockets).
- Static assets (CSS/JS) live under apps/core/static.

##### README for additional insights
- Specifies use of Django + virt env + migrations + Google Drive storage + optional email configuration

a. Main components:
- Client (Web Browser or Mobile Hybrid)
- CDN or Static-file server (serving CSS, JS, images)
- Load-Balancer / Reverse Proxy (e.g., Nginx)
- Application Server (ASGI via Daphne/Uvicorn or WSGI via Gunicorn)
- Django monolith comprising:
– account app (user management, auth)
– core app (templates, context processors, global utilities, HTMX)
– feed app (posts, comments, likes, email notifications)
– blog app (blog posts)
– chat app (direct messages)
– notification app (site notifications)
– api app (REST & GraphQL endpoints)
- Database (PostgreSQL or other)
- External storage (Google Drive via django-googledrive-storage)
- Email service (SMTP)
- (Optional) Cache/Queue (Redis + Celery for feed tasks)

b. Relationships & interactions:
- Browser → Reverse Proxy via HTTPS → Django ASGI/WSGI
- Django → Database for reads/writes
- Django → Google Drive for media storage
- Django → SMTP server for outbound emails
- apps/feed.tasks (Celery workers) ↔ Redis broker ↔ Django
- API clients ↔ apps/api endpoints (REST & GraphQL)
- WebSocket clients → ASGI channel layers (if real-time chat used)

c. Architectural patterns & design principles:
- Monolithic modularization: each feature in its own Django app
- MVC (Django’s MTV) pattern
- Async support via ASGI for real-time features
- Background processing via Celery & Redis (feed tasks, email notifications)
- Externalized storage (Google Drive) for scalability
- Template-driven UI with progressive enhancement (HTMX)

d. Key technologies/frameworks:
- Python 3 + Django
- HTMX for in-page updates
- Graphene or similar for GraphQL schemas
- django-googledrive-storage
- Celery + Redis (if configured)
- PostgreSQL (or default SQLite)
- Nginx + Gunicorn/Uvicorn

##### Elements
- Clear labels: “Browser”, “Nginx (SSL)”, “Gunicorn/Uvicorn”, each Django app, “PostgreSQL”, “Google Drive”, “SMTP”, “Redis/Celery”
- HTTP/HTTPS requests
- Data reads/writes
- Background job dispatch & result flows
- File upload/download flows

##### Detail
- Every Django app as a distinct component.
- Static/media serving as a separate flow.
- Both legacy API endpoints and GraphQL schemas under the api app.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Tier
    Browser["Browser / API Consumer"]:::external
    Mobile["Mobile Hybrid App"]:::external

    %% Edge Tier
    CDN["CDN / Static File Server"]:::infra
    Proxy["Nginx (SSL & Reverse Proxy)"]:::infra

    %% Application Tier
    subgraph "Application Tier"
        direction TB
        ASGI["ASGI Entry (Daphne/Uvicorn)"]:::infra
        WSGI["WSGI Entry (Gunicorn)"]:::infra
        subgraph "Django Monolith"
            direction TB
            manage["manage.py"]:::infra
            subgraph "Django Project Config"
                direction TB
                settings["settings.py"]:::app
                urls["urls.py"]:::app
            end
            subgraph "Apps"
                direction TB
                account["account app"]:::app
                core["core app"]:::app
                feed["feed app"]:::app
                blog["blog app"]:::app
                chat["chat app"]:::app
                notification["notification app"]:::app
                api["api app (REST & GraphQL)"]:::app
            end
        end
        subgraph "Background Workers"
            direction TB
            Celery["Celery Worker Pool"]:::optional
            Redis["Redis Broker"]:::service
        end
    end

    %% Data Tier
    subgraph "Data Tier"
        direction TB
        DB["PostgreSQL Database"]:::service
        Drive["Google Drive Storage"]:::service
        SMTP["SMTP Email Service"]:::service
    end

    %% Connections
    Browser -->|"HTTPS"| CDN
    Mobile -->|"HTTPS"| Proxy
    CDN --> Proxy
    Proxy --> ASGI
    Proxy --> WSGI
    ASGI -->|"Loads manage.py"| manage
    WSGI --> manage
    manage --> settings
    manage --> urls
    manage --> account
    manage --> core
    manage --> feed
    manage --> blog
    manage --> chat
    manage --> notification
    manage --> api

    WSGI -->|"HTTP"| core
    WSGI -->|"HTTP"| account
    WSGI -->|"HTTP"| feed
    WSGI -->|"HTTP"| blog
    WSGI -->|"HTTP"| chat
    WSGI -->|"HTTP"| notification
    WSGI -->|"HTTP"| api

    ASGI -->|"WebSocket"| chat

    core --> DB
    account --> DB
    feed --> DB
    blog --> DB
    chat --> DB
    notification --> DB
    api --> DB

    feed -->|"Upload"| Drive
    core -->|"Serve static"| CDN

    feed -->|"Enqueue tasks"| Redis
    Redis --> Celery
    Celery --> feed

    feed -->|"Send email"| SMTP

    api -->|"REST / GraphQL"| Browser
    api -->|"REST / GraphQL"| Mobile

    %% Click Events
    click manage "https://github.com/foxy4096/vitary-classic/blob/main/manage.py"
    click ASGI "https://github.com/foxy4096/vitary-classic/blob/main/Vitary/asgi.py"
    click WSGI "https://github.com/foxy4096/vitary-classic/blob/main/Vitary/wsgi.py"
    click settings "https://github.com/foxy4096/vitary-classic/blob/main/Vitary/settings.py"
    click urls "https://github.com/foxy4096/vitary-classic/blob/main/Vitary/urls.py"
    click account "https://github.com/foxy4096/vitary-classic/tree/main/apps/account/"
    click core "https://github.com/foxy4096/vitary-classic/tree/main/apps/core/"
    click feed "https://github.com/foxy4096/vitary-classic/tree/main/apps/feed/"
    click blog "https://github.com/foxy4096/vitary-classic/tree/main/apps/blog/"
    click chat "https://github.com/foxy4096/vitary-classic/tree/main/apps/chat/"
    click notification "https://github.com/foxy4096/vitary-classic/tree/main/apps/notification/"
    click api "https://github.com/foxy4096/vitary-classic/tree/main/apps/api/"

    %% Styles
    classDef infra fill:#e0f7fa,stroke:#006064,color:#006064
    classDef service fill:#e3f2fd,stroke:#1565c0,color:#1565c0
    classDef app fill:#fff9c4,stroke:#f9a825,color:#f57f17
    classDef optional stroke-dasharray: 5 5,fill:#fce4ec,stroke:#880e4f,color:#880e4f
    class Browser,Mobile,CDN,Proxy,ASGI,WSGI,manage,settings,urls,account,core,feed,blog,chat,notification,api,DB,Drive,SMTP,Celery,Redis infra,app,service,optionalISIBLE
```
