# chaitanyadurgeshweb/locod architecture

> Architecture diagram of the GitHub repository chaitanyadurgeshweb/locod, 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/locod
- Repository: https://github.com/chaitanyadurgeshweb/locod

## Overview

Loco Portal is a Next.js reference site for Indian Railways locomotives. Users can browse classes and organizational categories, search and filter locomotive records, then follow results to locomotive or category details. The runtime data path is page handlers through a Supabase client; shared listing logic performs paginated queries and renders tables. The README also documents Supabase schema and seed files. Some category detail and informational pages were not excerpted, so their internal behavior and links are shown only where documented or indexed.

Main entry points: [`lib/db.ts`](https://github.com/chaitanyadurgeshweb/locod/blob/main/lib/db.ts) (Query layer), [`components/ListedLocos.tsx`](https://github.com/chaitanyadurgeshweb/locod/blob/main/components/ListedLocos.tsx) (Filtered listings), [`app/search/page.tsx`](https://github.com/chaitanyadurgeshweb/locod/blob/main/app/search/page.tsx) (Search), [`app/locomotives/[slug]/page.tsx`](https://github.com/chaitanyadurgeshweb/locod/blob/main/app/locomotives/%5Bslug%5D/page.tsx) (Class detail)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browse["Browse reference"]
  node_home["Home<br/>[page.tsx]"]
  node_class_index["Class index<br/>[page.tsx]"]
  node_class_detail["Class detail<br/>[page.tsx]"]
  node_loco_detail["Loco detail<br/>[page.tsx]"]
  node_shed_pages["Shed pages"]
  node_zone_pages["Zone pages"]
  node_manufacturer_pages["Manufacturer pages"]
end

subgraph group_search["Search and listings"]
  node_search_page["Search<br/>[page.tsx]"]
  node_listed_locos["Filtered listings<br/>[ListedLocos.tsx]"]
  node_loco_table["Loco table<br/>[LocoTable.tsx]"]
  node_pager["Pagination<br/>[Pager.tsx]"]
end

subgraph group_data["Data access"]
  node_db_client["Query layer<br/>[db.ts]"]
  node_supabase[("Supabase database")]
  node_schema["Database schema<br/>[0001_schema.sql]"]
end

subgraph group_info["Information"]
  node_about["About<br/>[page.tsx]"]
  node_sources["Sources<br/>[page.tsx]"]
end

node_visitor(("Site visitor"))

node_visitor -->|"opens"| node_home
node_visitor -->|"searches"| node_search_page
node_home -->|"loads options and count"| node_db_client
node_class_index -->|"queries classes"| node_db_client
node_class_detail -->|"loads class"| node_db_client
node_class_detail -->|"requests class listings"| node_listed_locos
node_loco_detail -->|"queries locomotive"| node_db_client
node_shed_pages -->|"queries shed data"| node_db_client
node_zone_pages -->|"queries zone data"| node_db_client
node_manufacturer_pages -->|"queries manufacturer data"| node_db_client
node_search_page -->|"loads options and text matches"| node_db_client
node_search_page -->|"requests filtered results"| node_listed_locos
node_listed_locos -->|"searches locomotives"| node_db_client
node_listed_locos -->|"renders rows"| node_loco_table
node_listed_locos -->|"renders pagination"| node_pager
node_db_client -->|"queries"| node_supabase
node_schema -.->|"defines schema for"| node_supabase

click node_home "https://github.com/chaitanyadurgeshweb/locod/blob/main/app/page.tsx"
click node_class_index "https://github.com/chaitanyadurgeshweb/locod/blob/main/app/locomotives/page.tsx"
click node_class_detail "https://github.com/chaitanyadurgeshweb/locod/blob/main/app/locomotives/%5Bslug%5D/page.tsx"
click node_loco_detail "https://github.com/chaitanyadurgeshweb/locod/blob/main/app/locos/%5Bnumber%5D/page.tsx"
click node_shed_pages "https://github.com/chaitanyadurgeshweb/locod/tree/main/app/sheds"
click node_zone_pages "https://github.com/chaitanyadurgeshweb/locod/tree/main/app/zones"
click node_manufacturer_pages "https://github.com/chaitanyadurgeshweb/locod/tree/main/app/manufacturers"
click node_search_page "https://github.com/chaitanyadurgeshweb/locod/blob/main/app/search/page.tsx"
click node_listed_locos "https://github.com/chaitanyadurgeshweb/locod/blob/main/components/ListedLocos.tsx"
click node_loco_table "https://github.com/chaitanyadurgeshweb/locod/blob/main/components/LocoTable.tsx"
click node_pager "https://github.com/chaitanyadurgeshweb/locod/blob/main/components/Pager.tsx"
click node_db_client "https://github.com/chaitanyadurgeshweb/locod/blob/main/lib/db.ts"
click node_schema "https://github.com/chaitanyadurgeshweb/locod/blob/main/supabase/migrations/0001_schema.sql"
click node_about "https://github.com/chaitanyadurgeshweb/locod/blob/main/app/about/page.tsx"
click node_sources "https://github.com/chaitanyadurgeshweb/locod/blob/main/app/sources/page.tsx"

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_class_index,node_class_detail,node_loco_detail,node_shed_pages,node_zone_pages,node_manufacturer_pages toneBlue
class node_search_page,node_listed_locos,node_loco_table,node_pager toneAmber
class node_db_client,node_supabase,node_schema toneMint
class node_about,node_sources toneRose
class node_visitor toneIndigo
```

## Components

### Browse reference

- [Home](https://github.com/chaitanyadurgeshweb/locod/blob/main/app/page.tsx): `app/page.tsx`
- [Class index](https://github.com/chaitanyadurgeshweb/locod/blob/main/app/locomotives/page.tsx): `app/locomotives/page.tsx`
- [Class detail](https://github.com/chaitanyadurgeshweb/locod/blob/main/app/locomotives/%5Bslug%5D/page.tsx): `app/locomotives/[slug]/page.tsx`
- [Loco detail](https://github.com/chaitanyadurgeshweb/locod/blob/main/app/locos/%5Bnumber%5D/page.tsx): `app/locos/[number]/page.tsx`
- [Shed pages](https://github.com/chaitanyadurgeshweb/locod/tree/main/app/sheds): `app/sheds`
- [Zone pages](https://github.com/chaitanyadurgeshweb/locod/tree/main/app/zones): `app/zones`
- [Manufacturer pages](https://github.com/chaitanyadurgeshweb/locod/tree/main/app/manufacturers): `app/manufacturers`

### Search and listings

- [Search](https://github.com/chaitanyadurgeshweb/locod/blob/main/app/search/page.tsx): `app/search/page.tsx`
- [Filtered listings](https://github.com/chaitanyadurgeshweb/locod/blob/main/components/ListedLocos.tsx): `components/ListedLocos.tsx`
- [Loco table](https://github.com/chaitanyadurgeshweb/locod/blob/main/components/LocoTable.tsx): `components/LocoTable.tsx`
- [Pagination](https://github.com/chaitanyadurgeshweb/locod/blob/main/components/Pager.tsx): `components/Pager.tsx`

### Data access

- [Query layer](https://github.com/chaitanyadurgeshweb/locod/blob/main/lib/db.ts): `lib/db.ts`
- **Supabase database**
- [Database schema](https://github.com/chaitanyadurgeshweb/locod/blob/main/supabase/migrations/0001_schema.sql): `supabase/migrations/0001_schema.sql`

### Information

- [About](https://github.com/chaitanyadurgeshweb/locod/blob/main/app/about/page.tsx): `app/about/page.tsx`
- [Sources](https://github.com/chaitanyadurgeshweb/locod/blob/main/app/sources/page.tsx): `app/sources/page.tsx`

### Other components

- **Site visitor**

## Connections

- Site visitor → Home: opens (evidence: `app/page.tsx`)
- Site visitor → Search: searches (evidence: `app/search/page.tsx`)
- Home → Query layer: loads options and count (evidence: `app/page.tsx`)
- Class index → Query layer: queries classes (evidence: `app/locomotives/page.tsx`)
- Class detail → Query layer: loads class (evidence: `app/locomotives/[slug]/page.tsx`)
- Class detail → Filtered listings: requests class listings (evidence: `app/locomotives/[slug]/page.tsx`)
- Loco detail → Query layer: queries locomotive (evidence: `app/locos/[number]/page.tsx`)
- Shed pages → Query layer: queries shed data (evidence: `app/sheds/page.tsx`)
- Zone pages → Query layer: queries zone data (evidence: `app/zones/page.tsx`)
- Manufacturer pages → Query layer: queries manufacturer data (evidence: `app/manufacturers/page.tsx`)
- Search → Query layer: loads options and text matches (evidence: `app/search/page.tsx`)
- Search → Filtered listings: requests filtered results (evidence: `app/search/page.tsx`)
- Filtered listings → Query layer: searches locomotives (evidence: `components/ListedLocos.tsx`)
- Filtered listings → Loco table: renders rows (evidence: `components/ListedLocos.tsx`)
- Filtered listings → Pagination: renders pagination (evidence: `components/ListedLocos.tsx`)
- Query layer → Supabase database: queries (evidence: `lib/db.ts`)
- Database schema → Supabase database: defines schema for (evidence: `README.md`)
