# saleem-bazhil/open_call_2 architecture

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

- Interactive diagram: https://gitdiagram.com/saleem-bazhil/open_call_2
- Repository: https://github.com/saleem-bazhil/open_call_2

## Overview

Open Call is a backend API for managing uploads and producing daily call plans, with matching, reporting, regional access controls, and administrative monitoring and configuration. The principal workflow accepts source files, parses and stores records, then lets the API preview matches and generate call-plan output. The graph also shows administration and operational support. Relationships are limited to those visible in excerpts or the SOURCE INDEX; unsampled report-generation and route wiring is represented without inferred call edges.

Main entry points: [`backend/src/services/compareService/matchPreviewService.ts`](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/compareService/matchPreviewService.ts) (Match preview service), [`backend/src/config/database.ts`](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/config/database.ts) (PostgreSQL), [`backend/src/services/uploadService.ts`](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/uploadService.ts) (Upload service), [`backend/src/services/engineers/engineerService.ts`](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/engineers/engineerService.ts) (Engineer service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Upload and Parsing"]
  node_uploadctrl["Upload endpoint"]
  node_uploadsvc["Upload service<br/>[uploadService.ts]"]
  node_parser["Source parser"]
end

subgraph group_operations["Matching and Plans"]
  node_previewctrl["Match preview endpoint"]
  node_preview["Match preview service"]
  node_matcher["Matching engine<br/>[matchingEngine.ts]"]
  node_normalize["Value normalization<br/>[valueNormalizer.ts]"]
  node_plan["Daily call-plan generator"]
  node_formatter["Call-plan formatter"]
  node_report["Report comparison"]
end

subgraph group_api["API and Access"]
  node_apiapp["Express application<br/>[app.ts]"]
  node_routes["API routes<br/>[index.ts]"]
  node_auth["Authentication and roles<br/>[authMiddleware.ts]"]
  node_regionaccess["Regional access"]
end

subgraph group_admin["Administration"]
  node_adminroutes["Admin routes<br/>[adminRoutes.ts]"]
  node_adminusers["User administration"]
  node_engineerctrl["Engineer administration"]
  node_engineersvc["Engineer service<br/>[engineerService.ts]"]
  node_monitoring["Monitoring service"]
  node_rca["RCA service<br/>[rcaService.ts]"]
end

subgraph group_platform["Persistence and Runtime"]
  node_records[("Source records")]
  node_batches[("Upload batches")]
  node_engineerrepo[("Engineer records")]
  node_db[("PostgreSQL<br/>[database.ts]")]
  node_health["Database health"]
  node_runtime["Runtime verification"]
end

node_frontend(("Frontend client"))

node_frontend -.->|"sends requests"| node_apiapp
node_apiapp -->|"mounts API"| node_routes
node_uploadsvc -->|"parses files"| node_parser
node_uploadsvc -->|"stores records"| node_records
node_uploadsvc -->|"stores batches"| node_batches
node_previewctrl -->|"requests preview"| node_preview
node_preview -->|"loads source rows"| node_records
node_preview -->|"validates batches"| node_batches
node_preview -->|"matches records"| node_matcher
node_matcher -->|"normalizes values"| node_normalize
node_engineerctrl -->|"calls service"| node_engineersvc
node_engineersvc -->|"reads and updates"| node_engineerrepo
node_engineersvc -->|"records activity"| node_db
node_monitoring -->|"queries database"| node_db
node_rca -.->|"reads case data"| node_db
node_health -->|"checks connection"| node_db
node_runtime -->|"verifies runtime"| node_db
node_adminroutes -->|"routes requests"| node_adminusers
node_adminroutes -->|"routes requests"| node_engineerctrl
node_preview -->|"checks region access"| node_regionaccess
node_plan -.->|"formats plan"| node_formatter

click node_apiapp "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/app.ts"
click node_routes "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/routes/index.ts"
click node_uploadctrl "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/controllers/uploadController.ts"
click node_uploadsvc "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/uploadService.ts"
click node_parser "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/excelParser/sourceParserService.ts"
click node_records "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/repositories/sourceRecordRepository.ts"
click node_batches "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/repositories/uploadBatchRepository.ts"
click node_previewctrl "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/controllers/matchPreviewController.ts"
click node_preview "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/compareService/matchPreviewService.ts"
click node_matcher "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/compareService/matchingEngine.ts"
click node_normalize "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/normalization/valueNormalizer.ts"
click node_plan "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/callPlanGenerator/dailyCallPlanGenerator.ts"
click node_formatter "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/callPlanGenerator/dailyCallPlanFormatter.ts"
click node_report "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/reportComparison/compareReportsService.ts"
click node_auth "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/middlewares/authMiddleware.ts"
click node_regionaccess "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/rbac/regionAccessService.ts"
click node_adminroutes "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/routes/adminRoutes.ts"
click node_adminusers "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/controllers/adminUserController.ts"
click node_engineerctrl "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/controllers/adminEngineerController.ts"
click node_engineersvc "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/engineers/engineerService.ts"
click node_engineerrepo "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/repositories/engineerRepository.ts"
click node_monitoring "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/audit/monitoringService.ts"
click node_rca "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/rca/rcaService.ts"
click node_db "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/config/database.ts"
click node_health "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/databaseHealthService.ts"
click node_runtime "https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/runtime/runtimeVerificationService.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_uploadctrl,node_uploadsvc,node_parser,node_frontend toneBlue
class node_previewctrl,node_preview,node_matcher,node_normalize,node_plan,node_formatter,node_report toneAmber
class node_apiapp,node_routes,node_auth,node_regionaccess toneMint
class node_adminroutes,node_adminusers,node_engineerctrl,node_engineersvc,node_monitoring,node_rca toneRose
class node_records,node_batches,node_engineerrepo,node_db,node_health,node_runtime toneIndigo
```

## Components

### Upload and Parsing

- [Upload endpoint](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/controllers/uploadController.ts): `backend/src/controllers/uploadController.ts`
- [Upload service](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/uploadService.ts): `backend/src/services/uploadService.ts`
- [Source parser](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/excelParser/sourceParserService.ts): `backend/src/services/excelParser/sourceParserService.ts`

### Matching and Plans

- [Match preview endpoint](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/controllers/matchPreviewController.ts): `backend/src/controllers/matchPreviewController.ts`
- [Match preview service](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/compareService/matchPreviewService.ts): `backend/src/services/compareService/matchPreviewService.ts`
- [Matching engine](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/compareService/matchingEngine.ts): `backend/src/services/compareService/matchingEngine.ts`
- [Value normalization](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/normalization/valueNormalizer.ts): `backend/src/services/normalization/valueNormalizer.ts`
- [Daily call-plan generator](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/callPlanGenerator/dailyCallPlanGenerator.ts): `backend/src/services/callPlanGenerator/dailyCallPlanGenerator.ts`
- [Call-plan formatter](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/callPlanGenerator/dailyCallPlanFormatter.ts): `backend/src/services/callPlanGenerator/dailyCallPlanFormatter.ts`
- [Report comparison](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/reportComparison/compareReportsService.ts): `backend/src/services/reportComparison/compareReportsService.ts`

### API and Access

- [Express application](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/app.ts): `backend/src/app.ts`
- [API routes](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/routes/index.ts): `backend/src/routes/index.ts`
- [Authentication and roles](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/middlewares/authMiddleware.ts): `backend/src/middlewares/authMiddleware.ts`
- [Regional access](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/rbac/regionAccessService.ts): `backend/src/services/rbac/regionAccessService.ts`

### Administration

- [Admin routes](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/routes/adminRoutes.ts): `backend/src/routes/adminRoutes.ts`
- [User administration](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/controllers/adminUserController.ts): `backend/src/controllers/adminUserController.ts`
- [Engineer administration](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/controllers/adminEngineerController.ts): `backend/src/controllers/adminEngineerController.ts`
- [Engineer service](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/engineers/engineerService.ts): `backend/src/services/engineers/engineerService.ts`
- [Monitoring service](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/audit/monitoringService.ts): `backend/src/services/audit/monitoringService.ts`
- [RCA service](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/rca/rcaService.ts): `backend/src/services/rca/rcaService.ts`

### Persistence and Runtime

- [Source records](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/repositories/sourceRecordRepository.ts): `backend/src/repositories/sourceRecordRepository.ts`
- [Upload batches](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/repositories/uploadBatchRepository.ts): `backend/src/repositories/uploadBatchRepository.ts`
- [Engineer records](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/repositories/engineerRepository.ts): `backend/src/repositories/engineerRepository.ts`
- [PostgreSQL](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/config/database.ts): `backend/src/config/database.ts`
- [Database health](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/databaseHealthService.ts): `backend/src/services/databaseHealthService.ts`
- [Runtime verification](https://github.com/saleem-bazhil/open_call_2/blob/main/backend/src/services/runtime/runtimeVerificationService.ts): `backend/src/services/runtime/runtimeVerificationService.ts`

### Other components

- **Frontend client**

## Connections

- Frontend client → Express application: sends requests (evidence: `README.md`)
- Express application → API routes: mounts API (evidence: `backend/src/app.ts`)
- Upload service → Source parser: parses files (evidence: `backend/src/services/uploadService.ts`)
- Upload service → Source records: stores records (evidence: `backend/src/services/uploadService.ts`)
- Upload service → Upload batches: stores batches (evidence: `backend/src/services/uploadService.ts`)
- Match preview endpoint → Match preview service: requests preview (evidence: `backend/src/controllers/matchPreviewController.ts`)
- Match preview service → Source records: loads source rows (evidence: `backend/src/services/compareService/matchPreviewService.ts`)
- Match preview service → Upload batches: validates batches (evidence: `backend/src/services/compareService/matchPreviewService.ts`)
- Match preview service → Matching engine: matches records (evidence: `backend/src/services/compareService/matchPreviewService.ts`)
- Matching engine → Value normalization: normalizes values (evidence: `backend/src/services/compareService/matchingEngine.ts`)
- Engineer administration → Engineer service: calls service (evidence: `backend/src/controllers/adminEngineerController.ts`)
- Engineer service → Engineer records: reads and updates (evidence: `backend/src/services/engineers/engineerService.ts`)
- Engineer service → PostgreSQL: records activity (evidence: `backend/src/services/engineers/engineerService.ts`)
- Monitoring service → PostgreSQL: queries database (evidence: `backend/src/services/audit/monitoringService.ts`)
- RCA service → PostgreSQL: reads case data
- Database health → PostgreSQL: checks connection (evidence: `backend/src/services/databaseHealthService.ts`)
- Runtime verification → PostgreSQL: verifies runtime (evidence: `backend/src/services/runtime/runtimeVerificationService.ts`)
- Admin routes → User administration: routes requests (evidence: `backend/src/routes/adminRoutes.ts`)
- Admin routes → Engineer administration: routes requests (evidence: `backend/src/routes/adminRoutes.ts`)
- Match preview service → Regional access: checks region access (evidence: `backend/src/services/compareService/matchPreviewService.ts`)
- Daily call-plan generator → Call-plan formatter: formats plan
