# rekanone/api-work architecture

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

- Interactive diagram: https://gitdiagram.com/rekanone/api-work
- Repository: https://github.com/rekanone/api-work

## Overview

Api-work is a small AdonisJS API for user registration/login and authenticated todo retrieval. Requests enter through the route definitions; registration validates and creates users, login issues an auth token, and the protected todo endpoint queries records for the authenticated user. Models and database configuration provide the persistence layer. The README documents no further product capabilities, and the available excerpts do not show database wiring or application boot internals.

Main entry points: [`start/routes.ts`](https://github.com/rekanone/api-work/blob/master/start/routes.ts) (Route dispatch), [`config/database.ts`](https://github.com/rekanone/api-work/blob/master/config/database.ts) (Database config), [`app/Controllers/Http/UsersController.ts`](https://github.com/rekanone/api-work/blob/master/app/Controllers/Http/UsersController.ts) (User endpoints), [`env.ts`](https://github.com/rekanone/api-work/blob/master/env.ts) (Environment settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_routes["Route dispatch<br/>[routes.ts]"]
  node_error_handler["HTTP error handling<br/>[Handler.ts]"]
end

subgraph group_identity["Identity"]
  node_users["User endpoints<br/>[UsersController.ts]"]
  node_register["Registration validation"]
  node_auth["Auth middleware<br/>[Auth.ts]"]
  node_silent_auth["Silent auth<br/>[SilentAuth.ts]"]
  node_hash_config["Password hashing<br/>[hash.ts]"]
end

subgraph group_todos["Todo access"]
  node_todos["Todo endpoint<br/>[TodosController.ts]"]
end

subgraph group_persistence["Persistence and config"]
  node_user_model["User model<br/>[User.ts]"]
  node_todo_model["Todo model<br/>[Todo.ts]"]
  node_database_config["Database config<br/>[database.ts]"]
  node_user_store[("Users table")]
  node_token_store[("API tokens")]
  node_todo_store[("Todos table")]
  node_drive_config["File storage config<br/>[drive.ts]"]
  node_env["Environment settings<br/>[env.ts]"]
end

node_client(("API client"))

node_client -->|"sends request"| node_routes
node_routes -->|"routes login/register"| node_users
node_routes -->|"protects todos"| node_auth
node_routes -->|"routes todo list"| node_todos
node_users -->|"validates payload"| node_register
node_users -->|"finds and creates users"| node_user_model
node_todos -->|"queries user todos"| node_todo_model
node_database_config -.-> node_user_store
node_database_config -.-> node_todo_store
node_database_config -.-> node_token_store
node_user_model -.-> node_user_store
node_todo_model -.-> node_todo_store
node_token_store -.-> node_auth
node_env -->|"sets disk choice"| node_drive_config
node_env -->|"sets hash driver"| node_hash_config

click node_routes "https://github.com/rekanone/api-work/blob/master/start/routes.ts"
click node_users "https://github.com/rekanone/api-work/blob/master/app/Controllers/Http/UsersController.ts"
click node_register "https://github.com/rekanone/api-work/blob/master/app/Validators/RegisterValidator.ts"
click node_auth "https://github.com/rekanone/api-work/blob/master/app/Middleware/Auth.ts"
click node_silent_auth "https://github.com/rekanone/api-work/blob/master/app/Middleware/SilentAuth.ts"
click node_todos "https://github.com/rekanone/api-work/blob/master/app/Controllers/Http/TodosController.ts"
click node_user_model "https://github.com/rekanone/api-work/blob/master/app/Models/User.ts"
click node_todo_model "https://github.com/rekanone/api-work/blob/master/app/Models/Todo.ts"
click node_database_config "https://github.com/rekanone/api-work/blob/master/config/database.ts"
click node_user_store "https://github.com/rekanone/api-work/blob/master/database/migrations/1653507407622_users.ts"
click node_token_store "https://github.com/rekanone/api-work/blob/master/database/migrations/1653507407633_api_tokens.ts"
click node_todo_store "https://github.com/rekanone/api-work/blob/master/database/migrations/1653508221433_todos.ts"
click node_hash_config "https://github.com/rekanone/api-work/blob/master/config/hash.ts"
click node_drive_config "https://github.com/rekanone/api-work/blob/master/config/drive.ts"
click node_env "https://github.com/rekanone/api-work/blob/master/env.ts"
click node_error_handler "https://github.com/rekanone/api-work/blob/master/app/Exceptions/Handler.ts"

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_routes,node_error_handler,node_client toneBlue
class node_users,node_register,node_auth,node_silent_auth,node_hash_config toneAmber
class node_todos toneMint
class node_user_model,node_todo_model,node_database_config,node_user_store,node_token_store,node_todo_store,node_drive_config,node_env toneRose
```

## Components

### HTTP API

- [Route dispatch](https://github.com/rekanone/api-work/blob/master/start/routes.ts): `start/routes.ts`
- [HTTP error handling](https://github.com/rekanone/api-work/blob/master/app/Exceptions/Handler.ts): `app/Exceptions/Handler.ts`

### Identity

- [User endpoints](https://github.com/rekanone/api-work/blob/master/app/Controllers/Http/UsersController.ts): `app/Controllers/Http/UsersController.ts`
- [Registration validation](https://github.com/rekanone/api-work/blob/master/app/Validators/RegisterValidator.ts): `app/Validators/RegisterValidator.ts`
- [Auth middleware](https://github.com/rekanone/api-work/blob/master/app/Middleware/Auth.ts): `app/Middleware/Auth.ts`
- [Silent auth](https://github.com/rekanone/api-work/blob/master/app/Middleware/SilentAuth.ts): `app/Middleware/SilentAuth.ts`
- [Password hashing](https://github.com/rekanone/api-work/blob/master/config/hash.ts): `config/hash.ts`

### Todo access

- [Todo endpoint](https://github.com/rekanone/api-work/blob/master/app/Controllers/Http/TodosController.ts): `app/Controllers/Http/TodosController.ts`

### Persistence and config

- [User model](https://github.com/rekanone/api-work/blob/master/app/Models/User.ts): `app/Models/User.ts`
- [Todo model](https://github.com/rekanone/api-work/blob/master/app/Models/Todo.ts): `app/Models/Todo.ts`
- [Database config](https://github.com/rekanone/api-work/blob/master/config/database.ts): `config/database.ts`
- [Users table](https://github.com/rekanone/api-work/blob/master/database/migrations/1653507407622_users.ts): `database/migrations/1653507407622_users.ts`
- [API tokens](https://github.com/rekanone/api-work/blob/master/database/migrations/1653507407633_api_tokens.ts): `database/migrations/1653507407633_api_tokens.ts`
- [Todos table](https://github.com/rekanone/api-work/blob/master/database/migrations/1653508221433_todos.ts): `database/migrations/1653508221433_todos.ts`
- [File storage config](https://github.com/rekanone/api-work/blob/master/config/drive.ts): `config/drive.ts`
- [Environment settings](https://github.com/rekanone/api-work/blob/master/env.ts): `env.ts`

### Other components

- **API client**

## Connections

- API client → Route dispatch: sends request (evidence: `start/routes.ts`)
- Route dispatch → User endpoints: routes login/register (evidence: `start/routes.ts`)
- Route dispatch → Auth middleware: protects todos (evidence: `start/routes.ts`)
- Route dispatch → Todo endpoint: routes todo list (evidence: `start/routes.ts`)
- User endpoints → Registration validation: validates payload (evidence: `app/Controllers/Http/UsersController.ts`)
- User endpoints → User model: finds and creates users (evidence: `app/Controllers/Http/UsersController.ts`)
- Todo endpoint → Todo model: queries user todos (evidence: `app/Controllers/Http/TodosController.ts`)
- Database config → Users table
- Database config → Todos table
- Database config → API tokens
- User model → Users table
- Todo model → Todos table
- API tokens → Auth middleware
- Environment settings → File storage config: sets disk choice (evidence: `config/drive.ts`)
- Environment settings → Password hashing: sets hash driver (evidence: `config/hash.ts`)
