# jahanzaibaslammehar/field-service-api architecture

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

- Interactive diagram: https://gitdiagram.com/jahanzaibaslammehar/field-service-api
- Repository: https://github.com/jahanzaibaslammehar/field-service-api

## Overview

Field Service API is a NestJS field-service backend: contractors register companies, invite employees, create inspection cases, attach media, and prepare priced offers using supplier catalogs and AI-assisted materials parsing. The public gateway authenticates and scopes HTTP requests, then routes them to three TCP services sharing PostgreSQL through Prisma. The graph preserves the documented catalog-import and billing/storage capabilities; unsampled internals are represented at their supported directory paths, and unverified integration links are dashed.

Main entry points: [`apps/api-gateway/src`](https://github.com/jahanzaibaslammehar/field-service-api/tree/main/apps/api-gateway/src) (HTTP API), [`apps/api-gateway/src/cases/cases-http.controller.ts`](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/api-gateway/src/cases/cases-http.controller.ts) (Case routes), [`apps/api-gateway/src/suppliers/suppliers-http.controller.ts`](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/api-gateway/src/suppliers/suppliers-http.controller.ts) (Supplier routes), [`apps/authentication/src/auth/auth.controller.ts`](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/authentication/src/auth/auth.controller.ts) (Authentication service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["HTTP gateway"]
  node_gateway_http["HTTP API"]
  node_gateway_auth["Auth routes"]
  node_gateway_cases["Case routes"]
  node_gateway_media["Media routes"]
  node_gateway_offers["Offer routes"]
  node_gateway_supplier["Supplier routes"]
  node_gateway_authproxy["Auth RPC proxy"]
  node_gateway_caseproxy["Cases RPC proxy"]
end

subgraph group_identity["Identity and tenancy"]
  node_auth_service["Authentication service<br/>[auth.controller.ts]"]
  node_auth_logic["Auth and tokens<br/>[auth.service.ts]"]
  node_auth_signup["Signup and invitations<br/>[signup.service.ts]"]
end

subgraph group_fieldwork["Cases and offers"]
  node_case_service["Case management<br/>[cases.service.ts]"]
  node_materials["Materials parsing and quotes"]
  node_offers["Offer management<br/>[offers.service.ts]"]
  node_media_service["Media handling<br/>[media.service.ts]"]
end

subgraph group_catalog["Supplier catalog"]
  node_supplier_service["Supplier catalog"]
  node_catalog_import["Catalog import"]
  node_csv_parser["CSV parsing"]
  node_excel_parser["Excel parsing"]
end

subgraph group_shared["Shared capabilities"]
  node_database[("PostgreSQL / Prisma<br/>[prisma.service.ts]")]
  node_storage["S3 storage"]
  node_stripe["Stripe billing<br/>[stripe.service.ts]"]
end

node_contractor(("Contractor"))
node_llm{{"LLM provider"}}

node_contractor -->|"sends HTTP"| node_gateway_http
node_gateway_http -->|"routes auth"| node_gateway_auth
node_gateway_http -->|"routes cases"| node_gateway_cases
node_gateway_http -->|"routes media"| node_gateway_media
node_gateway_http -->|"routes offers"| node_gateway_offers
node_gateway_http -->|"routes suppliers"| node_gateway_supplier
node_gateway_auth -->|"calls proxy"| node_gateway_authproxy
node_gateway_cases -->|"calls proxy"| node_gateway_caseproxy
node_gateway_authproxy -->|"TCP RPC"| node_auth_service
node_gateway_caseproxy -->|"TCP RPC"| node_case_service
node_gateway_supplier -->|"TCP RPC"| node_supplier_service
node_auth_service -->|"dispatches login"| node_auth_logic
node_auth_service -->|"dispatches signup"| node_auth_signup
node_auth_logic -->|"reads and writes"| node_database
node_case_service -.->|"persists cases"| node_database
node_gateway_cases -->|"requests quote"| node_materials
node_materials -.->|"parses text"| node_llm
node_gateway_offers -->|"TCP RPC"| node_offers
node_gateway_media -->|"TCP RPC"| node_media_service
node_media_service -.->|"stores media"| node_storage
node_gateway_supplier -->|"imports catalog"| node_catalog_import
node_catalog_import -->|"parses CSV"| node_csv_parser
node_excel_parser -->|"reuses parsing"| node_csv_parser
node_supplier_service -.->|"catalog data"| node_database
node_auth_signup -.->|"creates billing"| node_stripe

click node_gateway_http "https://github.com/jahanzaibaslammehar/field-service-api/tree/main/apps/api-gateway/src"
click node_gateway_auth "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/api-gateway/src/auth/auth-http.controller.ts"
click node_gateway_cases "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/api-gateway/src/cases/cases-http.controller.ts"
click node_gateway_media "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/api-gateway/src/media/media-http.controller.ts"
click node_gateway_offers "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/api-gateway/src/offers/offers-http.controller.ts"
click node_gateway_supplier "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/api-gateway/src/suppliers/suppliers-http.controller.ts"
click node_gateway_authproxy "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/api-gateway/src/auth/auth-proxy.service.ts"
click node_gateway_caseproxy "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/api-gateway/src/cases/cases-proxy.service.ts"
click node_auth_service "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/authentication/src/auth/auth.controller.ts"
click node_auth_logic "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/authentication/src/auth/services/auth.service.ts"
click node_auth_signup "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/authentication/src/auth/services/signup.service.ts"
click node_case_service "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/cases/src/cases/services/cases.service.ts"
click node_materials "https://github.com/jahanzaibaslammehar/field-service-api/tree/main/apps/cases/src/materials"
click node_offers "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/cases/src/offers/services/offers.service.ts"
click node_media_service "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/cases/src/media/services/media.service.ts"
click node_supplier_service "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/suppliers/src/suppliers/services/suppliers.service.ts"
click node_catalog_import "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/suppliers/src/suppliers/catalog-import/services/catalog-import.service.ts"
click node_csv_parser "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/suppliers/src/suppliers/catalog-import/services/csv-parser.service.ts"
click node_excel_parser "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/suppliers/src/suppliers/catalog-import/services/excel-parser.service.ts"
click node_database "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/libs/shared/database/src/lib/prisma.service.ts"
click node_storage "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/libs/shared/storage/src/lib/s3-storage.service.ts"
click node_stripe "https://github.com/jahanzaibaslammehar/field-service-api/blob/main/libs/billing/stripe/src/lib/stripe.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_gateway_http,node_gateway_auth,node_gateway_cases,node_gateway_media,node_gateway_offers,node_gateway_supplier,node_gateway_authproxy,node_gateway_caseproxy toneBlue
class node_auth_service,node_auth_logic,node_auth_signup toneAmber
class node_case_service,node_materials,node_offers,node_media_service toneMint
class node_supplier_service,node_catalog_import,node_csv_parser,node_excel_parser toneRose
class node_database,node_storage,node_stripe,node_contractor,node_llm toneIndigo
```

## Components

### HTTP gateway

- [HTTP API](https://github.com/jahanzaibaslammehar/field-service-api/tree/main/apps/api-gateway/src): `apps/api-gateway/src`
- [Auth routes](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/api-gateway/src/auth/auth-http.controller.ts): `apps/api-gateway/src/auth/auth-http.controller.ts`
- [Case routes](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/api-gateway/src/cases/cases-http.controller.ts): `apps/api-gateway/src/cases/cases-http.controller.ts`
- [Media routes](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/api-gateway/src/media/media-http.controller.ts): `apps/api-gateway/src/media/media-http.controller.ts`
- [Offer routes](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/api-gateway/src/offers/offers-http.controller.ts): `apps/api-gateway/src/offers/offers-http.controller.ts`
- [Supplier routes](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/api-gateway/src/suppliers/suppliers-http.controller.ts): `apps/api-gateway/src/suppliers/suppliers-http.controller.ts`
- [Auth RPC proxy](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/api-gateway/src/auth/auth-proxy.service.ts): `apps/api-gateway/src/auth/auth-proxy.service.ts`
- [Cases RPC proxy](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/api-gateway/src/cases/cases-proxy.service.ts): `apps/api-gateway/src/cases/cases-proxy.service.ts`

### Identity and tenancy

- [Authentication service](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/authentication/src/auth/auth.controller.ts): `apps/authentication/src/auth/auth.controller.ts`
- [Auth and tokens](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/authentication/src/auth/services/auth.service.ts): `apps/authentication/src/auth/services/auth.service.ts`
- [Signup and invitations](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/authentication/src/auth/services/signup.service.ts): `apps/authentication/src/auth/services/signup.service.ts`

### Cases and offers

- [Case management](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/cases/src/cases/services/cases.service.ts): `apps/cases/src/cases/services/cases.service.ts`
- [Materials parsing and quotes](https://github.com/jahanzaibaslammehar/field-service-api/tree/main/apps/cases/src/materials): `apps/cases/src/materials`
- [Offer management](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/cases/src/offers/services/offers.service.ts): `apps/cases/src/offers/services/offers.service.ts`
- [Media handling](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/cases/src/media/services/media.service.ts): `apps/cases/src/media/services/media.service.ts`

### Supplier catalog

- [Supplier catalog](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/suppliers/src/suppliers/services/suppliers.service.ts): `apps/suppliers/src/suppliers/services/suppliers.service.ts`
- [Catalog import](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/suppliers/src/suppliers/catalog-import/services/catalog-import.service.ts): `apps/suppliers/src/suppliers/catalog-import/services/catalog-import.service.ts`
- [CSV parsing](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/suppliers/src/suppliers/catalog-import/services/csv-parser.service.ts): `apps/suppliers/src/suppliers/catalog-import/services/csv-parser.service.ts`
- [Excel parsing](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/apps/suppliers/src/suppliers/catalog-import/services/excel-parser.service.ts): `apps/suppliers/src/suppliers/catalog-import/services/excel-parser.service.ts`

### Shared capabilities

- [PostgreSQL / Prisma](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/libs/shared/database/src/lib/prisma.service.ts): `libs/shared/database/src/lib/prisma.service.ts`
- [S3 storage](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/libs/shared/storage/src/lib/s3-storage.service.ts): `libs/shared/storage/src/lib/s3-storage.service.ts`
- [Stripe billing](https://github.com/jahanzaibaslammehar/field-service-api/blob/main/libs/billing/stripe/src/lib/stripe.service.ts): `libs/billing/stripe/src/lib/stripe.service.ts`

### Other components

- **Contractor**
- **LLM provider**

## Connections

- Contractor → HTTP API: sends HTTP
- HTTP API → Auth routes: routes auth (evidence: `apps/api-gateway/src/auth/auth-http.controller.ts`)
- HTTP API → Case routes: routes cases (evidence: `apps/api-gateway/src/cases/cases-http.controller.ts`)
- HTTP API → Media routes: routes media (evidence: `apps/api-gateway/src/media/media-http.controller.ts`)
- HTTP API → Offer routes: routes offers (evidence: `apps/api-gateway/src/offers/offers-http.controller.ts`)
- HTTP API → Supplier routes: routes suppliers (evidence: `apps/api-gateway/src/suppliers/suppliers-http.controller.ts`)
- Auth routes → Auth RPC proxy: calls proxy (evidence: `apps/api-gateway/src/auth/auth-http.controller.ts`)
- Case routes → Cases RPC proxy: calls proxy (evidence: `apps/api-gateway/src/cases/cases-http.controller.ts`)
- Auth RPC proxy → Authentication service: TCP RPC
- Cases RPC proxy → Case management: TCP RPC
- Supplier routes → Supplier catalog: TCP RPC
- Authentication service → Auth and tokens: dispatches login (evidence: `apps/authentication/src/auth/auth.controller.ts`)
- Authentication service → Signup and invitations: dispatches signup (evidence: `apps/authentication/src/auth/auth.controller.ts`)
- Auth and tokens → PostgreSQL / Prisma: reads and writes (evidence: `apps/authentication/src/auth/services/auth.service.ts`)
- Case management → PostgreSQL / Prisma: persists cases
- Case routes → Materials parsing and quotes: requests quote (evidence: `apps/api-gateway/src/cases/cases-http.controller.ts`)
- Materials parsing and quotes → LLM provider: parses text
- Offer routes → Offer management: TCP RPC
- Media routes → Media handling: TCP RPC
- Media handling → S3 storage: stores media
- Supplier routes → Catalog import: imports catalog
- Catalog import → CSV parsing: parses CSV (evidence: `apps/suppliers/src/suppliers/catalog-import/services/csv-parser.service.ts`)
- Excel parsing → CSV parsing: reuses parsing (evidence: `apps/suppliers/src/suppliers/catalog-import/services/excel-parser.service.ts`)
- Supplier catalog → PostgreSQL / Prisma: catalog data
- Signup and invitations → Stripe billing: creates billing
