# sakina1303/nnomm-claims architecture

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

- Interactive diagram: https://gitdiagram.com/sakina1303/nnomm-claims
- Repository: https://github.com/sakina1303/nnomm-claims

## Overview

Nnomm is a PostgreSQL-backed flash-deal and claim API. Customers and restaurant admins authenticate to browse deals, create deals, and reserve limited stock; claims are idempotent and expire, while authenticated payment events update claim state. A periodic sweep also expires overdue claims. The excerpts place these responsibilities together in Main.kt, so the graph separates them by role but reuses that exact path. Route details beyond the sampled handlers and the migration wiring rely on README documentation.

Main entry points: [`src/main/kotlin/com/nnomm/Main.kt`](https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt) (HTTP routes), [`src/main/resources/db/migration/V1__init.sql`](https://github.com/sakina1303/nnomm-claims/blob/main/src/main/resources/db/migration/V1__init.sql) (Database schema)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and identity"]
  node_router["HTTP routes<br/>[Main.kt]"]
  node_auth["JWT authentication<br/>[Main.kt]"]
  node_validation["Request validation<br/>[Main.kt]"]
end

subgraph group_deals["Deals and claims"]
  node_deal_ops["Deal operations<br/>[Main.kt]"]
  node_claim_ops["Claim operations<br/>[Main.kt]"]
  node_idempotency["Idempotency records<br/>[Main.kt]"]
end

subgraph group_payments["Payment and expiry"]
  node_webhook["Payment webhook<br/>[Main.kt]"]
  node_expiry["Expiry sweep<br/>[Main.kt]"]
end

subgraph group_storage["Persistence"]
  node_pool["Connection pool<br/>[Main.kt]"]
  node_schema["Database schema<br/>[V1__init.sql]"]
  node_postgres[("PostgreSQL")]
end

node_customer(("Customer"))
node_admin(("Restaurant admin"))
node_provider(("Payment provider"))

node_customer -->|"calls API"| node_router
node_admin -->|"calls API"| node_router
node_provider -->|"sends events"| node_webhook
node_router -->|"authenticates"| node_auth
node_router -->|"parses requests"| node_validation
node_router -->|"routes deal calls"| node_deal_ops
node_router -->|"routes claims"| node_claim_ops
node_router -->|"routes events"| node_webhook
node_deal_ops -->|"runs transactions"| node_pool
node_claim_ops -->|"records responses"| node_idempotency
node_claim_ops -->|"locks and updates"| node_pool
node_webhook -->|"updates claim state"| node_pool
node_expiry -->|"expires claims"| node_claim_ops
node_expiry -->|"sweeps reservations"| node_pool
node_pool -->|"reads and writes"| node_postgres
node_schema -->|"defines tables"| node_postgres
node_router -->|"runs migration"| node_schema

click node_router "https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt"
click node_auth "https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt"
click node_validation "https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt"
click node_deal_ops "https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt"
click node_claim_ops "https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt"
click node_idempotency "https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt"
click node_webhook "https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt"
click node_expiry "https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt"
click node_pool "https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt"
click node_schema "https://github.com/sakina1303/nnomm-claims/blob/main/src/main/resources/db/migration/V1__init.sql"

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_router,node_auth,node_validation toneBlue
class node_deal_ops,node_claim_ops,node_idempotency toneAmber
class node_webhook,node_expiry toneMint
class node_pool,node_schema,node_postgres toneRose
class node_customer,node_admin,node_provider toneIndigo
```

## Components

### API and identity

- [HTTP routes](https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt): `src/main/kotlin/com/nnomm/Main.kt`
- [JWT authentication](https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt): `src/main/kotlin/com/nnomm/Main.kt`
- [Request validation](https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt): `src/main/kotlin/com/nnomm/Main.kt`

### Deals and claims

- [Deal operations](https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt): `src/main/kotlin/com/nnomm/Main.kt`
- [Claim operations](https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt): `src/main/kotlin/com/nnomm/Main.kt`
- [Idempotency records](https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt): `src/main/kotlin/com/nnomm/Main.kt`

### Payment and expiry

- [Payment webhook](https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt): `src/main/kotlin/com/nnomm/Main.kt`
- [Expiry sweep](https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt): `src/main/kotlin/com/nnomm/Main.kt`

### Persistence

- [Connection pool](https://github.com/sakina1303/nnomm-claims/blob/main/src/main/kotlin/com/nnomm/Main.kt): `src/main/kotlin/com/nnomm/Main.kt`
- [Database schema](https://github.com/sakina1303/nnomm-claims/blob/main/src/main/resources/db/migration/V1__init.sql): `src/main/resources/db/migration/V1__init.sql`
- **PostgreSQL**

### Other components

- **Customer**
- **Restaurant admin**
- **Payment provider**

## Connections

- Customer → HTTP routes: calls API (evidence: `README.md`)
- Restaurant admin → HTTP routes: calls API (evidence: `README.md`)
- Payment provider → Payment webhook: sends events (evidence: `README.md`)
- HTTP routes → JWT authentication: authenticates (evidence: `src/main/kotlin/com/nnomm/Main.kt`)
- HTTP routes → Request validation: parses requests (evidence: `src/main/kotlin/com/nnomm/Main.kt`)
- HTTP routes → Deal operations: routes deal calls (evidence: `src/main/kotlin/com/nnomm/Main.kt`)
- HTTP routes → Claim operations: routes claims (evidence: `src/main/kotlin/com/nnomm/Main.kt`)
- HTTP routes → Payment webhook: routes events (evidence: `README.md`)
- Deal operations → Connection pool: runs transactions (evidence: `src/main/kotlin/com/nnomm/Main.kt`)
- Claim operations → Idempotency records: records responses (evidence: `src/main/kotlin/com/nnomm/Main.kt`)
- Claim operations → Connection pool: locks and updates (evidence: `src/main/kotlin/com/nnomm/Main.kt`)
- Payment webhook → Connection pool: updates claim state (evidence: `src/main/kotlin/com/nnomm/Main.kt`)
- Expiry sweep → Claim operations: expires claims (evidence: `README.md`)
- Expiry sweep → Connection pool: sweeps reservations (evidence: `README.md`)
- Connection pool → PostgreSQL: reads and writes (evidence: `src/main/kotlin/com/nnomm/Main.kt`)
- Database schema → PostgreSQL: defines tables (evidence: `README.md`)
- HTTP routes → Database schema: runs migration (evidence: `README.md`)
