# archimedesaj/cms-api architecture

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

- Interactive diagram: https://gitdiagram.com/archimedesaj/cms-api
- Repository: https://github.com/archimedesaj/cms-api

## Overview

##### Main components
a. Client(s) – e.g. web/mobile apps or third-party integrators
b. API Gateway / HTTP Layer – Django’s ASGI/WSGI entrypoints + URL dispatcher (`cmsapi/asgi.py`, `cmsapi/wsgi.py`, `cmsapi/urls.py`)
c. Django Project Core – settings, shared middleware (`cmsapi/settings.py`)
d. Django Apps (logical modules):
- `accounts` (authentication, user profiles)
- `member` (church member records)
- `sundayschool` (Sunday school classes & rosters)
- `visitor` (visitor tracking)
e. Business Logic – views (`views.py`), serializers (`serializers.py`) within each app
f. Persistence Layer – Django ORM + SQLite (`db.sqlite3`)
g. Media Store – local filesystem under `media/photos/...`
h. Development Environment – virtualenv (`venv`), `manage.py`

##### Relationships and data-flow
- Clients send HTTP requests → API Gateway (ASGI/WSGI)
- URL router dispatches to app-specific URL modules (`accounts/urls.py`, etc.)
- Requests handled by View classes/functions
- Views invoke Serializers → validate/transform input/output
- Serializers interact with Models → Django ORM executes CRUD on SQLite
- ORM writes/reads `db.sqlite3`; media uploads written to `media/`
- Responses flow back up to the client

##### Architectural patterns and principles
- Modular monolith: each app encapsulates its own models, serializers, views, URLs, and tests
- RESTful design: resources exposed via standard HTTP verbs (GET, POST, PUT, DELETE)
- Separation of concerns:
– URL routing → request dispatch
– Views → orchestrate logic
– Serializers → data validation & transformation
– Models → persistence schema
- Use of Django’s built-in admin for management (`admin.py`)

##### Technologies/frameworks
- Python 3 + Django REST Framework
- SQLite for quick local development
- Django’s built-in static/media handling
- Virtual environment (`venv`) for dependency isolation

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Clients
    Client["External Client"]:::client

    %% API Gateway / HTTP Layer
    subgraph "API Gateway / HTTP Layer"
        ASGI["asgi.py"]:::framework
        WSGI["wsgi.py"]:::framework
        URLRouter["urls.py"]:::framework
    end

    %% Django Project Core
    Settings["settings.py"]:::framework

    %% Django Apps
    subgraph "Django Apps"
        subgraph "accounts app"
            A_models["models.py"]:::framework
            A_serializers["serializers.py"]:::framework
            A_views["views.py"]:::framework
            A_urls["urls.py"]:::framework
            A_admin["admin.py"]:::framework
            A_tests["tests.py"]:::framework
            A_migrations["migrations/"]:::framework
        end
        subgraph "member app"
            M_models["models.py"]:::framework
            M_serializers["serializers.py"]:::framework
            M_views["views.py"]:::framework
            M_urls["urls.py"]:::framework
            M_admin["admin.py"]:::framework
            M_tests["tests.py"]:::framework
            M_migrations["migrations/"]:::framework
        end
        subgraph "sundayschool app"
            S_models["models.py"]:::framework
            S_serializers["serializers.py"]:::framework
            S_views["views.py"]:::framework
            S_urls["urls.py"]:::framework
            S_admin["admin.py"]:::framework
            S_tests["tests.py"]:::framework
            S_migrations["migrations/"]:::framework
        end
        subgraph "visitor app"
            V_models["models.py"]:::framework
            V_serializers["serializers.py"]:::framework
            V_views["views.py"]:::framework
            V_urls["urls.py"]:::framework
            V_admin["admin.py"]:::framework
            V_tests["tests.py"]:::framework
            V_migrations["migrations/"]:::framework
        end
    end

    %% Persistence and Media
    DB["SQLite DB<br/>db.sqlite3"]:::database
    Media["Media Store<br/>media/photos/"]:::media

    %% Development Tools
    Manage["manage.py"]:::tool
    Venv["venv/"]:::tool
    Req["requirements.txt"]:::tool

    %% Flow of Requests
    Client --> ASGI
    Client --> WSGI
    ASGI --> URLRouter
    WSGI --> URLRouter
    URLRouter --> A_urls
    URLRouter --> M_urls
    URLRouter --> S_urls
    URLRouter --> V_urls

    %% Internal request handling
    A_urls --> A_views
    M_urls --> M_views
    S_urls --> S_views
    V_urls --> V_views

    A_views --> A_serializers
    M_views --> M_serializers
    S_views --> S_serializers
    V_views --> V_serializers

    A_serializers --> A_models
    M_serializers --> M_models
    S_serializers --> S_models
    V_serializers --> V_models

    A_models --> DB
    M_models --> DB
    S_models --> DB
    V_models --> DB

    %% Media upload
    A_models -- uploads --> Media
    M_models -- uploads --> Media
    S_models -- uploads --> Media
    V_models -- uploads --> Media

    %% Core Settings linkage
    URLRouter --> Settings
    ASGI --> Settings
    WSGI --> Settings

    %% Development Tools usage
    Manage --> Settings
    Manage --> DB
    Manage --> Media
    Manage --> A_migrations
    Manage --> M_migrations
    Manage --> S_migrations
    Manage --> V_migrations

    %% Click Events
    click ASGI "https://github.com/archimedesaj/cms-api/blob/main/cmsapi/asgi.py"
    click WSGI "https://github.com/archimedesaj/cms-api/blob/main/cmsapi/wsgi.py"
    click URLRouter "https://github.com/archimedesaj/cms-api/blob/main/cmsapi/urls.py"
    click Settings "https://github.com/archimedesaj/cms-api/blob/main/cmsapi/settings.py"
    click A_models "https://github.com/archimedesaj/cms-api/blob/main/accounts/models.py"
    click A_serializers "https://github.com/archimedesaj/cms-api/blob/main/accounts/serializers.py"
    click A_views "https://github.com/archimedesaj/cms-api/blob/main/accounts/views.py"
    click A_urls "https://github.com/archimedesaj/cms-api/blob/main/accounts/urls.py"
    click A_admin "https://github.com/archimedesaj/cms-api/blob/main/accounts/admin.py"
    click A_tests "https://github.com/archimedesaj/cms-api/blob/main/accounts/tests.py"
    click A_migrations "https://github.com/archimedesaj/cms-api/tree/main/accounts/migrations/"
    click M_models "https://github.com/archimedesaj/cms-api/blob/main/member/models.py"
    click M_serializers "https://github.com/archimedesaj/cms-api/blob/main/member/serializers.py"
    click M_views "https://github.com/archimedesaj/cms-api/blob/main/member/views.py"
    click M_urls "https://github.com/archimedesaj/cms-api/blob/main/member/urls.py"
    click M_admin "https://github.com/archimedesaj/cms-api/blob/main/member/admin.py"
    click M_tests "https://github.com/archimedesaj/cms-api/blob/main/member/tests.py"
    click M_migrations "https://github.com/archimedesaj/cms-api/tree/main/member/migrations/"
    click S_models "https://github.com/archimedesaj/cms-api/blob/main/sundayschool/models.py"
    click S_serializers "https://github.com/archimedesaj/cms-api/blob/main/sundayschool/serializers.py"
    click S_views "https://github.com/archimedesaj/cms-api/blob/main/sundayschool/views.py"
    click S_urls "https://github.com/archimedesaj/cms-api/blob/main/sundayschool/urls.py"
    click S_admin "https://github.com/archimedesaj/cms-api/blob/main/sundayschool/admin.py"
    click S_tests "https://github.com/archimedesaj/cms-api/blob/main/sundayschool/tests.py"
    click S_migrations "https://github.com/archimedesaj/cms-api/tree/main/sundayschool/migrations/"
    click V_models "https://github.com/archimedesaj/cms-api/blob/main/visitor/models.py"
    click V_serializers "https://github.com/archimedesaj/cms-api/blob/main/visitor/serializers.py"
    click V_views "https://github.com/archimedesaj/cms-api/blob/main/visitor/views.py"
    click V_urls "https://github.com/archimedesaj/cms-api/blob/main/visitor/urls.py"
    click V_admin "https://github.com/archimedesaj/cms-api/blob/main/visitor/admin.py"
    click V_tests "https://github.com/archimedesaj/cms-api/blob/main/visitor/tests.py"
    click V_migrations "https://github.com/archimedesaj/cms-api/tree/main/visitor/migrations/"
    click DB "https://github.com/archimedesaj/cms-api/blob/main/db.sqlite3"
    click Media "https://github.com/archimedesaj/cms-api/tree/main/media/photos/"
    click Manage "https://github.com/archimedesaj/cms-api/blob/main/manage.py"
    click Venv "https://github.com/archimedesaj/cms-api/tree/main/venv/"
    click Req "https://github.com/archimedesaj/cms-api/blob/main/requirements.txt"

    %% Styles
    classDef client fill:#dddddd,stroke:#333,stroke-width:1px
    classDef framework fill:#a2d2ff,stroke:#034078,stroke-width:1px
    classDef database fill:#c2f784,stroke:#2b9348,stroke-width:1px
    classDef media fill:#ffe066,stroke:#bb3e03,stroke-width:1px
    classDef tool fill:#e0e0e0,stroke:#666,stroke-width:1px
```
