# chaitanyadurgeshweb/irldb architecture

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

- Interactive diagram: https://gitdiagram.com/chaitanyadurgeshweb/irldb
- Repository: https://github.com/chaitanyadurgeshweb/irldb

## Overview

Loco Portal is a Next.js reference portal for Indian Railways locomotives. Users can search by locomotive number or filters, browse classes, and follow listings into locomotive, shed, zone, and manufacturer records. Pages query Supabase through a shared data-access module; search results are fetched and displayed by a shared listing component with table and pagination views. The README identifies Supabase as the backend and the repository includes schema and seed files. Some detail routes and informational pages were not excerpted, so their connections are limited to SOURCE INDEX references.

Main entry points: [`lib/db.ts`](https://github.com/chaitanyadurgeshweb/irldb/blob/main/lib/db.ts) (Data queries), [`components/ListedLocos.tsx`](https://github.com/chaitanyadurgeshweb/irldb/blob/main/components/ListedLocos.tsx) (Listed locomotives), [`app/page.tsx`](https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/page.tsx) (Home), [`app/search/page.tsx`](https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/search/page.tsx) (Search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discovery["Discovery"]
  node_home["Home<br/>[page.tsx]"]
  node_search["Search<br/>[page.tsx]"]
end

subgraph group_catalog["Catalog browsing"]
  node_class_index["Class index<br/>[page.tsx]"]
  node_class_detail["Class detail<br/>[page.tsx]"]
  node_loco_detail["Locomotive detail<br/>[page.tsx]"]
  node_shed_index["Shed index<br/>[page.tsx]"]
  node_shed_detail["Shed detail<br/>[page.tsx]"]
  node_zone_index["Zone index<br/>[page.tsx]"]
  node_zone_detail["Zone detail<br/>[page.tsx]"]
  node_manufacturer_index["Manufacturer index<br/>[page.tsx]"]
  node_manufacturer_detail["Manufacturer detail<br/>[page.tsx]"]
  node_sources["Sources page<br/>[page.tsx]"]
end

subgraph group_views["Result views"]
  node_listed_locos["Listed locomotives<br/>[ListedLocos.tsx]"]
  node_loco_table["Locomotive table<br/>[LocoTable.tsx]"]
  node_pager["Pagination<br/>[Pager.tsx]"]
end

subgraph group_data["Data access"]
  node_db_access["Data queries<br/>[db.ts]"]
  node_supabase[("Supabase")]
end

node_visitor(("Portal visitor"))

node_visitor -->|"opens"| node_home
node_visitor -->|"searches"| node_search
node_visitor -->|"browses"| node_class_index
node_home -->|"loads options"| node_db_access
node_home -->|"counts locomotives"| node_db_access
node_search -->|"loads matches"| node_db_access
node_search -->|"renders results"| node_listed_locos
node_class_index -->|"loads classes"| node_db_access
node_class_detail -->|"loads class"| node_db_access
node_class_detail -->|"renders members"| node_listed_locos
node_loco_detail -->|"loads locomotive"| node_db_access
node_shed_index -->|"loads sheds"| node_db_access
node_shed_detail -->|"loads shed"| node_db_access
node_shed_detail -->|"renders members"| node_listed_locos
node_zone_index -->|"loads zones"| node_db_access
node_zone_detail -->|"loads zone"| node_db_access
node_zone_detail -->|"renders members"| node_listed_locos
node_manufacturer_index -->|"loads manufacturers"| node_db_access
node_manufacturer_detail -->|"loads manufacturer"| node_db_access
node_manufacturer_detail -->|"renders members"| node_listed_locos
node_listed_locos -->|"searches locomotives"| node_db_access
node_listed_locos -->|"renders pagination"| node_pager
node_listed_locos -->|"renders rows"| node_loco_table
node_db_access -->|"queries"| node_supabase

click node_home "https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/page.tsx"
click node_search "https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/search/page.tsx"
click node_class_index "https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/locomotives/page.tsx"
click node_class_detail "https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/locomotives/%5Bslug%5D/page.tsx"
click node_loco_detail "https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/locos/%5Bnumber%5D/page.tsx"
click node_shed_index "https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/sheds/page.tsx"
click node_shed_detail "https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/sheds/%5Bcode%5D/page.tsx"
click node_zone_index "https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/zones/page.tsx"
click node_zone_detail "https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/zones/%5Bcode%5D/page.tsx"
click node_manufacturer_index "https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/manufacturers/page.tsx"
click node_manufacturer_detail "https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/manufacturers/%5Bcode%5D/page.tsx"
click node_sources "https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/sources/page.tsx"
click node_listed_locos "https://github.com/chaitanyadurgeshweb/irldb/blob/main/components/ListedLocos.tsx"
click node_loco_table "https://github.com/chaitanyadurgeshweb/irldb/blob/main/components/LocoTable.tsx"
click node_pager "https://github.com/chaitanyadurgeshweb/irldb/blob/main/components/Pager.tsx"
click node_db_access "https://github.com/chaitanyadurgeshweb/irldb/blob/main/lib/db.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_home,node_search toneBlue
class node_class_index,node_class_detail,node_loco_detail,node_shed_index,node_shed_detail,node_zone_index,node_zone_detail,node_manufacturer_index,node_manufacturer_detail,node_sources toneAmber
class node_listed_locos,node_loco_table,node_pager toneMint
class node_db_access,node_supabase toneRose
class node_visitor toneIndigo
```

## Components

### Discovery

- [Home](https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/page.tsx): `app/page.tsx`
- [Search](https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/search/page.tsx): `app/search/page.tsx`

### Catalog browsing

- [Class index](https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/locomotives/page.tsx): `app/locomotives/page.tsx`
- [Class detail](https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/locomotives/%5Bslug%5D/page.tsx): `app/locomotives/[slug]/page.tsx`
- [Locomotive detail](https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/locos/%5Bnumber%5D/page.tsx): `app/locos/[number]/page.tsx`
- [Shed index](https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/sheds/page.tsx): `app/sheds/page.tsx`
- [Shed detail](https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/sheds/%5Bcode%5D/page.tsx): `app/sheds/[code]/page.tsx`
- [Zone index](https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/zones/page.tsx): `app/zones/page.tsx`
- [Zone detail](https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/zones/%5Bcode%5D/page.tsx): `app/zones/[code]/page.tsx`
- [Manufacturer index](https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/manufacturers/page.tsx): `app/manufacturers/page.tsx`
- [Manufacturer detail](https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/manufacturers/%5Bcode%5D/page.tsx): `app/manufacturers/[code]/page.tsx`
- [Sources page](https://github.com/chaitanyadurgeshweb/irldb/blob/main/app/sources/page.tsx): `app/sources/page.tsx`

### Result views

- [Listed locomotives](https://github.com/chaitanyadurgeshweb/irldb/blob/main/components/ListedLocos.tsx): `components/ListedLocos.tsx`
- [Locomotive table](https://github.com/chaitanyadurgeshweb/irldb/blob/main/components/LocoTable.tsx): `components/LocoTable.tsx`
- [Pagination](https://github.com/chaitanyadurgeshweb/irldb/blob/main/components/Pager.tsx): `components/Pager.tsx`

### Data access

- [Data queries](https://github.com/chaitanyadurgeshweb/irldb/blob/main/lib/db.ts): `lib/db.ts`
- **Supabase**

### Other components

- **Portal visitor**

## Connections

- Portal visitor → Home: opens (evidence: `README.md`)
- Portal visitor → Search: searches (evidence: `README.md`)
- Portal visitor → Class index: browses (evidence: `README.md`)
- Home → Data queries: loads options (evidence: `app/page.tsx`)
- Home → Data queries: counts locomotives (evidence: `app/page.tsx`)
- Search → Data queries: loads matches (evidence: `app/search/page.tsx`)
- Search → Listed locomotives: renders results (evidence: `app/search/page.tsx`)
- Class index → Data queries: loads classes (evidence: `app/locomotives/page.tsx`)
- Class detail → Data queries: loads class (evidence: `app/locomotives/[slug]/page.tsx`)
- Class detail → Listed locomotives: renders members (evidence: `app/locomotives/[slug]/page.tsx`)
- Locomotive detail → Data queries: loads locomotive (evidence: `app/locos/[number]/page.tsx`)
- Shed index → Data queries: loads sheds (evidence: `app/sheds/page.tsx`)
- Shed detail → Data queries: loads shed (evidence: `app/sheds/[code]/page.tsx`)
- Shed detail → Listed locomotives: renders members (evidence: `app/sheds/[code]/page.tsx`)
- Zone index → Data queries: loads zones (evidence: `app/zones/page.tsx`)
- Zone detail → Data queries: loads zone (evidence: `app/zones/[code]/page.tsx`)
- Zone detail → Listed locomotives: renders members (evidence: `app/zones/[code]/page.tsx`)
- Manufacturer index → Data queries: loads manufacturers (evidence: `app/manufacturers/page.tsx`)
- Manufacturer detail → Data queries: loads manufacturer (evidence: `app/manufacturers/[code]/page.tsx`)
- Manufacturer detail → Listed locomotives: renders members (evidence: `app/manufacturers/[code]/page.tsx`)
- Listed locomotives → Data queries: searches locomotives (evidence: `components/ListedLocos.tsx`)
- Listed locomotives → Pagination: renders pagination (evidence: `components/ListedLocos.tsx`)
- Listed locomotives → Locomotive table: renders rows (evidence: `components/ListedLocos.tsx`)
- Data queries → Supabase: queries (evidence: `README.md`)
