# backmeupplz/todorant-backend architecture

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

- Interactive diagram: https://gitdiagram.com/backmeupplz/todorant-backend
- Repository: https://github.com/backmeupplz/todorant-backend

## Overview

Todorant is a task-management backend exposing HTTP APIs, authenticated user accounts, real-time client synchronization, a Telegram bot, and Google Calendar integration. The main workflow is a client request authenticated as a user, task operations against MongoDB, and synchronization notifications or client sync; Telegram offers another task-entry surface. The sampled source confirms task ordering, persistence, and socket sync. Several controller capabilities are represented from their filenames and index references rather than inspected implementation, so their internal links are omitted.

Main entry points: [`src/sockets/index.ts`](https://github.com/backmeupplz/todorant-backend/blob/main/src/sockets/index.ts) (Socket Events), [`src/controllers/todo.ts`](https://github.com/backmeupplz/todorant-backend/blob/main/src/controllers/todo.ts) (Todo API), [`src/app.ts`](https://github.com/backmeupplz/todorant-backend/blob/main/src/app.ts) (HTTP Application), [`src/middlewares/authenticate.ts`](https://github.com/backmeupplz/todorant-backend/blob/main/src/middlewares/authenticate.ts) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["Backend Server<br/>[server.ts]"]
  node_koa["HTTP Application<br/>[app.ts]"]
  node_controllers["API Controllers"]
  node_todo_api["Todo API<br/>[todo.ts]"]
end

subgraph group_domain["Task Domain"]
  node_todo_model[("Todo Records<br/>[Todo.ts]")]
  node_tag_model[("Tags<br/>[tag.ts]")]
  node_hero_model[("Hero Points<br/>[hero.ts]")]
  node_ordering["Todo Ordering<br/>[fixOrder.ts]"]
end

subgraph group_realtime["Realtime Sync"]
  node_socket_api["Socket Events<br/>[index.ts]"]
  node_socket_auth["Socket Authorization"]
  node_socket_sync["Entity Sync<br/>[setupSync.ts]"]
  node_wmdb["Sync Conversion<br/>[wmdb.ts]"]
end

subgraph group_integrations["Integrations"]
  node_telegram["Telegram Bot<br/>[index.ts]"]
  node_telegram_todos["Bot Todo Commands<br/>[todo.ts]"]
  node_calendar["Calendar Integration<br/>[googleCalendar.ts]"]
end

subgraph group_identity["Identity"]
  node_auth["Authentication<br/>[authenticate.ts]"]
  node_login["Login API<br/>[login.ts]"]
  node_user_model[("User Accounts<br/>[User.ts]")]
end

node_client(("API Client"))
node_mongo[("MongoDB")]
node_google["Google Calendar"]
node_telegram_service["Telegram Platform"]

node_client -.->|"sends requests"| node_koa
node_server -->|"starts app"| node_koa
node_koa -->|"registers routes"| node_controllers
node_todo_api -->|"requires authentication"| node_auth
node_auth -->|"looks up user"| node_user_model
node_auth -->|"verifies identity"| node_user_model
node_login -->|"uses accounts"| node_user_model
node_todo_api -->|"operates on todos"| node_todo_model
node_todo_api -->|"adds tags"| node_tag_model
node_todo_api -->|"reorders todos"| node_ordering
node_ordering -->|"loads and saves"| node_todo_model
node_todo_api -->|"requests sync"| node_socket_api
node_server -->|"starts bot"| node_telegram
node_telegram -->|"routes commands"| node_telegram_todos
node_telegram_todos -->|"uses todo records"| node_todo_model
node_server -->|"loads sockets"| node_socket_api
node_socket_api -->|"sets authorization"| node_socket_auth
node_socket_api -->|"sets up sync"| node_socket_sync
node_socket_api -->|"syncs todos"| node_todo_model
node_socket_api -->|"syncs tags"| node_tag_model
node_socket_api -->|"syncs user data"| node_user_model
node_socket_api -->|"syncs hero data"| node_hero_model
node_socket_api -->|"converts sync data"| node_wmdb
node_socket_auth -->|"uses authentication"| node_auth
node_koa -->|"loads channel handler"| node_calendar
node_socket_api -->|"uses calendar API"| node_calendar
node_calendar -->|"reads and updates events"| node_google
node_telegram -.->|"connects bot"| node_telegram_service

click node_server "https://github.com/backmeupplz/todorant-backend/blob/main/src/server.ts"
click node_koa "https://github.com/backmeupplz/todorant-backend/blob/main/src/app.ts"
click node_controllers "https://github.com/backmeupplz/todorant-backend/tree/main/src/controllers"
click node_todo_api "https://github.com/backmeupplz/todorant-backend/blob/main/src/controllers/todo.ts"
click node_auth "https://github.com/backmeupplz/todorant-backend/blob/main/src/middlewares/authenticate.ts"
click node_login "https://github.com/backmeupplz/todorant-backend/blob/main/src/controllers/login.ts"
click node_user_model "https://github.com/backmeupplz/todorant-backend/blob/main/src/models/user/User.ts"
click node_todo_model "https://github.com/backmeupplz/todorant-backend/blob/main/src/models/todo/Todo.ts"
click node_tag_model "https://github.com/backmeupplz/todorant-backend/blob/main/src/models/tag.ts"
click node_hero_model "https://github.com/backmeupplz/todorant-backend/blob/main/src/models/hero.ts"
click node_ordering "https://github.com/backmeupplz/todorant-backend/blob/main/src/helpers/fixOrder.ts"
click node_socket_api "https://github.com/backmeupplz/todorant-backend/blob/main/src/sockets/index.ts"
click node_socket_auth "https://github.com/backmeupplz/todorant-backend/blob/main/src/sockets/setupAuthorization.ts"
click node_socket_sync "https://github.com/backmeupplz/todorant-backend/blob/main/src/sockets/setupSync.ts"
click node_wmdb "https://github.com/backmeupplz/todorant-backend/blob/main/src/helpers/wmdb.ts"
click node_telegram "https://github.com/backmeupplz/todorant-backend/blob/main/src/helpers/telegram/index.ts"
click node_telegram_todos "https://github.com/backmeupplz/todorant-backend/blob/main/src/helpers/telegram/commands/todo.ts"
click node_calendar "https://github.com/backmeupplz/todorant-backend/blob/main/src/helpers/googleCalendar.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_server,node_koa,node_controllers,node_todo_api,node_client toneBlue
class node_todo_model,node_tag_model,node_hero_model,node_ordering,node_mongo toneAmber
class node_socket_api,node_socket_auth,node_socket_sync,node_wmdb toneMint
class node_telegram,node_telegram_todos,node_calendar toneRose
class node_auth,node_login,node_user_model,node_google,node_telegram_service toneIndigo
```

## Components

### HTTP API

- [Backend Server](https://github.com/backmeupplz/todorant-backend/blob/main/src/server.ts): `src/server.ts`
- [HTTP Application](https://github.com/backmeupplz/todorant-backend/blob/main/src/app.ts): `src/app.ts`
- [API Controllers](https://github.com/backmeupplz/todorant-backend/tree/main/src/controllers): `src/controllers`
- [Todo API](https://github.com/backmeupplz/todorant-backend/blob/main/src/controllers/todo.ts): `src/controllers/todo.ts`

### Task Domain

- [Todo Records](https://github.com/backmeupplz/todorant-backend/blob/main/src/models/todo/Todo.ts): `src/models/todo/Todo.ts`
- [Tags](https://github.com/backmeupplz/todorant-backend/blob/main/src/models/tag.ts): `src/models/tag.ts`
- [Hero Points](https://github.com/backmeupplz/todorant-backend/blob/main/src/models/hero.ts): `src/models/hero.ts`
- [Todo Ordering](https://github.com/backmeupplz/todorant-backend/blob/main/src/helpers/fixOrder.ts): `src/helpers/fixOrder.ts`

### Realtime Sync

- [Socket Events](https://github.com/backmeupplz/todorant-backend/blob/main/src/sockets/index.ts): `src/sockets/index.ts`
- [Socket Authorization](https://github.com/backmeupplz/todorant-backend/blob/main/src/sockets/setupAuthorization.ts): `src/sockets/setupAuthorization.ts`
- [Entity Sync](https://github.com/backmeupplz/todorant-backend/blob/main/src/sockets/setupSync.ts): `src/sockets/setupSync.ts`
- [Sync Conversion](https://github.com/backmeupplz/todorant-backend/blob/main/src/helpers/wmdb.ts): `src/helpers/wmdb.ts`

### Integrations

- [Telegram Bot](https://github.com/backmeupplz/todorant-backend/blob/main/src/helpers/telegram/index.ts): `src/helpers/telegram/index.ts`
- [Bot Todo Commands](https://github.com/backmeupplz/todorant-backend/blob/main/src/helpers/telegram/commands/todo.ts): `src/helpers/telegram/commands/todo.ts`
- [Calendar Integration](https://github.com/backmeupplz/todorant-backend/blob/main/src/helpers/googleCalendar.ts): `src/helpers/googleCalendar.ts`

### Identity

- [Authentication](https://github.com/backmeupplz/todorant-backend/blob/main/src/middlewares/authenticate.ts): `src/middlewares/authenticate.ts`
- [Login API](https://github.com/backmeupplz/todorant-backend/blob/main/src/controllers/login.ts): `src/controllers/login.ts`
- [User Accounts](https://github.com/backmeupplz/todorant-backend/blob/main/src/models/user/User.ts): `src/models/user/User.ts`

### Other components

- **API Client**
- **MongoDB**
- **Google Calendar**
- **Telegram Platform**

## Connections

- API Client → HTTP Application: sends requests
- Backend Server → HTTP Application: starts app (evidence: `src/server.ts`)
- HTTP Application → API Controllers: registers routes (evidence: `src/app.ts`)
- Todo API → Authentication: requires authentication (evidence: `src/controllers/todo.ts`)
- Authentication → User Accounts: looks up user (evidence: `src/middlewares/authenticate.ts`)
- Authentication → User Accounts: verifies identity (evidence: `src/middlewares/authenticate.ts`)
- Login API → User Accounts: uses accounts (evidence: `src/controllers/login.ts`)
- Todo API → Todo Records: operates on todos (evidence: `src/controllers/todo.ts`)
- Todo API → Tags: adds tags (evidence: `src/controllers/todo.ts`)
- Todo API → Todo Ordering: reorders todos (evidence: `src/controllers/todo.ts`)
- Todo Ordering → Todo Records: loads and saves (evidence: `src/helpers/fixOrder.ts`)
- Todo API → Socket Events: requests sync (evidence: `src/controllers/todo.ts`)
- Backend Server → Telegram Bot: starts bot (evidence: `src/server.ts`)
- Telegram Bot → Bot Todo Commands: routes commands (evidence: `src/helpers/telegram/index.ts`)
- Bot Todo Commands → Todo Records: uses todo records (evidence: `src/helpers/telegram/commands/todo.ts`)
- Backend Server → Socket Events: loads sockets (evidence: `src/server.ts`)
- Socket Events → Socket Authorization: sets authorization (evidence: `src/sockets/index.ts`)
- Socket Events → Entity Sync: sets up sync (evidence: `src/sockets/index.ts`)
- Socket Events → Todo Records: syncs todos (evidence: `src/sockets/index.ts`)
- Socket Events → Tags: syncs tags (evidence: `src/sockets/index.ts`)
- Socket Events → User Accounts: syncs user data (evidence: `src/sockets/index.ts`)
- Socket Events → Hero Points: syncs hero data (evidence: `src/sockets/index.ts`)
- Socket Events → Sync Conversion: converts sync data (evidence: `src/sockets/index.ts`)
- Socket Authorization → Authentication: uses authentication (evidence: `src/sockets/setupAuthorization.ts`)
- HTTP Application → Calendar Integration: loads channel handler (evidence: `src/app.ts`)
- Socket Events → Calendar Integration: uses calendar API (evidence: `src/sockets/index.ts`)
- Calendar Integration → Google Calendar: reads and updates events (evidence: `src/helpers/googleCalendar.ts`)
- Telegram Bot → Telegram Platform: connects bot
