# hegdepunithramesh/recruiterflow-backend-assignment architecture

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

- Interactive diagram: https://gitdiagram.com/hegdepunithramesh/recruiterflow-backend-assignment
- Repository: https://github.com/hegdepunithramesh/recruiterflow-backend-assignment

## Overview

Recruiter Bot’s main workflow accepts a match request, validates and routes it through the matching service, loads a consistent database snapshot of profiles, scores and orders counterparts, then returns explanations in the API response. Separate offline storage commands prepare and verify the Recruiter Bot database; the SQL Detective is an independent assignment capability using its own database and SQL answers. The graph reflects documented and indexed relationships; unsampled command and repository implementations are not described beyond those references.

Main entry points: [`backend/src/modules/matching/service.ts`](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/modules/matching/service.ts) (Matching service), [`backend/src/app.ts`](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/app.ts) (HTTP app), [`backend/src/db.ts`](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/db.ts) (Database lifecycle), [`backend/src/modules/matching/controller.ts`](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/modules/matching/controller.ts) (Request controllers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_app["HTTP app<br/>[app.ts]"]
  node_routes["Match routes<br/>[routes.ts]"]
  node_controller["Request controllers<br/>[controller.ts]"]
  node_errors["API errors<br/>[errors.ts]"]
  node_logger["Structured logging<br/>[logger.ts]"]
end

subgraph group_matching["Matching Domain"]
  node_service["Matching service<br/>[service.ts]"]
  node_candidate_repo["Candidate queries<br/>[repository.ts]"]
  node_job_repo["Job queries<br/>[repository.ts]"]
  node_policy["Scoring policy<br/>[policy.ts]"]
end

subgraph group_storage["Recruiter Bot Storage"]
  node_profiles["Assignment profiles<br/>[assignment.json]"]
  node_postgres[("PostgreSQL")]
  node_db["Database lifecycle<br/>[db.ts]"]
  node_config["Configuration<br/>[config.ts]"]
  node_lifecycle["Server lifecycle<br/>[lifecycle.ts]"]
  node_migration_tool["Migrations<br/>[migrations.ts]"]
  node_seed_tool["Fixture seeding<br/>[seed.ts]"]
  node_verify_tool["Storage verification<br/>[verify.ts]"]
  node_storage_fixture["Fixture validation<br/>[fixture.ts]"]
  node_storage_support["Storage support<br/>[support.ts]"]
end

subgraph group_detective["SQL Detective"]
  node_detective_cli["Detective CLI<br/>[cli.ts]"]
  node_detective_commands["Detective commands<br/>[commands.ts]"]
  node_detective_fixture["Detective fixture<br/>[fixture.ts]"]
  node_detective_support["Detective support<br/>[support.ts]"]
  node_detective_db[("Detective database")]
  node_detective_setup["Detective dataset<br/>[setup.sql]"]
  node_detective_answers["SQL answers<br/>[sql_detective.sql]"]
end

node_client(("API caller"))

node_client -->|"sends request"| node_app
node_app -->|"registers routes"| node_routes
node_routes -->|"dispatches"| node_controller
node_controller -->|"requests ranking"| node_service
node_controller -->|"reads version"| node_policy
node_controller -->|"raises errors"| node_errors
node_service -->|"loads candidates"| node_candidate_repo
node_service -->|"loads jobs"| node_job_repo
node_service -->|"ranks profiles"| node_policy
node_service -->|"validates profiles"| node_storage_fixture
node_service -->|"reads snapshot"| node_postgres
node_candidate_repo -->|"queries profiles"| node_postgres
node_job_repo -->|"queries profiles"| node_postgres
node_app -->|"logs requests"| node_logger
node_app -->|"checks readiness"| node_db
node_lifecycle -->|"creates server app"| node_app
node_lifecycle -->|"manages database"| node_db
node_db -->|"uses configuration"| node_config
node_db -->|"checks connection"| node_postgres
node_db -->|"checks permissions"| node_verify_tool
node_profiles -->|"validated as fixture"| node_storage_fixture
node_seed_tool -->|"loads fixture"| node_storage_fixture
node_seed_tool -->|"writes data"| node_postgres
node_migration_tool -->|"applies schema"| node_postgres
node_verify_tool -->|"checks stored data"| node_postgres
node_migration_tool -->|"uses transactions"| node_storage_support
node_seed_tool -->|"uses transactions"| node_storage_support
node_verify_tool -->|"compares fixture"| node_storage_fixture
node_detective_cli -->|"runs commands"| node_detective_commands
node_detective_commands -->|"uses database support"| node_detective_support
node_detective_commands -->|"uses fixture"| node_detective_fixture
node_detective_commands -->|"prepares dataset"| node_detective_db
node_detective_setup -->|"loads schema and rows"| node_detective_db
node_detective_answers -->|"queries dataset"| node_detective_db

click node_app "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/app.ts"
click node_routes "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/modules/matching/routes.ts"
click node_controller "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/modules/matching/controller.ts"
click node_errors "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/errors.ts"
click node_service "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/modules/matching/service.ts"
click node_candidate_repo "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/modules/candidates/repository.ts"
click node_job_repo "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/modules/jobs/repository.ts"
click node_policy "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/modules/matching/policy.ts"
click node_profiles "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/data/assignment.json"
click node_db "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/db.ts"
click node_config "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/config.ts"
click node_lifecycle "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/lifecycle.ts"
click node_migration_tool "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/storage/migrations.ts"
click node_seed_tool "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/storage/seed.ts"
click node_verify_tool "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/storage/verify.ts"
click node_storage_fixture "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/storage/fixture.ts"
click node_storage_support "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/storage/support.ts"
click node_detective_cli "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/detective/cli.ts"
click node_detective_commands "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/detective/commands.ts"
click node_detective_fixture "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/detective/fixture.ts"
click node_detective_support "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/detective/support.ts"
click node_detective_setup "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/sql/detective/setup.sql"
click node_detective_answers "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/sql_detective.sql"
click node_logger "https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/logger.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_routes,node_controller,node_errors,node_logger toneBlue
class node_service,node_candidate_repo,node_job_repo,node_policy toneAmber
class node_profiles,node_postgres,node_db,node_config,node_lifecycle,node_migration_tool,node_seed_tool,node_verify_tool,node_storage_fixture,node_storage_support,node_client toneMint
class node_detective_cli,node_detective_commands,node_detective_fixture,node_detective_support,node_detective_db,node_detective_setup,node_detective_answers toneRose
```

## Components

### HTTP API

- [HTTP app](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/app.ts): `backend/src/app.ts`
- [Match routes](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/modules/matching/routes.ts): `backend/src/modules/matching/routes.ts`
- [Request controllers](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/modules/matching/controller.ts): `backend/src/modules/matching/controller.ts`
- [API errors](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/errors.ts): `backend/src/errors.ts`
- [Structured logging](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/logger.ts): `backend/src/logger.ts`

### Matching Domain

- [Matching service](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/modules/matching/service.ts): `backend/src/modules/matching/service.ts`
- [Candidate queries](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/modules/candidates/repository.ts): `backend/src/modules/candidates/repository.ts`
- [Job queries](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/modules/jobs/repository.ts): `backend/src/modules/jobs/repository.ts`
- [Scoring policy](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/modules/matching/policy.ts): `backend/src/modules/matching/policy.ts`

### Recruiter Bot Storage

- [Assignment profiles](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/data/assignment.json): `backend/data/assignment.json`
- **PostgreSQL**
- [Database lifecycle](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/db.ts): `backend/src/db.ts`
- [Configuration](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/config.ts): `backend/src/config.ts`
- [Server lifecycle](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/lifecycle.ts): `backend/src/lifecycle.ts`
- [Migrations](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/storage/migrations.ts): `backend/src/storage/migrations.ts`
- [Fixture seeding](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/storage/seed.ts): `backend/src/storage/seed.ts`
- [Storage verification](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/storage/verify.ts): `backend/src/storage/verify.ts`
- [Fixture validation](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/storage/fixture.ts): `backend/src/storage/fixture.ts`
- [Storage support](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/storage/support.ts): `backend/src/storage/support.ts`

### SQL Detective

- [Detective CLI](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/detective/cli.ts): `backend/src/detective/cli.ts`
- [Detective commands](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/detective/commands.ts): `backend/src/detective/commands.ts`
- [Detective fixture](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/detective/fixture.ts): `backend/src/detective/fixture.ts`
- [Detective support](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/src/detective/support.ts): `backend/src/detective/support.ts`
- **Detective database**
- [Detective dataset](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/sql/detective/setup.sql): `backend/sql/detective/setup.sql`
- [SQL answers](https://github.com/hegdepunithramesh/recruiterflow-backend-assignment/blob/main/backend/sql_detective.sql): `backend/sql_detective.sql`

### Other components

- **API caller**

## Connections

- API caller → HTTP app: sends request (evidence: `README.md`)
- HTTP app → Match routes: registers routes (evidence: `backend/src/app.ts`)
- Match routes → Request controllers: dispatches (evidence: `backend/src/modules/matching/routes.ts`)
- Request controllers → Matching service: requests ranking (evidence: `backend/src/modules/matching/controller.ts`)
- Request controllers → Scoring policy: reads version (evidence: `backend/src/modules/matching/controller.ts`)
- Request controllers → API errors: raises errors (evidence: `backend/src/modules/matching/controller.ts`)
- Matching service → Candidate queries: loads candidates (evidence: `backend/src/modules/matching/service.ts`)
- Matching service → Job queries: loads jobs (evidence: `backend/src/modules/matching/service.ts`)
- Matching service → Scoring policy: ranks profiles (evidence: `backend/src/modules/matching/service.ts`)
- Matching service → Fixture validation: validates profiles (evidence: `backend/src/modules/matching/service.ts`)
- Matching service → PostgreSQL: reads snapshot (evidence: `README.md`)
- Candidate queries → PostgreSQL: queries profiles (evidence: `README.md`)
- Job queries → PostgreSQL: queries profiles (evidence: `README.md`)
- HTTP app → Structured logging: logs requests (evidence: `backend/src/app.ts`)
- HTTP app → Database lifecycle: checks readiness (evidence: `backend/src/app.ts`)
- Server lifecycle → HTTP app: creates server app (evidence: `backend/src/lifecycle.ts`)
- Server lifecycle → Database lifecycle: manages database (evidence: `backend/src/lifecycle.ts`)
- Database lifecycle → Configuration: uses configuration (evidence: `backend/src/db.ts`)
- Database lifecycle → PostgreSQL: checks connection (evidence: `backend/src/db.ts`)
- Database lifecycle → Storage verification: checks permissions (evidence: `backend/src/db.ts`)
- Assignment profiles → Fixture validation: validated as fixture (evidence: `backend/src/storage/fixture.ts`)
- Fixture seeding → Fixture validation: loads fixture (evidence: `backend/src/storage/seed.ts`)
- Fixture seeding → PostgreSQL: writes data (evidence: `README.md`)
- Migrations → PostgreSQL: applies schema (evidence: `README.md`)
- Storage verification → PostgreSQL: checks stored data (evidence: `backend/src/storage/verify.ts`)
- Migrations → Storage support: uses transactions (evidence: `backend/src/storage/migrations.ts`)
- Fixture seeding → Storage support: uses transactions (evidence: `backend/src/storage/seed.ts`)
- Storage verification → Fixture validation: compares fixture (evidence: `backend/src/storage/verify.ts`)
- Detective CLI → Detective commands: runs commands (evidence: `backend/src/detective/cli.ts`)
- Detective commands → Detective support: uses database support (evidence: `backend/src/detective/commands.ts`)
- Detective commands → Detective fixture: uses fixture (evidence: `backend/src/detective/commands.ts`)
- Detective commands → Detective database: prepares dataset (evidence: `README.md`)
- Detective dataset → Detective database: loads schema and rows (evidence: `README.md`)
- SQL answers → Detective database: queries dataset (evidence: `README.md`)
