How rangonroyutsab/todoapi works
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 Task API views · frontend/views.py Frontend form flow · services.py Task services · settings.py Settings & root routes
Components 18
Django project
- Django entry points · Development and deployment entry points.
manage.py - Settings & root routes · Centralizes routing, auth, permissions, throttling, and JWT settings.
todoapi/settings.py
Versioned REST API
- /api/v1 API boundary
todoapi/urls.py - Task API views · Authenticated task CRUD and generation endpoints.
tasks/views.py - User API views · Registration and JWT login endpoints.
users/views.py - Task serializers
tasks/serializers.py - User serializers
users/serializers.py - Uniform API responses
todoapi/utils.py
Server-rendered UI
- Frontend form flow · Registration, login, and task-management HTTP flow.
frontend/views.py - Templates & static UI · Includes browser-side AI generation interaction.
frontend/templates/base.html
Task domain
- Task services · Coordinates task operations and AI generation.
tasks/services.py - Task query filters · Status filtering, sorting, and pagination behavior.
tasks/filters.py - Task model & migrations · Central persisted task resource.
tasks/models.py - User model
users/models.py - Gemini client · Isolates Google Gemini calls and failure handling.
tasks/clients.py
Runtime services
- PostgreSQL · Production and container persistence.
- Docker Compose runtime · Runs Django with PostgreSQL and environment configuration.
docker-compose.yml - Google Gemini
Connections 22
- 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