# bustixpf/bustix-backend architecture

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

- Interactive diagram: https://gitdiagram.com/bustixpf/bustix-backend
- Repository: https://github.com/bustixpf/bustix-backend

## Overview

This is a BusTix backend API built with NestJS, despite the generic starter README. The main user flow is authentication followed by role-protected access to company and travel services; passengers can purchase tickets, while company administrators manage routes and trips. Superadmins review company, route, and schedule requests and oversee users and sales. The graph also includes notifications, uploads, audit logging, chatbot, and metrics. Relationships reflect the excerpts and SOURCE INDEX references; unsampled implementations are represented by their listed paths, without assuming their internal call flows.

Main entry points: [`src/companies/companies.controller.ts`](https://github.com/bustixpf/bustix-backend/blob/main/src/companies/companies.controller.ts) (Company endpoints), [`src/auth`](https://github.com/bustixpf/bustix-backend/tree/main/src/auth) (Auth and guards), [`src/dashboard/dashboard.service.ts`](https://github.com/bustixpf/bustix-backend/blob/main/src/dashboard/dashboard.service.ts) (Dashboard workflows), [`src/notifications/notifications.service.ts`](https://github.com/bustixpf/bustix-backend/blob/main/src/notifications/notifications.service.ts) (Email notifications)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and access"]
  node_auth_api["Auth endpoints<br/>[auth.controller.ts]"]
  node_auth_core["Auth and guards"]
  node_users["Users<br/>[users.service.ts]"]
end

subgraph group_company["Company operations"]
  node_companies_api["Company endpoints"]
  node_companies["Company services"]
  node_company_store[("Company records<br/>[company.entity.ts]")]
  node_uploads["Document uploads"]
end

subgraph group_travel["Travel and sales"]
  node_routes_api["Route endpoints"]
  node_routes["Route services<br/>[routes.service.ts]"]
  node_route_records[("Route records<br/>[routes.entity.ts]")]
  node_trips["Trip services<br/>[trips.service.ts]"]
  node_tickets["Ticket services<br/>[tickets.service.ts]"]
  node_payments_api["Payment endpoints"]
  node_payments["Payment processing"]
end

subgraph group_admin["Administration"]
  node_dashboard_api["Dashboard endpoints"]
  node_dashboard["Dashboard workflows"]
  node_requests[("Review requests")]
end

subgraph group_support["Platform services"]
  node_audit["Audit logging"]
  node_notifications_api["Notification endpoints"]
  node_notifications["Email notifications"]
  node_templates["Email templates"]
  node_email_provider{{"Brevo email"}}
  node_chatbot["Chatbot<br/>[chatbot.service.ts]"]
  node_metrics["Metrics<br/>[metric.service.ts]"]
end

node_client(("API client"))

node_client -->|"requests login"| node_auth_api
node_auth_api -->|"delegates auth"| node_auth_core
node_auth_core -->|"looks up users"| node_users
node_auth_core -->|"sends welcome"| node_notifications
node_client -->|"requests companies"| node_companies_api
node_companies_api -->|"delegates operations"| node_companies
node_companies_api -->|"issues upload token"| node_uploads
node_companies_api -->|"applies interceptor"| node_audit
node_companies_api -->|"guards access"| node_auth_core
node_client -->|"requests administration"| node_dashboard_api
node_dashboard_api -->|"delegates workflows"| node_dashboard
node_dashboard -->|"queries users"| node_users
node_dashboard -->|"uses company service"| node_companies
node_dashboard -->|"handles requests"| node_requests
node_client -->|"requests routes"| node_routes_api
node_routes_api -->|"delegates operations"| node_routes
node_routes_api -->|"guards access"| node_auth_core
node_route_records -->|"references company"| node_company_store
node_route_records -->|"relates trips"| node_trips
node_client -->|"requests checkout"| node_payments_api
node_payments_api -->|"delegates payment"| node_payments
node_client -->|"requests tickets"| node_tickets
node_client -->|"requests email test"| node_notifications_api
node_notifications_api -->|"dispatches email"| node_notifications
node_notifications -->|"renders templates"| node_templates
node_notifications -->|"sends email"| node_email_provider
node_client -->|"uses chatbot"| node_chatbot
node_client -->|"requests metrics"| node_metrics

click node_auth_api "https://github.com/bustixpf/bustix-backend/blob/main/src/auth/auth.controller.ts"
click node_auth_core "https://github.com/bustixpf/bustix-backend/tree/main/src/auth"
click node_users "https://github.com/bustixpf/bustix-backend/blob/main/src/users/users.service.ts"
click node_companies_api "https://github.com/bustixpf/bustix-backend/blob/main/src/companies/companies.controller.ts"
click node_companies "https://github.com/bustixpf/bustix-backend/blob/main/src/companies/companies.service.ts"
click node_company_store "https://github.com/bustixpf/bustix-backend/blob/main/src/companies/entities/company.entity.ts"
click node_uploads "https://github.com/bustixpf/bustix-backend/blob/main/src/file-upload/file-upload.service.ts"
click node_dashboard_api "https://github.com/bustixpf/bustix-backend/blob/main/src/dashboard/superadmin.controller.ts"
click node_dashboard "https://github.com/bustixpf/bustix-backend/blob/main/src/dashboard/dashboard.service.ts"
click node_requests "https://github.com/bustixpf/bustix-backend/blob/main/src/dashboard/entities/route-request.entity.ts"
click node_routes_api "https://github.com/bustixpf/bustix-backend/blob/main/src/routes/routes.controller.ts"
click node_routes "https://github.com/bustixpf/bustix-backend/blob/main/src/routes/routes.service.ts"
click node_route_records "https://github.com/bustixpf/bustix-backend/blob/main/src/routes/entities/routes.entity.ts"
click node_trips "https://github.com/bustixpf/bustix-backend/blob/main/src/trips/trips.service.ts"
click node_tickets "https://github.com/bustixpf/bustix-backend/blob/main/src/tickets/tickets.service.ts"
click node_payments_api "https://github.com/bustixpf/bustix-backend/blob/main/src/payments/payments.controller.ts"
click node_payments "https://github.com/bustixpf/bustix-backend/blob/main/src/payments/payments.service.ts"
click node_audit "https://github.com/bustixpf/bustix-backend/blob/main/src/auditLog/auditLog.interceptor.ts"
click node_notifications_api "https://github.com/bustixpf/bustix-backend/blob/main/src/notifications/notifications.controller.ts"
click node_notifications "https://github.com/bustixpf/bustix-backend/blob/main/src/notifications/notifications.service.ts"
click node_templates "https://github.com/bustixpf/bustix-backend/blob/main/src/notifications/email-templates.service.ts"
click node_chatbot "https://github.com/bustixpf/bustix-backend/blob/main/src/chatbot/chatbot.service.ts"
click node_metrics "https://github.com/bustixpf/bustix-backend/blob/main/src/metrics/metric.service.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_auth_api,node_auth_core,node_users,node_client toneBlue
class node_companies_api,node_companies,node_company_store,node_uploads toneAmber
class node_routes_api,node_routes,node_route_records,node_trips,node_tickets,node_payments_api,node_payments toneMint
class node_dashboard_api,node_dashboard,node_requests toneRose
class node_audit,node_notifications_api,node_notifications,node_templates,node_email_provider,node_chatbot,node_metrics toneIndigo
```

## Components

### Identity and access

- [Auth endpoints](https://github.com/bustixpf/bustix-backend/blob/main/src/auth/auth.controller.ts): `src/auth/auth.controller.ts`
- [Auth and guards](https://github.com/bustixpf/bustix-backend/tree/main/src/auth): `src/auth`
- [Users](https://github.com/bustixpf/bustix-backend/blob/main/src/users/users.service.ts): `src/users/users.service.ts`

### Company operations

- [Company endpoints](https://github.com/bustixpf/bustix-backend/blob/main/src/companies/companies.controller.ts): `src/companies/companies.controller.ts`
- [Company services](https://github.com/bustixpf/bustix-backend/blob/main/src/companies/companies.service.ts): `src/companies/companies.service.ts`
- [Company records](https://github.com/bustixpf/bustix-backend/blob/main/src/companies/entities/company.entity.ts): `src/companies/entities/company.entity.ts`
- [Document uploads](https://github.com/bustixpf/bustix-backend/blob/main/src/file-upload/file-upload.service.ts): `src/file-upload/file-upload.service.ts`

### Travel and sales

- [Route endpoints](https://github.com/bustixpf/bustix-backend/blob/main/src/routes/routes.controller.ts): `src/routes/routes.controller.ts`
- [Route services](https://github.com/bustixpf/bustix-backend/blob/main/src/routes/routes.service.ts): `src/routes/routes.service.ts`
- [Route records](https://github.com/bustixpf/bustix-backend/blob/main/src/routes/entities/routes.entity.ts): `src/routes/entities/routes.entity.ts`
- [Trip services](https://github.com/bustixpf/bustix-backend/blob/main/src/trips/trips.service.ts): `src/trips/trips.service.ts`
- [Ticket services](https://github.com/bustixpf/bustix-backend/blob/main/src/tickets/tickets.service.ts): `src/tickets/tickets.service.ts`
- [Payment endpoints](https://github.com/bustixpf/bustix-backend/blob/main/src/payments/payments.controller.ts): `src/payments/payments.controller.ts`
- [Payment processing](https://github.com/bustixpf/bustix-backend/blob/main/src/payments/payments.service.ts): `src/payments/payments.service.ts`

### Administration

- [Dashboard endpoints](https://github.com/bustixpf/bustix-backend/blob/main/src/dashboard/superadmin.controller.ts): `src/dashboard/superadmin.controller.ts`
- [Dashboard workflows](https://github.com/bustixpf/bustix-backend/blob/main/src/dashboard/dashboard.service.ts): `src/dashboard/dashboard.service.ts`
- [Review requests](https://github.com/bustixpf/bustix-backend/blob/main/src/dashboard/entities/route-request.entity.ts): `src/dashboard/entities/route-request.entity.ts`

### Platform services

- [Audit logging](https://github.com/bustixpf/bustix-backend/blob/main/src/auditLog/auditLog.interceptor.ts): `src/auditLog/auditLog.interceptor.ts`
- [Notification endpoints](https://github.com/bustixpf/bustix-backend/blob/main/src/notifications/notifications.controller.ts): `src/notifications/notifications.controller.ts`
- [Email notifications](https://github.com/bustixpf/bustix-backend/blob/main/src/notifications/notifications.service.ts): `src/notifications/notifications.service.ts`
- [Email templates](https://github.com/bustixpf/bustix-backend/blob/main/src/notifications/email-templates.service.ts): `src/notifications/email-templates.service.ts`
- **Brevo email**
- [Chatbot](https://github.com/bustixpf/bustix-backend/blob/main/src/chatbot/chatbot.service.ts): `src/chatbot/chatbot.service.ts`
- [Metrics](https://github.com/bustixpf/bustix-backend/blob/main/src/metrics/metric.service.ts): `src/metrics/metric.service.ts`

### Other components

- **API client**

## Connections

- API client → Auth endpoints: requests login (evidence: `src/auth/auth.controller.ts`)
- Auth endpoints → Auth and guards: delegates auth (evidence: `src/auth/auth.controller.ts`)
- Auth and guards → Users: looks up users (evidence: `src/auth/auth.service.ts`)
- Auth and guards → Email notifications: sends welcome (evidence: `src/auth/auth.service.ts`)
- API client → Company endpoints: requests companies (evidence: `src/companies/companies.controller.ts`)
- Company endpoints → Company services: delegates operations (evidence: `src/companies/companies.controller.ts`)
- Company endpoints → Document uploads: issues upload token (evidence: `src/companies/companies.controller.ts`)
- Company endpoints → Audit logging: applies interceptor (evidence: `src/companies/companies.controller.ts`)
- Company endpoints → Auth and guards: guards access (evidence: `src/companies/companies.controller.ts`)
- API client → Dashboard endpoints: requests administration (evidence: `src/dashboard/superadmin.controller.ts`)
- Dashboard endpoints → Dashboard workflows: delegates workflows (evidence: `src/dashboard/superadmin.controller.ts`)
- Dashboard workflows → Users: queries users (evidence: `src/dashboard/dashboard.service.ts`)
- Dashboard workflows → Company services: uses company service (evidence: `src/dashboard/dashboard.service.ts`)
- Dashboard workflows → Review requests: handles requests (evidence: `src/dashboard/dashboard.service.ts`)
- API client → Route endpoints: requests routes (evidence: `src/routes/routes.controller.ts`)
- Route endpoints → Route services: delegates operations (evidence: `src/routes/routes.controller.ts`)
- Route endpoints → Auth and guards: guards access (evidence: `src/routes/routes.controller.ts`)
- Route records → Company records: references company (evidence: `src/routes/entities/routes.entity.ts`)
- Route records → Trip services: relates trips (evidence: `src/routes/entities/routes.entity.ts`)
- API client → Payment endpoints: requests checkout (evidence: `src/payments/payments.controller.ts`)
- Payment endpoints → Payment processing: delegates payment (evidence: `src/payments/payments.controller.ts`)
- API client → Ticket services: requests tickets
- API client → Notification endpoints: requests email test (evidence: `src/notifications/notifications.controller.ts`)
- Notification endpoints → Email notifications: dispatches email (evidence: `src/notifications/notifications.controller.ts`)
- Email notifications → Email templates: renders templates (evidence: `src/notifications/notifications.service.ts`)
- Email notifications → Brevo email: sends email (evidence: `src/notifications/notifications.service.ts`)
- API client → Chatbot: uses chatbot
- API client → Metrics: requests metrics
