# nipuana/teflow_backend architecture

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

- Interactive diagram: https://gitdiagram.com/nipuana/teflow_backend
- Repository: https://github.com/nipuana/teflow_backend

## Overview

Teflow is a team-collaboration backend exposing an Express REST API. The documented user workflow enters through the versioned API, authenticates a session, then manages organizations, projects, tasks, and notifications; billing and outbound integrations are additional product capabilities. Domain services and repositories provide the internal application and persistence layers. Edges are limited to relationships shown in the README, excerpts, or SOURCE INDEX; unsampled details are not inferred.

Main entry points: [`src/api/v1/index.ts`](https://github.com/nipuana/teflow_backend/blob/master/src/api/v1/index.ts) (Versioned API), [`src/modules/orgs/orgs.service.ts`](https://github.com/nipuana/teflow_backend/blob/master/src/modules/orgs/orgs.service.ts) (Organizations and roles), [`src/modules/auth/auth.service.ts`](https://github.com/nipuana/teflow_backend/blob/master/src/modules/auth/auth.service.ts) (Accounts and sessions), [`src/modules/notifications/notifications.service.ts`](https://github.com/nipuana/teflow_backend/blob/master/src/modules/notifications/notifications.service.ts) (Notifications)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry"]
  node_app["Express app<br/>[app.ts]"]
  node_v1["Versioned API<br/>[index.ts]"]
end

subgraph group_identity["Identity and access"]
  node_auth["Accounts and sessions<br/>[auth.service.ts]"]
  node_authrepo["Auth repository<br/>[auth.repository.ts]"]
  node_authctl["Auth controller<br/>[auth.controller.ts]"]
  node_authguard["Token authentication<br/>[auth.ts]"]
end

subgraph group_work["Team and work"]
  node_orgs["Organizations and roles<br/>[orgs.service.ts]"]
  node_orgrepo["Organization repository<br/>[orgs.repository.ts]"]
  node_orgctl["Organization controller<br/>[orgs.controller.ts]"]
  node_projects["Projects"]
  node_projectrepo["Project repository"]
  node_projectctl["Project controller"]
  node_tasks["Tasks and attachments<br/>[tasks.service.ts]"]
  node_taskrepo["Task repository"]
  node_taskctl["Task controller"]
end

subgraph group_capabilities["Product capabilities"]
  node_notifications["Notifications"]
  node_notificationrepo["Notification repository"]
  node_billing["Billing<br/>[billing.service.ts]"]
  node_integrations["Outbound integrations"]
end

subgraph group_platform["Shared platform"]
  node_db[("Database adapter<br/>[db.ts]")]
  node_files[("File storage<br/>[fileStorage.ts]")]
  node_http["Outbound HTTP adapter<br/>[outboundHttp.ts]"]
  node_config["Runtime configuration<br/>[index.ts]"]
end

node_client(("Teflow web client"))

node_client -->|"sends requests"| node_app
node_app -->|"mounts API"| node_v1
node_v1 -->|"routes requests"| node_authctl
node_v1 -->|"routes requests"| node_orgctl
node_v1 -->|"routes requests"| node_projectctl
node_v1 -->|"routes requests"| node_taskctl
node_v1 -->|"exposes routes"| node_billing
node_v1 -->|"exposes routes"| node_integrations
node_v1 -->|"exposes routes"| node_notifications
node_authctl -->|"calls service"| node_auth
node_auth -->|"uses repository"| node_authrepo
node_authrepo -->|"uses adapter"| node_db
node_auth -->|"creates organization"| node_orgs
node_auth -->|"emits notification"| node_notifications
node_auth -->|"stores avatar"| node_files
node_auth -->|"fetches avatar URL"| node_http
node_orgctl -->|"calls service"| node_orgs
node_orgs -->|"uses repository"| node_orgrepo
node_orgs -->|"uses repository"| node_authrepo
node_orgs -->|"uses service"| node_notifications
node_projectctl -->|"calls service"| node_projects
node_projects -->|"uses repository"| node_projectrepo
node_projects -->|"checks organization"| node_orgs
node_taskctl -->|"calls service"| node_tasks
node_tasks -->|"uses repository"| node_taskrepo
node_tasks -->|"checks project"| node_projects
node_tasks -->|"emits notification"| node_notifications
node_tasks -->|"stores attachments"| node_files
node_notifications -->|"uses repository"| node_notificationrepo
node_notifications -->|"looks up account"| node_authrepo
node_billing -.->|"uses service"| node_orgs
node_integrations -.->|"uses adapter"| node_http
node_files -->|"reads limits"| node_config
node_app -->|"reads settings"| node_config

click node_app "https://github.com/nipuana/teflow_backend/blob/master/src/app.ts"
click node_v1 "https://github.com/nipuana/teflow_backend/blob/master/src/api/v1/index.ts"
click node_auth "https://github.com/nipuana/teflow_backend/blob/master/src/modules/auth/auth.service.ts"
click node_authrepo "https://github.com/nipuana/teflow_backend/blob/master/src/modules/auth/auth.repository.ts"
click node_authctl "https://github.com/nipuana/teflow_backend/blob/master/src/modules/auth/auth.controller.ts"
click node_authguard "https://github.com/nipuana/teflow_backend/blob/master/src/shared/middleware/auth.ts"
click node_orgs "https://github.com/nipuana/teflow_backend/blob/master/src/modules/orgs/orgs.service.ts"
click node_orgrepo "https://github.com/nipuana/teflow_backend/blob/master/src/modules/orgs/orgs.repository.ts"
click node_orgctl "https://github.com/nipuana/teflow_backend/blob/master/src/modules/orgs/orgs.controller.ts"
click node_projects "https://github.com/nipuana/teflow_backend/blob/master/src/modules/projects/projects.service.ts"
click node_projectrepo "https://github.com/nipuana/teflow_backend/blob/master/src/modules/projects/projects.repository.ts"
click node_projectctl "https://github.com/nipuana/teflow_backend/blob/master/src/modules/projects/projects.controller.ts"
click node_tasks "https://github.com/nipuana/teflow_backend/blob/master/src/modules/tasks/tasks.service.ts"
click node_taskrepo "https://github.com/nipuana/teflow_backend/blob/master/src/modules/tasks/tasks.repository.ts"
click node_taskctl "https://github.com/nipuana/teflow_backend/blob/master/src/modules/tasks/tasks.controller.ts"
click node_notifications "https://github.com/nipuana/teflow_backend/blob/master/src/modules/notifications/notifications.service.ts"
click node_notificationrepo "https://github.com/nipuana/teflow_backend/blob/master/src/modules/notifications/notifications.repository.ts"
click node_billing "https://github.com/nipuana/teflow_backend/blob/master/src/modules/billing/billing.service.ts"
click node_integrations "https://github.com/nipuana/teflow_backend/blob/master/src/modules/integrations/integrations.service.ts"
click node_db "https://github.com/nipuana/teflow_backend/blob/master/src/shared/adapters/db.ts"
click node_files "https://github.com/nipuana/teflow_backend/blob/master/src/shared/adapters/fileStorage.ts"
click node_http "https://github.com/nipuana/teflow_backend/blob/master/src/shared/adapters/outboundHttp.ts"
click node_config "https://github.com/nipuana/teflow_backend/blob/master/src/shared/config/index.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_app,node_v1,node_client toneBlue
class node_auth,node_authrepo,node_authctl,node_authguard toneAmber
class node_orgs,node_orgrepo,node_orgctl,node_projects,node_projectrepo,node_projectctl,node_tasks,node_taskrepo,node_taskctl toneMint
class node_notifications,node_notificationrepo,node_billing,node_integrations toneRose
class node_db,node_files,node_http,node_config toneIndigo
```

## Components

### API entry

- [Express app](https://github.com/nipuana/teflow_backend/blob/master/src/app.ts): `src/app.ts`
- [Versioned API](https://github.com/nipuana/teflow_backend/blob/master/src/api/v1/index.ts): `src/api/v1/index.ts`

### Identity and access

- [Accounts and sessions](https://github.com/nipuana/teflow_backend/blob/master/src/modules/auth/auth.service.ts): `src/modules/auth/auth.service.ts`
- [Auth repository](https://github.com/nipuana/teflow_backend/blob/master/src/modules/auth/auth.repository.ts): `src/modules/auth/auth.repository.ts`
- [Auth controller](https://github.com/nipuana/teflow_backend/blob/master/src/modules/auth/auth.controller.ts): `src/modules/auth/auth.controller.ts`
- [Token authentication](https://github.com/nipuana/teflow_backend/blob/master/src/shared/middleware/auth.ts): `src/shared/middleware/auth.ts`

### Team and work

- [Organizations and roles](https://github.com/nipuana/teflow_backend/blob/master/src/modules/orgs/orgs.service.ts): `src/modules/orgs/orgs.service.ts`
- [Organization repository](https://github.com/nipuana/teflow_backend/blob/master/src/modules/orgs/orgs.repository.ts): `src/modules/orgs/orgs.repository.ts`
- [Organization controller](https://github.com/nipuana/teflow_backend/blob/master/src/modules/orgs/orgs.controller.ts): `src/modules/orgs/orgs.controller.ts`
- [Projects](https://github.com/nipuana/teflow_backend/blob/master/src/modules/projects/projects.service.ts): `src/modules/projects/projects.service.ts`
- [Project repository](https://github.com/nipuana/teflow_backend/blob/master/src/modules/projects/projects.repository.ts): `src/modules/projects/projects.repository.ts`
- [Project controller](https://github.com/nipuana/teflow_backend/blob/master/src/modules/projects/projects.controller.ts): `src/modules/projects/projects.controller.ts`
- [Tasks and attachments](https://github.com/nipuana/teflow_backend/blob/master/src/modules/tasks/tasks.service.ts): `src/modules/tasks/tasks.service.ts`
- [Task repository](https://github.com/nipuana/teflow_backend/blob/master/src/modules/tasks/tasks.repository.ts): `src/modules/tasks/tasks.repository.ts`
- [Task controller](https://github.com/nipuana/teflow_backend/blob/master/src/modules/tasks/tasks.controller.ts): `src/modules/tasks/tasks.controller.ts`

### Product capabilities

- [Notifications](https://github.com/nipuana/teflow_backend/blob/master/src/modules/notifications/notifications.service.ts): `src/modules/notifications/notifications.service.ts`
- [Notification repository](https://github.com/nipuana/teflow_backend/blob/master/src/modules/notifications/notifications.repository.ts): `src/modules/notifications/notifications.repository.ts`
- [Billing](https://github.com/nipuana/teflow_backend/blob/master/src/modules/billing/billing.service.ts): `src/modules/billing/billing.service.ts`
- [Outbound integrations](https://github.com/nipuana/teflow_backend/blob/master/src/modules/integrations/integrations.service.ts): `src/modules/integrations/integrations.service.ts`

### Shared platform

- [Database adapter](https://github.com/nipuana/teflow_backend/blob/master/src/shared/adapters/db.ts): `src/shared/adapters/db.ts`
- [File storage](https://github.com/nipuana/teflow_backend/blob/master/src/shared/adapters/fileStorage.ts): `src/shared/adapters/fileStorage.ts`
- [Outbound HTTP adapter](https://github.com/nipuana/teflow_backend/blob/master/src/shared/adapters/outboundHttp.ts): `src/shared/adapters/outboundHttp.ts`
- [Runtime configuration](https://github.com/nipuana/teflow_backend/blob/master/src/shared/config/index.ts): `src/shared/config/index.ts`

### Other components

- **Teflow web client**

## Connections

- Teflow web client → Express app: sends requests
- Express app → Versioned API: mounts API (evidence: `src/app.ts`)
- Versioned API → Auth controller: routes requests (evidence: `src/api/v1/index.ts`)
- Versioned API → Organization controller: routes requests (evidence: `src/api/v1/index.ts`)
- Versioned API → Project controller: routes requests (evidence: `src/api/v1/index.ts`)
- Versioned API → Task controller: routes requests (evidence: `src/api/v1/index.ts`)
- Versioned API → Billing: exposes routes (evidence: `src/api/v1/index.ts`)
- Versioned API → Outbound integrations: exposes routes (evidence: `src/api/v1/index.ts`)
- Versioned API → Notifications: exposes routes (evidence: `src/api/v1/index.ts`)
- Auth controller → Accounts and sessions: calls service (evidence: `src/modules/auth/auth.controller.ts`)
- Accounts and sessions → Auth repository: uses repository (evidence: `src/modules/auth/auth.service.ts`)
- Auth repository → Database adapter: uses adapter (evidence: `src/modules/auth/auth.repository.ts`)
- Accounts and sessions → Organizations and roles: creates organization (evidence: `src/modules/auth/auth.service.ts`)
- Accounts and sessions → Notifications: emits notification (evidence: `src/modules/auth/auth.service.ts`)
- Accounts and sessions → File storage: stores avatar (evidence: `src/modules/auth/auth.service.ts`)
- Accounts and sessions → Outbound HTTP adapter: fetches avatar URL (evidence: `src/modules/auth/auth.service.ts`)
- Organization controller → Organizations and roles: calls service (evidence: `src/modules/orgs/orgs.controller.ts`)
- Organizations and roles → Organization repository: uses repository (evidence: `src/modules/orgs/orgs.service.ts`)
- Organizations and roles → Auth repository: uses repository (evidence: `src/modules/orgs/orgs.service.ts`)
- Organizations and roles → Notifications: uses service (evidence: `src/modules/orgs/orgs.service.ts`)
- Project controller → Projects: calls service (evidence: `src/modules/projects/projects.controller.ts`)
- Projects → Project repository: uses repository (evidence: `src/modules/projects/projects.service.ts`)
- Projects → Organizations and roles: checks organization (evidence: `src/modules/projects/projects.service.ts`)
- Task controller → Tasks and attachments: calls service (evidence: `src/modules/tasks/tasks.controller.ts`)
- Tasks and attachments → Task repository: uses repository (evidence: `src/modules/tasks/tasks.service.ts`)
- Tasks and attachments → Projects: checks project (evidence: `src/modules/tasks/tasks.service.ts`)
- Tasks and attachments → Notifications: emits notification (evidence: `src/modules/tasks/tasks.service.ts`)
- Tasks and attachments → File storage: stores attachments (evidence: `src/modules/tasks/tasks.service.ts`)
- Notifications → Notification repository: uses repository (evidence: `src/modules/notifications/notifications.service.ts`)
- Notifications → Auth repository: looks up account (evidence: `src/modules/notifications/notifications.service.ts`)
- Billing → Organizations and roles: uses service
- Outbound integrations → Outbound HTTP adapter: uses adapter
- File storage → Runtime configuration: reads limits (evidence: `src/shared/adapters/fileStorage.ts`)
- Express app → Runtime configuration: reads settings (evidence: `src/app.ts`)
