# damix00/taskbuddy-backend architecture

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

- Interactive diagram: https://gitdiagram.com/damix00/taskbuddy-backend
- Repository: https://github.com/damix00/taskbuddy-backend

## Overview

TaskBuddy is a backend for matching people who need task help with people who can provide it. Its main workflow accepts mobile-app requests, authenticates users, manages task posts and discovery, and supports task negotiation through chat and completion reviews. The graph also retains documented recommendations, moderation, location services, phone verification, and Firebase capabilities. Evidence is limited to the README and sampled source; unsampled feature connections are shown only where documentation supports them.

Main entry points: [`src/index.ts`](https://github.com/damix00/taskbuddy-backend/blob/main/src/index.ts) (HTTP server), [`src/routes/index.ts`](https://github.com/damix00/taskbuddy-backend/blob/main/src/routes/index.ts) (Route registry), [`src/routes/v1/posts`](https://github.com/damix00/taskbuddy-backend/tree/main/src/routes/v1/posts) (Task endpoints), [`src/routes/v1/channels`](https://github.com/damix00/taskbuddy-backend/tree/main/src/routes/v1/channels) (Chat endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Server runtime"]
  node_server["HTTP server<br/>[index.ts]"]
  node_routing["Route registry<br/>[index.ts]"]
  node_database[("PostgreSQL<br/>[connection.ts]")]
end

subgraph group_identity["Accounts and identity"]
  node_authorization["Request authorization<br/>[authorization.ts]"]
  node_jwt["JWT verification<br/>[jwt.ts]"]
  node_phone["Phone verification<br/>[phone.ts]"]
  node_users["User accounts<br/>[index.ts]"]
  node_profiles["User profiles<br/>[index.ts]"]
end

subgraph group_tasks["Tasks and discovery"]
  node_posts["Task posts<br/>[index.ts]"]
  node_post_routes["Task endpoints"]
  node_classification["Task classification<br/>[cohere.ts]"]
  node_moderation["Content moderation<br/>[text_check.ts]"]
  node_discovery["Search and recommendations"]
  node_sessions["Feed sessions"]
end

subgraph group_communication["Chat and reviews"]
  node_channels["Task channels<br/>[channels.ts]"]
  node_chat_routes["Chat endpoints"]
  node_socket["Realtime chat<br/>[socket_server.ts]"]
  node_reviews["Task reviews<br/>[wrapper.ts]"]
end

subgraph group_integrations["External services"]
  node_cohere{{"Cohere API"}}
  node_openai{{"OpenAI moderation API"}}
  node_osm{{"OpenStreetMap API"}}
  node_twilio{{"Twilio SMS"}}
  node_firebase["Firebase services"]
end

node_mobile(("Mobile app"))

node_mobile -->|"sends requests"| node_server
node_server -->|"registers routes"| node_routing
node_server -->|"connects"| node_database
node_server -->|"starts"| node_socket
node_routing -->|"routes tasks"| node_post_routes
node_routing -->|"routes chat"| node_chat_routes
node_authorization -->|"verifies tokens"| node_jwt
node_authorization -->|"loads user"| node_users
node_authorization -->|"loads profile"| node_profiles
node_post_routes -.->|"manages tasks"| node_posts
node_posts -.->|"persists tasks"| node_database
node_post_routes -.->|"classifies text"| node_classification
node_classification -->|"embeds text"| node_cohere
node_post_routes -.->|"checks content"| node_moderation
node_moderation -->|"moderates content"| node_openai
node_routing -->|"routes search"| node_discovery
node_discovery -.->|"personalizes feed"| node_sessions
node_discovery -->|"filters by location"| node_osm
node_chat_routes -->|"loads channel"| node_channels
node_chat_routes -->|"creates review"| node_reviews
node_chat_routes -->|"emits chat events"| node_socket
node_socket -->|"connects"| node_database
node_phone -->|"verifies numbers"| node_twilio
node_profiles -->|"uploads media"| node_firebase
node_server -->|"initializes"| node_firebase

click node_server "https://github.com/damix00/taskbuddy-backend/blob/main/src/index.ts"
click node_routing "https://github.com/damix00/taskbuddy-backend/blob/main/src/routes/index.ts"
click node_authorization "https://github.com/damix00/taskbuddy-backend/blob/main/src/middleware/authorization.ts"
click node_jwt "https://github.com/damix00/taskbuddy-backend/blob/main/src/verification/jwt.ts"
click node_phone "https://github.com/damix00/taskbuddy-backend/blob/main/src/verification/phone.ts"
click node_users "https://github.com/damix00/taskbuddy-backend/blob/main/src/database/wrappers/accounts/users/index.ts"
click node_profiles "https://github.com/damix00/taskbuddy-backend/blob/main/src/database/wrappers/accounts/profiles/index.ts"
click node_posts "https://github.com/damix00/taskbuddy-backend/blob/main/src/database/wrappers/posts/post/index.ts"
click node_post_routes "https://github.com/damix00/taskbuddy-backend/tree/main/src/routes/v1/posts"
click node_classification "https://github.com/damix00/taskbuddy-backend/blob/main/src/classification/cohere.ts"
click node_moderation "https://github.com/damix00/taskbuddy-backend/blob/main/src/classification/text_check.ts"
click node_discovery "https://github.com/damix00/taskbuddy-backend/tree/main/src/routes/v1/search"
click node_sessions "https://github.com/damix00/taskbuddy-backend/blob/main/src/database/wrappers/algorithm/sessions_wrapper.ts"
click node_channels "https://github.com/damix00/taskbuddy-backend/blob/main/src/database/models/chats/channels.ts"
click node_chat_routes "https://github.com/damix00/taskbuddy-backend/tree/main/src/routes/v1/channels"
click node_socket "https://github.com/damix00/taskbuddy-backend/blob/main/src/socket/socket_server.ts"
click node_reviews "https://github.com/damix00/taskbuddy-backend/blob/main/src/database/wrappers/reviews/wrapper.ts"
click node_database "https://github.com/damix00/taskbuddy-backend/blob/main/src/database/connection.ts"
click node_firebase "https://github.com/damix00/taskbuddy-backend/tree/main/src/firebase"

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_routing,node_database toneBlue
class node_authorization,node_jwt,node_phone,node_users,node_profiles toneAmber
class node_posts,node_post_routes,node_classification,node_moderation,node_discovery,node_sessions toneMint
class node_channels,node_chat_routes,node_socket,node_reviews toneRose
class node_cohere,node_openai,node_osm,node_twilio,node_firebase,node_mobile toneIndigo
```

## Components

### Server runtime

- [HTTP server](https://github.com/damix00/taskbuddy-backend/blob/main/src/index.ts): `src/index.ts`
- [Route registry](https://github.com/damix00/taskbuddy-backend/blob/main/src/routes/index.ts): `src/routes/index.ts`
- [PostgreSQL](https://github.com/damix00/taskbuddy-backend/blob/main/src/database/connection.ts): `src/database/connection.ts`

### Accounts and identity

- [Request authorization](https://github.com/damix00/taskbuddy-backend/blob/main/src/middleware/authorization.ts): `src/middleware/authorization.ts`
- [JWT verification](https://github.com/damix00/taskbuddy-backend/blob/main/src/verification/jwt.ts): `src/verification/jwt.ts`
- [Phone verification](https://github.com/damix00/taskbuddy-backend/blob/main/src/verification/phone.ts): `src/verification/phone.ts`
- [User accounts](https://github.com/damix00/taskbuddy-backend/blob/main/src/database/wrappers/accounts/users/index.ts): `src/database/wrappers/accounts/users/index.ts`
- [User profiles](https://github.com/damix00/taskbuddy-backend/blob/main/src/database/wrappers/accounts/profiles/index.ts): `src/database/wrappers/accounts/profiles/index.ts`

### Tasks and discovery

- [Task posts](https://github.com/damix00/taskbuddy-backend/blob/main/src/database/wrappers/posts/post/index.ts): `src/database/wrappers/posts/post/index.ts`
- [Task endpoints](https://github.com/damix00/taskbuddy-backend/tree/main/src/routes/v1/posts): `src/routes/v1/posts`
- [Task classification](https://github.com/damix00/taskbuddy-backend/blob/main/src/classification/cohere.ts): `src/classification/cohere.ts`
- [Content moderation](https://github.com/damix00/taskbuddy-backend/blob/main/src/classification/text_check.ts): `src/classification/text_check.ts`
- [Search and recommendations](https://github.com/damix00/taskbuddy-backend/tree/main/src/routes/v1/search): `src/routes/v1/search`
- [Feed sessions](https://github.com/damix00/taskbuddy-backend/blob/main/src/database/wrappers/algorithm/sessions_wrapper.ts): `src/database/wrappers/algorithm/sessions_wrapper.ts`

### Chat and reviews

- [Task channels](https://github.com/damix00/taskbuddy-backend/blob/main/src/database/models/chats/channels.ts): `src/database/models/chats/channels.ts`
- [Chat endpoints](https://github.com/damix00/taskbuddy-backend/tree/main/src/routes/v1/channels): `src/routes/v1/channels`
- [Realtime chat](https://github.com/damix00/taskbuddy-backend/blob/main/src/socket/socket_server.ts): `src/socket/socket_server.ts`
- [Task reviews](https://github.com/damix00/taskbuddy-backend/blob/main/src/database/wrappers/reviews/wrapper.ts): `src/database/wrappers/reviews/wrapper.ts`

### External services

- **Cohere API**
- **OpenAI moderation API**
- **OpenStreetMap API**
- **Twilio SMS**
- [Firebase services](https://github.com/damix00/taskbuddy-backend/tree/main/src/firebase): `src/firebase`

### Other components

- **Mobile app**

## Connections

- Mobile app → HTTP server: sends requests
- HTTP server → Route registry: registers routes (evidence: `src/index.ts`)
- HTTP server → PostgreSQL: connects (evidence: `src/index.ts`)
- HTTP server → Realtime chat: starts (evidence: `src/index.ts`)
- Route registry → Task endpoints: routes tasks (evidence: `src/routes/index.ts`)
- Route registry → Chat endpoints: routes chat (evidence: `src/routes/index.ts`)
- Request authorization → JWT verification: verifies tokens (evidence: `src/middleware/authorization.ts`)
- Request authorization → User accounts: loads user (evidence: `src/middleware/authorization.ts`)
- Request authorization → User profiles: loads profile (evidence: `src/middleware/authorization.ts`)
- Task endpoints → Task posts: manages tasks
- Task posts → PostgreSQL: persists tasks
- Task endpoints → Task classification: classifies text
- Task classification → Cohere API: embeds text
- Task endpoints → Content moderation: checks content
- Content moderation → OpenAI moderation API: moderates content
- Route registry → Search and recommendations: routes search (evidence: `src/routes/index.ts`)
- Search and recommendations → Feed sessions: personalizes feed
- Search and recommendations → OpenStreetMap API: filters by location
- Chat endpoints → Task channels: loads channel (evidence: `src/routes/v1/channels/[uuid]/middleware.ts`)
- Chat endpoints → Task reviews: creates review (evidence: `src/routes/v1/channels/[uuid]/messages/[message_uuid]/review.ts`)
- Chat endpoints → Realtime chat: emits chat events (evidence: `src/routes/v1/channels/[uuid]/actions/worker.ts`)
- Realtime chat → PostgreSQL: connects (evidence: `src/socket/socket_server.ts`)
- Phone verification → Twilio SMS: verifies numbers
- User profiles → Firebase services: uploads media (evidence: `src/database/wrappers/accounts/profiles/index.ts`)
- HTTP server → Firebase services: initializes (evidence: `src/index.ts`)
