# f4r4n/movie-quote architecture

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

- Interactive diagram: https://gitdiagram.com/f4r4n/movie-quote
- Repository: https://github.com/f4r4n/movie-quote

## Overview

##### Project Type and Purpose
- This is a backend-only REST API service built with Django and Django REST Framework.
- Its sole responsibility is to serve random movie and series quotes via versioned HTTP endpoints.
- The project is deployed on Heroku and uses a relational database (e.g., PostgreSQL).

##### Analyzing the File Structure
- Top-level “config” directory holds Django settings, URL routing, and ASGI/WGI entrypoints.
- Three Django apps represent the core functionality:
- api – exposes quote endpoints, handles serialization and view logic
- auth – custom authentication models and views (token/session handling)
- statistic – scheduled or on-demand reporting (management commands, report generation)
- Templates folder holds email templates for notifications or reporting.
- Scripts and configs—build.sh, Procfile, runtime.txt, requirements.txt—drive deployment on Heroku.
- manage.py is the Django CLI entrypoint; clock.py likely orchestrates scheduled tasks (cron).

##### Relationships and Data Flows
- Management flow: Scheduler Dyno → clock.py → Django → monthly_report command → DB read/write and email templating (templates/email.html & .txt) → external email service (SMTP).

##### Architectural Patterns and Principles
- MVC/MVT pattern inherent in Django (Models, Views, Templates).
- Layered architecture: transport (HTTP) → application (views/serializers) → domain (models) → infrastructure (DB).
- Separation of concerns: auth logic isolated in its own Django app; quote logic in “api”; reporting in “statistic.”
- Twelve-factor App principles: configuration in environment, Procfile for process types, buildpacks via Heroku.

##### Technologies and Frameworks
- Python 3.x
- Django and Django REST Framework
- Gunicorn as WSGI server
- PostgreSQL (managed by Heroku)
- Procfile / runtime.txt for Heroku deployment
- Cron or Heroku Scheduler for periodic tasks

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Clients
    subgraph "External Clients"
        direction TB
        Client1["Mobile App"]:::external
        Client2["Web Browser"]:::external
        Client3["API Tools (Postman, cURL)"]:::external
    end

    %% Heroku Platform
    subgraph "Heroku Platform" 
        direction TB
        Router["Heroku Router"]:::platform
        WebDyno["Web Dyno\n(Gunicorn + Django)"]:::platform
        Scheduler["Scheduler Dyno"]:::platform
    end

    %% Django Application
    subgraph "Django Application" 
        direction TB
        subgraph "Entry Points"
            direction TB
            WSGI["WSGI Entry Point"]:::app
            ASGI["ASGI Entry Point"]:::app
        end
        URLConf["URL Dispatcher\n(config/urls.py)"]:::app
        subgraph "Apps"
            direction TB
            subgraph "API App"
                direction TB
                API_URLs["api/urls.py"]:::app
                API_Views["api/views.py"]:::app
                API_Serializers["api/serializers.py"]:::app
                API_Models["api/models.py"]:::app
                API_Utils["api/utils.py"]:::app
                API_Admin["api/admin.py"]:::app
                API_Tests["api/tests.py"]:::app
            end
            subgraph "Auth App"
                direction TB
                Auth_URLs["auth/urls.py"]:::app
                Auth_Views["auth/views.py"]:::app
                Auth_Serializers["auth/serializers.py"]:::app
                Auth_Models["auth/models.py"]:::app
                Auth_Admin["auth/admin.py"]:::app
                Auth_Tests["auth/tests.py"]:::app
            end
            subgraph "Statistic App"
                direction TB
                Stat_URLs["statistic/urls.py"]:::app
                Stat_Views["statistic/views.py"]:::app
                Stat_Serializers["statistic/serializers.py"]:::app
                Stat_Models["statistic/models.py"]:::app
                Stat_Utils["statistic/utils.py"]:::app
                Stat_Report["statistic/report.py"]:::app
                Stat_Admin["statistic/admin.py"]:::app
                Stat_Mgmt["monthly_report\n(statistic/management/commands)"]:::app
            end
        end
        TemplatesHTML["templates/email.html"]:::app
        TemplatesTXT["templates/email.txt"]:::app
    end

    %% Database and External Services
    DB["PostgreSQL Database"]:::datastore
    SMTP["External SMTP Service"]:::external

    %% Django CLI & Scheduler Entrypoints
    Manage["manage.py"]:::app
    Clock["clock.py"]:::app

    %% Request Flow
    Client1 -->|HTTP/HTTPS| Router
    Client2 -->|HTTP/HTTPS| Router
    Client3 -->|HTTP/HTTPS| Router
    Router --> WebDyno
    WebDyno -->|"WSGI"| WSGI
    WebDyno -->|"ASGI"| ASGI
    WSGI --> URLConf
    ASGI --> URLConf
    URLConf --> API_URLs
    URLConf --> Auth_URLs
    URLConf --> Stat_URLs
    API_URLs --> API_Views
    Auth_URLs --> Auth_Views
    Stat_URLs --> Stat_Views
    API_Views --> API_Serializers
    Auth_Views --> Auth_Serializers
    Stat_Views --> Stat_Serializers
    API_Serializers --> API_Models
    Auth_Serializers --> Auth_Models
    Stat_Serializers --> Stat_Models
    API_Models --> DB
    Auth_Models --> DB
    Stat_Models --> DB
    DB --> API_Models
    DB --> Auth_Models
    DB --> Stat_Models
    API_Serializers --> API_Views
    Auth_Serializers --> Auth_Views
    Stat_Serializers --> Stat_Views
    API_Views -->|HTTP Response| WebDyno
    Auth_Views -->|HTTP Response| WebDyno
    Stat_Views -->|HTTP Response| WebDyno
    WebDyno -->|HTTP/HTTPS| Router

    %% Management Flow (Dashed)
    Scheduler -.-> Clock
    Clock --> Manage
    Manage --> Stat_Mgmt
    Stat_Mgmt --> DB
    Stat_Mgmt --> TemplatesHTML
    Stat_Mgmt --> TemplatesTXT
    Stat_Mgmt --> SMTP

    %% Click Events
    click WSGI "https://github.com/f4r4n/movie-quote/blob/main/config/wsgi.py"
    click ASGI "https://github.com/f4r4n/movie-quote/blob/main/config/asgi.py"
    click URLConf "https://github.com/f4r4n/movie-quote/blob/main/config/urls.py"
    click API_URLs "https://github.com/f4r4n/movie-quote/blob/main/api/urls.py"
    click API_Views "https://github.com/f4r4n/movie-quote/blob/main/api/views.py"
    click API_Serializers "https://github.com/f4r4n/movie-quote/blob/main/api/serializers.py"
    click API_Models "https://github.com/f4r4n/movie-quote/blob/main/api/models.py"
    click API_Utils "https://github.com/f4r4n/movie-quote/blob/main/api/utils.py"
    click API_Admin "https://github.com/f4r4n/movie-quote/blob/main/api/admin.py"
    click API_Tests "https://github.com/f4r4n/movie-quote/blob/main/api/tests.py"
    click Auth_URLs "https://github.com/f4r4n/movie-quote/blob/main/auth/urls.py"
    click Auth_Views "https://github.com/f4r4n/movie-quote/blob/main/auth/views.py"
    click Auth_Serializers "https://github.com/f4r4n/movie-quote/blob/main/auth/serializers.py"
    click Auth_Models "https://github.com/f4r4n/movie-quote/blob/main/auth/models.py"
    click Auth_Admin "https://github.com/f4r4n/movie-quote/blob/main/auth/admin.py"
    click Auth_Tests "https://github.com/f4r4n/movie-quote/blob/main/auth/tests.py"
    click Stat_URLs "https://github.com/f4r4n/movie-quote/blob/main/statistic/urls.py"
    click Stat_Views "https://github.com/f4r4n/movie-quote/blob/main/statistic/views.py"
    click Stat_Serializers "https://github.com/f4r4n/movie-quote/blob/main/statistic/serializers.py"
    click Stat_Models "https://github.com/f4r4n/movie-quote/blob/main/statistic/models.py"
    click Stat_Utils "https://github.com/f4r4n/movie-quote/blob/main/statistic/utils.py"
    click Stat_Report "https://github.com/f4r4n/movie-quote/blob/main/statistic/report.py"
    click Stat_Mgmt "https://github.com/f4r4n/movie-quote/blob/main/statistic/management/commands/monthly_report.py"
    click Stat_Admin "https://github.com/f4r4n/movie-quote/blob/main/statistic/admin.py"
    click TemplatesHTML "https://github.com/f4r4n/movie-quote/blob/main/templates/email.html"
    click TemplatesTXT "https://github.com/f4r4n/movie-quote/blob/main/templates/email.txt"
    click Manage "https://github.com/f4r4n/movie-quote/blob/main/manage.py"
    click Clock "https://github.com/f4r4n/movie-quote/blob/main/clock.py"

    %% Styles
    classDef platform fill:#cce5ff,stroke:#339,stroke-width:1px;
    classDef app fill:#d4edda,stroke:#228B22,stroke-width:1px;
    classDef datastore fill:#ffe5b4,stroke:#d2691e,stroke-width:1px;
    classDef external fill:#e2e3e5,stroke:#6c757d,stroke-width:1px;
```
