# divanov11/django-course architecture

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

- Interactive diagram: https://gitdiagram.com/divanov11/django-course
- Repository: https://github.com/divanov11/django-course

## Overview

##### Project Type & Purpose
- This is a monolithic, full-stack Django web application (“DevSearch”) that combines traditional server-rendered pages (HTML/CSS/JS) with a REST API (Django REST Framework).
- Users can register, log in, share projects, message other developers, rate work, and search profiles/projects.

##### High-Level Architecture Components
a. Clients & Entry Points
- Web Browser (end-user)
- Third-party API clients (e.g., mobile app or JS fetch calls to `/api/`)
b. Edge & Delivery Layer
- Heroku Router / Load Balancer (or Nginx)
- CDN or WhiteNoise for static assets (CSS/JS/images under `static` & `staticfiles`)
c. Application Layer
- WSGI/ASGI Server (Gunicorn/Uvicorn) invoking Django via `devsearch/wsgi.py` or `devsearch/asgi.py`
- Django Project (“devsearch” settings, URL routing)
- Django Apps:
– users (authentication, profiles, messaging)
– projects (project CRUD, ratings, search utilities)
– api (serializers, viewsets, URLs for REST endpoints)
d. Persistence Layer
- PostgreSQL Database (prod) or SQLite (`db.sqlite3` in dev)
- File storage for user-uploaded media (e.g., project images) – could be S3 or local `MEDIA_ROOT`
e. External Services (optional based on env)
- Email Service (password reset workflows)
- Monitoring/Logging (e.g., Sentry, Heroku logs)

##### Interactions & Data Flows
- User loads `login.html` or any server-rendered template → request hits Heroku Router → Gunicorn → Django view → Query Database → Render HTML + static references → Response to Browser.
- In-page JS (e.g., `main.js`, `login.js`) calls `/api/…` endpoints → JSON responses from DRF viewsets → UI updates.
- Static URLs (`/static/…` or `/staticfiles/…`) served by CDN or directly by WhiteNoise.
- Forms (project_form, message_form) post back to Django views in the appropriate app, which validate via `forms.py`, update models, then redirect or re-render.

##### Architectural Patterns & Principles
- MVT (Model-View-Template) for server-rendered pages
- RESTful resource routing for the API
- Single monolithic deployment unit, but logically separated apps
- Separation of concerns: authentication/messages vs. project CRUD vs. API layer

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend Layer" 
        direction TB
        Browser["Web Browser"]:::client
        Templates["HTML Templates"]:::frontend
        JS["Custom JS/CSS"]:::frontend
        ClientAPI["API Clients (JS/Mobile)"]:::client
        Browser -->|HTTP/HTTPS| LB
        Browser -->|renders| Templates
        Browser -->|loads| JS
        ClientAPI -->|HTTP/HTTPS| LB
    end

    subgraph "Edge & Delivery Layer"
        direction TB
        LB["Heroku Router / Nginx"]:::edge
        CDN["CDN / WhiteNoise"]:::static
        Browser -->|GET /static/...| CDN
    end

    LB -->|WSGI/ASGI| Server["Gunicorn/Uvicorn"]:::server

    subgraph "Application Layer"
        direction TB
        subgraph "Django Process"
            direction TB
            DjangoCore["Django Core\n(devsearch)"]:::django
            DjangoCore --> UsersApp
            DjangoCore --> ProjectsApp
            DjangoCore --> ApiApp
        end
        Server -->|invokes| DjangoCore
    end

    subgraph "Services"
        direction TB
        UsersApp["Users App"]:::service
        ProjectsApp["Projects App"]:::service
        ApiApp["API Layer (DRF)"]:::service
    end

    DjangoCore -->|email/password reset| Email["Email Service"]:::external
    Server -->|log events| Logging["Monitoring/Logging"]:::external

    subgraph "Persistence Layer"
        direction TB
        DB["PostgreSQL / SQLite"]:::db
        Media["Media Storage (S3 / Local)"]:::storage
    end

    UsersApp -->|reads/writes| DB
    ProjectsApp -->|reads/writes| DB
    ApiApp -->|reads/writes| DB
    Server -->|uploads/downloads| Media

    %% Click Events
    click Templates "https://github.com/divanov11/django-course/tree/master/templates/"
    click JS "https://github.com/divanov11/django-course/blob/master/frontend/main.js"
    click LB "https://github.com/divanov11/django-course/tree/master/Procfile"
    click Server "https://github.com/divanov11/django-course/blob/master/devsearch/wsgi.py"
    click Server "https://github.com/divanov11/django-course/blob/master/devsearch/asgi.py"
    click DjangoCore "https://github.com/divanov11/django-course/blob/master/devsearch/settings.py"
    click DjangoCore "https://github.com/divanov11/django-course/blob/master/devsearch/urls.py"
    click DjangoCore "https://github.com/divanov11/django-course/blob/master/manage.py"
    click UsersApp "https://github.com/divanov11/django-course/tree/master/users/"
    click ProjectsApp "https://github.com/divanov11/django-course/tree/master/projects/"
    click ApiApp "https://github.com/divanov11/django-course/tree/master/api/"
    click DB "https://github.com/divanov11/django-course/blob/master/db.sqlite3"
    click static "https://github.com/divanov11/django-course/tree/master/static/"
    click staticfiles "https://github.com/divanov11/django-course/tree/master/staticfiles/"

    %% Styles
    classDef client fill:#cdeefc,stroke:#07689f,color:#000;
    classDef frontend fill:#e0f7fa,stroke:#006064,color:#000;
    classDef edge fill:#f1f8e9,stroke:#33691e,color:#000;
    classDef static fill:#fff3e0,stroke:#e65100,color:#000;
    classDef server fill:#ede7f6,stroke:#4527a0,color:#000;
    classDef django fill:#f3e5f5,stroke:#4a148c,color:#000;
    classDef service fill:#e8f5e9,stroke:#1b5e20,color:#000;
    classDef db fill:#fff8e1,stroke:#ff6f00,color:#000;
    classDef storage fill:#eceff1,stroke:#37474f,color:#000;
    classDef external fill:#ffebee,stroke:#b71c1c,color:#000;
```
