# nuwan516/lanka-offers-admin-api architecture

> Architecture diagram of the GitHub repository nuwan516/lanka-offers-admin-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nuwan516/lanka-offers-admin-api
- Repository: https://github.com/nuwan516/lanka-offers-admin-api

## Overview

This is a private admin control plane and bank-offer ingestion engine. The main workflow runs bank scrapers, parses and normalizes source evidence, validates and stages offers, then lets an operator review and publish approved changes to Neon for public readers. Separate capabilities cover geospatial verification, scheduled scraping, parser-rule administration, and consumer-engagement settings. The graph follows documented workflow and sampled call relationships; several subsystem internals were not sampled, so their internal links are omitted.

Main entry points: [`src/api/server.ts`](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/api/server.ts) (Admin API), [`src/banks`](https://github.com/nuwan516/lanka-offers-admin-api/tree/main/src/banks) (Bank parsers), [`src/infrastructure/db/db-client.ts`](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/infrastructure/db/db-client.ts) (Neon database), [`src/api/register-admin-routes.ts`](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/api/register-admin-routes.ts) (Admin routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Control plane"]
  node_admin_api["Admin API<br/>[server.ts]"]
  node_admin_routes["Admin routes"]
  node_job_manager["Scrape jobs"]
  node_scheduler["Scrape scheduler"]
  node_engagement["Consumer engagement"]
end

subgraph group_ingestion["Scraping and parsing"]
  node_bank_runner["Bank runner<br/>[runner.ts]"]
  node_bank_adapters["Bank adapters"]
  node_bank_parsers["Bank parsers"]
  node_parser_rules["Parser rules"]
  node_period_parser["Period parsing<br/>[period-engine.ts]"]
  node_address_parser["Address parsing<br/>[address-engine.ts]"]
end

subgraph group_assessment["Validation and enrichment"]
  node_validation_pipeline["Validation pipeline"]
  node_rule_validator["Offer validator<br/>[offer-validator.ts]"]
  node_llm_validator["LLM validation<br/>[llm-validator.ts]"]
  node_offer_orchestrator["Offer orchestration"]
  node_geo_engine["Geo resolution<br/>[geo-engine.ts]"]
end

subgraph group_review["Review and publication"]
  node_review_routes["Offer review<br/>[offers.routes.ts]"]
  node_workflow_repository["Review workflow"]
end

subgraph group_platform["Persistence and integrations"]
  node_offer_repository["Offer storage"]
  node_database[("Neon database<br/>[db-client.ts]")]
  node_geo_services["Geo services"]
end

node_operator(("Operator"))
node_public_readers(("Public API readers"))

node_operator -->|"operates"| node_admin_api
node_admin_api -->|"registers"| node_admin_routes
node_admin_api -->|"starts"| node_job_manager
node_admin_api -->|"starts"| node_scheduler
node_admin_routes -->|"registers"| node_review_routes
node_job_manager -->|"uses"| node_database
node_bank_runner -.->|"runs"| node_bank_adapters
node_bank_adapters -->|"parse sources"| node_bank_parsers
node_bank_parsers -->|"loads rules"| node_parser_rules
node_bank_parsers -->|"parses periods"| node_period_parser
node_bank_parsers -->|"parses addresses"| node_address_parser
node_validation_pipeline -->|"validates"| node_rule_validator
node_validation_pipeline -->|"delegates"| node_offer_orchestrator
node_offer_orchestrator -.->|"optional validation"| node_llm_validator
node_offer_orchestrator -.->|"resolves location"| node_geo_engine
node_review_routes -->|"reviews offers"| node_workflow_repository
node_review_routes -->|"queries offers"| node_offer_repository
node_workflow_repository -->|"loads offers"| node_offer_repository
node_offer_repository -->|"reads and writes"| node_database
node_workflow_repository -->|"persists workflow"| node_database
node_public_readers -->|"reads published offers"| node_database
node_admin_routes -->|"registers routes"| node_engagement
node_geo_engine -->|"geocodes"| node_geo_services

click node_admin_api "https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/api/server.ts"
click node_admin_routes "https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/api/register-admin-routes.ts"
click node_job_manager "https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/api/services/job-manager.service.ts"
click node_scheduler "https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/api/services/scraper-scheduler.service.ts"
click node_bank_runner "https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/banks/runner.ts"
click node_bank_adapters "https://github.com/nuwan516/lanka-offers-admin-api/tree/main/src/banks"
click node_bank_parsers "https://github.com/nuwan516/lanka-offers-admin-api/tree/main/src/banks"
click node_parser_rules "https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/banks/bank-rules-loader.ts"
click node_period_parser "https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/parsing/period/period-engine.ts"
click node_address_parser "https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/parsing/address/address-engine.ts"
click node_validation_pipeline "https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/api/services/validation-pipeline.service.ts"
click node_rule_validator "https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/validation/offer-validator.ts"
click node_llm_validator "https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/infrastructure/llm/llm-validator.ts"
click node_offer_orchestrator "https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/api/services/unified-offer-orchestrator.service.ts"
click node_geo_engine "https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/geo/geo-engine.ts"
click node_review_routes "https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/api/routes/offers.routes.ts"
click node_workflow_repository "https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/infrastructure/db/offer-workflow-repository.ts"
click node_offer_repository "https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/infrastructure/db/offer-repository.ts"
click node_database "https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/infrastructure/db/db-client.ts"
click node_engagement "https://github.com/nuwan516/lanka-offers-admin-api/tree/main/src/api/routes"
click node_geo_services "https://github.com/nuwan516/lanka-offers-admin-api/tree/main/src/infrastructure/geo"

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_admin_api,node_admin_routes,node_job_manager,node_scheduler,node_engagement toneBlue
class node_bank_runner,node_bank_adapters,node_bank_parsers,node_parser_rules,node_period_parser,node_address_parser toneAmber
class node_validation_pipeline,node_rule_validator,node_llm_validator,node_offer_orchestrator,node_geo_engine,node_public_readers toneMint
class node_review_routes,node_workflow_repository toneRose
class node_offer_repository,node_database,node_geo_services,node_operator toneIndigo
```

## Components

### Control plane

- [Admin API](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/api/server.ts): `src/api/server.ts`
- [Admin routes](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/api/register-admin-routes.ts): `src/api/register-admin-routes.ts`
- [Scrape jobs](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/api/services/job-manager.service.ts): `src/api/services/job-manager.service.ts`
- [Scrape scheduler](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/api/services/scraper-scheduler.service.ts): `src/api/services/scraper-scheduler.service.ts`
- [Consumer engagement](https://github.com/nuwan516/lanka-offers-admin-api/tree/main/src/api/routes): `src/api/routes`

### Scraping and parsing

- [Bank runner](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/banks/runner.ts): `src/banks/runner.ts`
- [Bank adapters](https://github.com/nuwan516/lanka-offers-admin-api/tree/main/src/banks): `src/banks`
- [Bank parsers](https://github.com/nuwan516/lanka-offers-admin-api/tree/main/src/banks): `src/banks`
- [Parser rules](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/banks/bank-rules-loader.ts): `src/banks/bank-rules-loader.ts`
- [Period parsing](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/parsing/period/period-engine.ts): `src/parsing/period/period-engine.ts`
- [Address parsing](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/parsing/address/address-engine.ts): `src/parsing/address/address-engine.ts`

### Validation and enrichment

- [Validation pipeline](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/api/services/validation-pipeline.service.ts): `src/api/services/validation-pipeline.service.ts`
- [Offer validator](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/validation/offer-validator.ts): `src/validation/offer-validator.ts`
- [LLM validation](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/infrastructure/llm/llm-validator.ts): `src/infrastructure/llm/llm-validator.ts`
- [Offer orchestration](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/api/services/unified-offer-orchestrator.service.ts): `src/api/services/unified-offer-orchestrator.service.ts`
- [Geo resolution](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/geo/geo-engine.ts): `src/geo/geo-engine.ts`

### Review and publication

- [Offer review](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/api/routes/offers.routes.ts): `src/api/routes/offers.routes.ts`
- [Review workflow](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/infrastructure/db/offer-workflow-repository.ts): `src/infrastructure/db/offer-workflow-repository.ts`

### Persistence and integrations

- [Offer storage](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/infrastructure/db/offer-repository.ts): `src/infrastructure/db/offer-repository.ts`
- [Neon database](https://github.com/nuwan516/lanka-offers-admin-api/blob/main/src/infrastructure/db/db-client.ts): `src/infrastructure/db/db-client.ts`
- [Geo services](https://github.com/nuwan516/lanka-offers-admin-api/tree/main/src/infrastructure/geo): `src/infrastructure/geo`

### Other components

- **Operator**
- **Public API readers**

## Connections

- Operator → Admin API: operates (evidence: `README.md`)
- Admin API → Admin routes: registers (evidence: `src/api/server.ts`)
- Admin API → Scrape jobs: starts (evidence: `src/api/server.ts`)
- Admin API → Scrape scheduler: starts (evidence: `src/api/server.ts`)
- Admin routes → Offer review: registers (evidence: `src/api/register-admin-routes.ts`)
- Scrape jobs → Neon database: uses (evidence: `src/api/services/job-manager.service.ts`)
- Bank runner → Bank adapters: runs
- Bank adapters → Bank parsers: parse sources (evidence: `README.md`)
- Bank parsers → Parser rules: loads rules (evidence: `src/banks/combank/combank-parser.ts`)
- Bank parsers → Period parsing: parses periods (evidence: `src/banks/combank/combank-parser.ts`)
- Bank parsers → Address parsing: parses addresses (evidence: `src/banks/combank/combank-parser.ts`)
- Validation pipeline → Offer validator: validates (evidence: `src/api/services/validation-pipeline.service.ts`)
- Validation pipeline → Offer orchestration: delegates (evidence: `src/api/services/validation-pipeline.service.ts`)
- Offer orchestration → LLM validation: optional validation
- Offer orchestration → Geo resolution: resolves location
- Offer review → Review workflow: reviews offers (evidence: `src/api/routes/offers.routes.ts`)
- Offer review → Offer storage: queries offers (evidence: `src/api/routes/offers.routes.ts`)
- Review workflow → Offer storage: loads offers (evidence: `src/infrastructure/db/offer-workflow-repository.ts`)
- Offer storage → Neon database: reads and writes (evidence: `src/infrastructure/db/offer-repository.ts`)
- Review workflow → Neon database: persists workflow (evidence: `src/infrastructure/db/offer-workflow-repository.ts`)
- Public API readers → Neon database: reads published offers (evidence: `README.md`)
- Admin routes → Consumer engagement: registers routes (evidence: `src/api/register-admin-routes.ts`)
- Geo resolution → Geo services: geocodes (evidence: `src/geo/geo-engine.ts`)
