# udayige-amaha/todo architecture

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

- Interactive diagram: https://gitdiagram.com/udayige-amaha/todo
- Repository: https://github.com/udayige-amaha/todo

## Overview

#### Purpose and entry points
This is a Ruby on Rails API-oriented task service. The primary HTTP entry point is Rack/Rails via `config.ru`, with routing in `config/routes.rb`. The exposed versioned API is implemented by `app/controllers/api/v1/tasks_controller.rb`.

#### HTTP API layer
`Api::V1::TasksController` handles task-facing requests and inherits shared Rails controller behavior from `app/controllers/application_controller.rb`. Cross-origin behavior is configured at the application boundary in `config/initializers/cors.rb`, indicating the API may be consumed by a separate client origin.

#### Domain and persistence
The central domain entity is `Task` in `app/models/task.rb`, backed by the database schema in `db/schema.rb`. Its initial relational structure is established by `db/migrate/20260406050340_create_tasks.rb`; fixture data exists in `test/fixtures/tasks.yml`. Controllers should treat the model/database boundary as the source of task lifecycle state and validation behavior.

#### Rails application runtime
Rails boot and environment composition flow through `config/boot.rb`, `config/application.rb`, and `config/environment.rb`. Environment-specific runtime behavior is separated under `config/environments/production.rb` and peers. Puma is the web server (`config/puma.rb`), while `bin/rails` and `bin/dev` are local operational entry points.

#### Background work, cache, and realtime-capable infrastructure
The repository includes Rails-managed queue, cache, and Action Cable database schemas: `db/queue_schema.rb`, `db/cache_schema.rb`, and `db/cable_schema.rb`. Queue configuration and recurring-job scheduling are defined in `config/queue.yml` and `config/recurring.yml`; jobs inherit from `app/jobs/application_job.rb`. No task-specific job implementation is currently present, so these are platform capabilities rather than part of the visible task request path.

#### Deployment and container boundary
The application is containerized by `Dockerfile` and starts through `bin/docker-entrypoint`. Kamal deployment configuration is in `config/deploy.yml`, with lifecycle hooks in `.kamal/hooks`. Production therefore crosses from Kamal-managed infrastructure into a containerized Rails/Puma process, with credentials supplied through Rails encrypted credentials (`config/credentials.yml.enc`) and deployment secrets support under `.kamal/secrets`.

#### Data/control flow
A typical request flows: client → Rack (`config.ru`) → Rails routes (`config/routes.rb`) → versioned tasks controller (`app/controllers/api/v1/tasks_controller.rb`) → `Task` Active Record model (`app/models/task.rb`) → configured database (`config/database.yml`). Responses return through the controller; CORS policy is applied at the middleware/application boundary. Persistence also supports separate database-backed queue, cache, and cable concerns rather than requiring external Redis-like services in the checked-in structure.

Main entry points: [`config.ru`](https://github.com/udayige-amaha/todo/blob/main/config.ru) (Rack entry), [`config/database.yml`](https://github.com/udayige-amaha/todo/blob/main/config/database.yml) (Application database), [`app/controllers/api/v1/tasks_controller.rb`](https://github.com/udayige-amaha/todo/blob/main/app/controllers/api/v1/tasks_controller.rb) (Tasks controller), [`config/routes.rb`](https://github.com/udayige-amaha/todo/blob/main/config/routes.rb) (API routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_client(("API client<br/>external client"))
  node_rack["Rack entry<br/>[config.ru]"]
  node_routes["API routes<br/>Rails routes<br/>[routes.rb]"]
  node_tasks_controller["Tasks controller<br/>API v1 controller"]
  node_application_controller["Application controller<br/>base controller"]
  node_cors["CORS policy<br/>middleware config<br/>[cors.rb]"]
end

subgraph group_runtime["Rails Runtime"]
  node_rails_boot["Rails boot<br/>boot sequence<br/>[boot.rb]"]
  node_rails_application["Rails application<br/>application config<br/>[application.rb]"]
  node_environment["Runtime environment<br/>environment config<br/>[environment.rb]"]
  node_puma["Puma server<br/>web server<br/>[puma.rb]"]
end

subgraph group_data["Task Data"]
  node_task["Task<br/>Active Record model<br/>[task.rb]"]
  node_database[("Application database<br/>[database.yml]")]
  node_task_schema["Tasks schema<br/>relational schema<br/>[schema.rb]"]
end

subgraph group_platform["Database-backed Platform"]
  node_job_base["Application job<br/>job base class<br/>[application_job.rb]"]
  node_queue["Job queue<br/>database queue<br/>[queue.yml]"]
  node_cache[("Cache store<br/>database cache<br/>[cache_schema.rb]")]
  node_cable[("Action Cable store<br/>database cable<br/>[cable_schema.rb]")]
end

subgraph group_deploy["Deployment"]
  node_kamal["Kamal deployment<br/>deployment config<br/>[deploy.yml]"]
  node_container["Rails container<br/>Docker image"]
end

node_client -->|"HTTP request"| node_rack
node_rack -->|"dispatches"| node_routes
node_routes -->|"routes task API"| node_tasks_controller
node_tasks_controller -.->|"inherits"| node_application_controller
node_tasks_controller -->|"reads and mutates"| node_task
node_task -->|"persists via Active Record"| node_database
node_task_schema -->|"defines task tables"| node_database
node_cors -.->|"applies cross-origin policy"| node_rack
node_rails_boot -->|"loads"| node_rails_application
node_rails_application -->|"composes"| node_environment
node_environment -.->|"initializes application"| node_rack
node_puma -->|"serves"| node_rack
node_job_base -.->|"enqueues work"| node_queue
node_queue -.->|"uses queue tables"| node_database
node_cache -.->|"uses cache tables"| node_database
node_cable -.->|"uses cable tables"| node_database
node_kamal -->|"deploys"| node_container
node_container -->|"runs"| node_puma

click node_rack "https://github.com/udayige-amaha/todo/blob/main/config.ru"
click node_routes "https://github.com/udayige-amaha/todo/blob/main/config/routes.rb"
click node_tasks_controller "https://github.com/udayige-amaha/todo/blob/main/app/controllers/api/v1/tasks_controller.rb"
click node_application_controller "https://github.com/udayige-amaha/todo/blob/main/app/controllers/application_controller.rb"
click node_cors "https://github.com/udayige-amaha/todo/blob/main/config/initializers/cors.rb"
click node_rails_boot "https://github.com/udayige-amaha/todo/blob/main/config/boot.rb"
click node_rails_application "https://github.com/udayige-amaha/todo/blob/main/config/application.rb"
click node_environment "https://github.com/udayige-amaha/todo/blob/main/config/environment.rb"
click node_puma "https://github.com/udayige-amaha/todo/blob/main/config/puma.rb"
click node_task "https://github.com/udayige-amaha/todo/blob/main/app/models/task.rb"
click node_database "https://github.com/udayige-amaha/todo/blob/main/config/database.yml"
click node_task_schema "https://github.com/udayige-amaha/todo/blob/main/db/schema.rb"
click node_job_base "https://github.com/udayige-amaha/todo/blob/main/app/jobs/application_job.rb"
click node_queue "https://github.com/udayige-amaha/todo/blob/main/config/queue.yml"
click node_cache "https://github.com/udayige-amaha/todo/blob/main/db/cache_schema.rb"
click node_cable "https://github.com/udayige-amaha/todo/blob/main/db/cable_schema.rb"
click node_kamal "https://github.com/udayige-amaha/todo/blob/main/config/deploy.yml"
click node_container "https://github.com/udayige-amaha/todo/blob/main/Dockerfile"

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_client,node_rack,node_routes,node_tasks_controller,node_application_controller,node_cors toneBlue
class node_rails_boot,node_rails_application,node_environment,node_puma toneAmber
class node_task,node_database,node_task_schema toneMint
class node_job_base,node_queue,node_cache,node_cable toneRose
class node_kamal,node_container toneIndigo
```

## Components

### HTTP API

- **API client**: external client
- [Rack entry](https://github.com/udayige-amaha/todo/blob/main/config.ru): Rack · `config.ru`
- [API routes](https://github.com/udayige-amaha/todo/blob/main/config/routes.rb): Rails routes · `config/routes.rb`
- [Tasks controller](https://github.com/udayige-amaha/todo/blob/main/app/controllers/api/v1/tasks_controller.rb): API v1 controller · `app/controllers/api/v1/tasks_controller.rb`
- [Application controller](https://github.com/udayige-amaha/todo/blob/main/app/controllers/application_controller.rb): base controller · Provides shared Rails controller behavior. · `app/controllers/application_controller.rb`
- [CORS policy](https://github.com/udayige-amaha/todo/blob/main/config/initializers/cors.rb): middleware config · `config/initializers/cors.rb`

### Rails Runtime

- [Rails boot](https://github.com/udayige-amaha/todo/blob/main/config/boot.rb): boot sequence · Composes boot, application, and environment configuration. · `config/boot.rb`
- [Rails application](https://github.com/udayige-amaha/todo/blob/main/config/application.rb): application config · `config/application.rb`
- [Runtime environment](https://github.com/udayige-amaha/todo/blob/main/config/environment.rb): environment config · `config/environment.rb`
- [Puma server](https://github.com/udayige-amaha/todo/blob/main/config/puma.rb): web server · `config/puma.rb`

### Task Data

- [Task](https://github.com/udayige-amaha/todo/blob/main/app/models/task.rb): Active Record model · Owns task lifecycle state and validation behavior. · `app/models/task.rb`
- [Application database](https://github.com/udayige-amaha/todo/blob/main/config/database.yml): database · `config/database.yml`
- [Tasks schema](https://github.com/udayige-amaha/todo/blob/main/db/schema.rb): relational schema · Created initially by the tasks migration. · `db/schema.rb`

### Database-backed Platform

- [Application job](https://github.com/udayige-amaha/todo/blob/main/app/jobs/application_job.rb): job base class · `app/jobs/application_job.rb`
- [Job queue](https://github.com/udayige-amaha/todo/blob/main/config/queue.yml): database queue · Queue settings and recurring schedules support future background jobs. · `config/queue.yml`
- [Cache store](https://github.com/udayige-amaha/todo/blob/main/db/cache_schema.rb): database cache · `db/cache_schema.rb`
- [Action Cable store](https://github.com/udayige-amaha/todo/blob/main/db/cable_schema.rb): database cable · `db/cable_schema.rb`

### Deployment

- [Kamal deployment](https://github.com/udayige-amaha/todo/blob/main/config/deploy.yml): deployment config · `config/deploy.yml`
- [Rails container](https://github.com/udayige-amaha/todo/blob/main/Dockerfile): Docker image · Starts the Rails/Puma process through the Docker entrypoint. · `Dockerfile`

## Connections

- API client → Rack entry: HTTP request
- Rack entry → API routes: dispatches
- API routes → Tasks controller: routes task API
- Tasks controller → Application controller: inherits
- Tasks controller → Task: reads and mutates
- Task → Application database: persists via Active Record
- Tasks schema → Application database: defines task tables
- CORS policy → Rack entry: applies cross-origin policy
- Rails boot → Rails application: loads
- Rails application → Runtime environment: composes
- Runtime environment → Rack entry: initializes application
- Puma server → Rack entry: serves
- Application job → Job queue: enqueues work
- Job queue → Application database: uses queue tables
- Cache store → Application database: uses cache tables
- Action Cable store → Application database: uses cable tables
- Kamal deployment → Rails container: deploys
- Rails container → Puma server: runs
