# rangonroyutsab/todoapi architecture

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

- Interactive diagram: https://gitdiagram.com/rangonroyutsab/todoapi
- Repository: https://github.com/rangonroyutsab/todoapi

## Overview

#### Purpose and Entry Points
Django full-stack to-do system: server-rendered browser UI plus versioned DRF JSON API. Process entry points are `manage.py`, deployment adapters `todoapi/wsgi.py` and `todoapi/asgi.py`; project configuration and root routing live in `todoapi/settings.py` and `todoapi/urls.py`.

#### Domain and Persistence
Tasks and users are separate Django apps. The task model is the central persisted resource, with migrations defining its database evolution: `tasks/models.py`, `tasks/migrations/0001_initial.py`, `users/models.py`. PostgreSQL is the production/container database, configured through environment variables and Compose.

#### API Boundary
The REST API is exposed under `/api/v1/`, with app-level route dispatch in `tasks/urls.py` and `users/urls.py`, implemented by DRF views in `tasks/views.py` and `users/views.py`. Serializers form the API validation/representation boundary: `tasks/serializers.py`, `users/serializers.py`. Responses use a shared uniform success/error format, with common utility support in `todoapi/utils.py`.

#### Authentication and Ownership
User registration and JWT login are handled by the users API layer (`users/views.py`, `users/serializers.py`). Protected task operations are scoped to the authenticated user, separating public registration/login from authenticated CRUD and AI generation. Framework authentication, permissions, throttling, and JWT settings are centralized in `todoapi/settings.py`.

#### Task Query and CRUD Flow
Requests reach task views, validate through serializers, then read/write the task model. List behavior includes status filtering, sorting, pagination, and response metadata; filtering logic is isolated in `tasks/filters.py`. Core task endpoints and request orchestration reside in `tasks/views.py`, with business-level operations in `tasks/services.py`.

#### AI Description Generation
The task-specific generation endpoint is an authenticated, separately throttled external-service boundary. Task views delegate generation/business behavior to `tasks/services.py`; the Gemini-facing client is isolated in `tasks/clients.py`, and service/API failure semantics are represented by `tasks/exceptions.py`. The browser UI invokes this capability from `frontend/static/js/ai_generator.js`.

#### Server-Rendered Frontend
A distinct Django-template frontend provides registration, login, and task management pages. HTTP form flow is owned by `frontend/views.py`, `frontend/urls.py`, and `frontend/forms.py`; presentation is in `frontend/templates/` and static assets. It is a first-party UI over the same user/task domain, rather than a separate JavaScript application.

#### Runtime and Infrastructure
The service runs in Docker via `Dockerfile` and `docker-compose.yml`, with PostgreSQL and Django environment configuration sourced from `.env`/`.env.example`. External dependencies include PostgreSQL, JWT authentication infrastructure, and Google Gemini via `GEMINI_API_KEY`; API consumers can use the supplied collection at `postman/TodoAPI_Postman_Collection.json`.

Main entry points: [`tasks/views.py`](https://github.com/rangonroyutsab/todoapi/blob/master/tasks/views.py) (Task API views), [`frontend/views.py`](https://github.com/rangonroyutsab/todoapi/blob/master/frontend/views.py) (Frontend form flow), [`tasks/services.py`](https://github.com/rangonroyutsab/todoapi/blob/master/tasks/services.py) (Task services), [`todoapi/settings.py`](https://github.com/rangonroyutsab/todoapi/blob/master/todoapi/settings.py) (Settings & root routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_django["Django project"]
  node_entry{{"Django entry points<br/>process entry<br/>[manage.py]"}}
  node_project_config["Settings &amp; root routes<br/>Django configuration<br/>[settings.py]"]
end

subgraph group_api["Versioned REST API"]
  node_api_root["/api/v1 API boundary<br/>DRF routing<br/>[urls.py]"]
  node_task_api["Task API views<br/>DRF views<br/>[views.py]"]
  node_user_api["User API views<br/>DRF views<br/>[views.py]"]
  node_task_serializers["Task serializers<br/>validation boundary<br/>[serializers.py]"]
  node_user_serializers["User serializers<br/>validation boundary<br/>[serializers.py]"]
  node_response_format["Uniform API responses<br/>response utility<br/>[utils.py]"]
end

subgraph group_frontend["Server-rendered UI"]
  node_frontend_routes["Frontend form flow<br/>Django views and routes<br/>[views.py]"]
  node_templates["Templates &amp; static UI<br/>presentation<br/>[base.html]"]
end

subgraph group_domain["Task domain"]
  node_task_domain["Task services<br/>business services<br/>[services.py]"]
  node_task_filters["Task query filters<br/>query logic<br/>[filters.py]"]
  node_task_model[("Task model &amp; migrations<br/>Django model<br/>[models.py]")]
  node_user_model[("User model<br/>Django model<br/>[models.py]")]
  node_gemini_client["Gemini client<br/>external client<br/>[clients.py]"]
end

subgraph group_runtime["Runtime services"]
  node_postgres[("PostgreSQL<br/>database")]
  node_docker{{"Docker Compose runtime<br/>container deployment<br/>[docker-compose.yml]"}}
  node_gemini(("Google Gemini<br/>external AI service"))
end

node_entry -->|"loads"| node_project_config
node_project_config -->|"mounts"| node_api_root
node_project_config -->|"routes browser UI"| node_frontend_routes
node_api_root -->|"dispatches task routes"| node_task_api
node_api_root -->|"dispatches user routes"| node_user_api
node_task_api -->|"validates requests"| node_task_serializers
node_user_api -->|"validates auth data"| node_user_serializers
node_task_api -->|"delegates operations"| node_task_domain
node_task_api -->|"applies list behavior"| node_task_filters
node_task_api -->|"formats responses"| node_response_format
node_user_api -->|"registers users"| node_user_model
node_frontend_routes -->|"renders"| node_templates
node_frontend_routes -->|"uses task domain"| node_task_domain
node_frontend_routes -->|"uses user domain"| node_user_model
node_task_domain -->|"reads and writes"| node_task_model
node_task_filters -->|"queries"| node_task_model
node_task_domain -->|"generates descriptions"| node_gemini_client
node_gemini_client -->|"calls with API key"| node_gemini
node_task_model -->|"persists"| node_postgres
node_user_model -->|"persists"| node_postgres
node_docker -->|"runs Django"| node_entry
node_docker -->|"runs database"| node_postgres

click node_entry "https://github.com/rangonroyutsab/todoapi/blob/master/manage.py"
click node_project_config "https://github.com/rangonroyutsab/todoapi/blob/master/todoapi/settings.py"
click node_api_root "https://github.com/rangonroyutsab/todoapi/blob/master/todoapi/urls.py"
click node_task_api "https://github.com/rangonroyutsab/todoapi/blob/master/tasks/views.py"
click node_user_api "https://github.com/rangonroyutsab/todoapi/blob/master/users/views.py"
click node_task_serializers "https://github.com/rangonroyutsab/todoapi/blob/master/tasks/serializers.py"
click node_user_serializers "https://github.com/rangonroyutsab/todoapi/blob/master/users/serializers.py"
click node_response_format "https://github.com/rangonroyutsab/todoapi/blob/master/todoapi/utils.py"
click node_frontend_routes "https://github.com/rangonroyutsab/todoapi/blob/master/frontend/views.py"
click node_templates "https://github.com/rangonroyutsab/todoapi/blob/master/frontend/templates/base.html"
click node_task_domain "https://github.com/rangonroyutsab/todoapi/blob/master/tasks/services.py"
click node_task_filters "https://github.com/rangonroyutsab/todoapi/blob/master/tasks/filters.py"
click node_task_model "https://github.com/rangonroyutsab/todoapi/blob/master/tasks/models.py"
click node_user_model "https://github.com/rangonroyutsab/todoapi/blob/master/users/models.py"
click node_gemini_client "https://github.com/rangonroyutsab/todoapi/blob/master/tasks/clients.py"
click node_docker "https://github.com/rangonroyutsab/todoapi/blob/master/docker-compose.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_project_config toneBlue
class node_api_root,node_task_api,node_user_api,node_task_serializers,node_user_serializers,node_response_format toneAmber
class node_frontend_routes,node_templates toneMint
class node_task_domain,node_task_filters,node_task_model,node_user_model,node_gemini_client toneRose
class node_postgres,node_docker,node_gemini toneIndigo
```

## Components

### Django project

- [Django entry points](https://github.com/rangonroyutsab/todoapi/blob/master/manage.py): process entry · Development and deployment entry points. · `manage.py`
- [Settings & root routes](https://github.com/rangonroyutsab/todoapi/blob/master/todoapi/settings.py): Django configuration · Centralizes routing, auth, permissions, throttling, and JWT settings. · `todoapi/settings.py`

### Versioned REST API

- [/api/v1 API boundary](https://github.com/rangonroyutsab/todoapi/blob/master/todoapi/urls.py): DRF routing · `todoapi/urls.py`
- [Task API views](https://github.com/rangonroyutsab/todoapi/blob/master/tasks/views.py): DRF views · Authenticated task CRUD and generation endpoints. · `tasks/views.py`
- [User API views](https://github.com/rangonroyutsab/todoapi/blob/master/users/views.py): DRF views · Registration and JWT login endpoints. · `users/views.py`
- [Task serializers](https://github.com/rangonroyutsab/todoapi/blob/master/tasks/serializers.py): validation boundary · `tasks/serializers.py`
- [User serializers](https://github.com/rangonroyutsab/todoapi/blob/master/users/serializers.py): validation boundary · `users/serializers.py`
- [Uniform API responses](https://github.com/rangonroyutsab/todoapi/blob/master/todoapi/utils.py): response utility · `todoapi/utils.py`

### Server-rendered UI

- [Frontend form flow](https://github.com/rangonroyutsab/todoapi/blob/master/frontend/views.py): Django views and routes · Registration, login, and task-management HTTP flow. · `frontend/views.py`
- [Templates & static UI](https://github.com/rangonroyutsab/todoapi/blob/master/frontend/templates/base.html): presentation · Includes browser-side AI generation interaction. · `frontend/templates/base.html`

### Task domain

- [Task services](https://github.com/rangonroyutsab/todoapi/blob/master/tasks/services.py): business services · Coordinates task operations and AI generation. · `tasks/services.py`
- [Task query filters](https://github.com/rangonroyutsab/todoapi/blob/master/tasks/filters.py): query logic · Status filtering, sorting, and pagination behavior. · `tasks/filters.py`
- [Task model & migrations](https://github.com/rangonroyutsab/todoapi/blob/master/tasks/models.py): Django model · Central persisted task resource. · `tasks/models.py`
- [User model](https://github.com/rangonroyutsab/todoapi/blob/master/users/models.py): Django model · `users/models.py`
- [Gemini client](https://github.com/rangonroyutsab/todoapi/blob/master/tasks/clients.py): external client · Isolates Google Gemini calls and failure handling. · `tasks/clients.py`

### Runtime services

- **PostgreSQL**: database · Production and container persistence.
- [Docker Compose runtime](https://github.com/rangonroyutsab/todoapi/blob/master/docker-compose.yml): container deployment · Runs Django with PostgreSQL and environment configuration. · `docker-compose.yml`
- **Google Gemini**: external AI service

## Connections

- Django entry points → Settings & root routes: loads
- Settings & root routes → /api/v1 API boundary: mounts
- Settings & root routes → Frontend form flow: routes browser UI
- /api/v1 API boundary → Task API views: dispatches task routes
- /api/v1 API boundary → User API views: dispatches user routes
- Task API views → Task serializers: validates requests
- User API views → User serializers: validates auth data
- Task API views → Task services: delegates operations
- Task API views → Task query filters: applies list behavior
- Task API views → Uniform API responses: formats responses
- User API views → User model: registers users
- Frontend form flow → Templates & static UI: renders
- Frontend form flow → Task services: uses task domain
- Frontend form flow → User model: uses user domain
- Task services → Task model & migrations: reads and writes
- Task query filters → Task model & migrations: queries
- Task services → Gemini client: generates descriptions
- Gemini client → Google Gemini: calls with API key
- Task model & migrations → PostgreSQL: persists
- User model → PostgreSQL: persists
- Docker Compose runtime → Django entry points: runs Django
- Docker Compose runtime → PostgreSQL: runs database
