# prosaugat/nepal-cause-list-api architecture

> Architecture diagram of the GitHub repository prosaugat/nepal-cause-list-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prosaugat/nepal-cause-list-api
- Repository: https://github.com/prosaugat/nepal-cause-list-api

## Overview

Nepal Cause List API provides both a PHP client and a JSON REST interface for fetching daily, weekly, and supplementary cause lists from Nepal’s courts. In the REST workflow, a caller requests a court, list type, and Bikram Sambat date; the API checks its file cache and delegates a miss to the client, which dispatches to a court-specific scraper and returns normalized data. Court-directory and calendar-date capabilities are also exposed. Scraper details are only partly sampled, so court-site relationships follow the README; the Supreme Court’s Selenium dependency is documented there as well.

Main entry points: [`src/CauseListClient.php`](https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/CauseListClient.php) (Cause-list client), [`src/Http/Api.php`](https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Http/Api.php) (REST API), [`src/Courts/SupremeCourtService.php`](https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Courts/SupremeCourtService.php) (Supreme scraper), [`src/Support/Log.php`](https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Support/Log.php) (Scraper logging)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["API interface"]
  node_front["HTTP front controller<br/>[index.php]"]
  node_api["REST API<br/>[Api.php]"]
end

subgraph group_core["Client and calendar"]
  node_client["Cause-list client"]
  node_calendar["BS calendar<br/>[NepaliCalendar.php]"]
end

subgraph group_scrapers["Court scrapers"]
  node_high["High Court scraper"]
  node_district["District scraper"]
  node_supreme["Supreme scraper"]
  node_cms["Special and Consumer scraper"]
end

subgraph group_support["Runtime support"]
  node_cache[("Response file cache<br/>[FileCache.php]")]
  node_logger["Scraper logging<br/>[Log.php]"]
end

node_caller(("API caller"))
node_courtsites["Court websites"]
node_selenium["Selenium hub"]

node_caller -->|"sends request"| node_front
node_front -->|"invokes"| node_api
node_api -->|"routes requests"| node_client
node_api -->|"reads cache"| node_cache
node_api -->|"writes results"| node_cache
node_client -->|"gets BS date"| node_calendar
node_client -->|"dispatches high court"| node_high
node_client -->|"dispatches district court"| node_district
node_client -->|"dispatches Supreme Court"| node_supreme
node_client -->|"dispatches CMS courts"| node_cms
node_high -->|"fetches lists"| node_courtsites
node_district -->|"fetches lists"| node_courtsites
node_cms -->|"fetches lists"| node_courtsites
node_supreme -->|"fetches lists"| node_courtsites
node_supreme -->|"solves WAF challenge"| node_selenium
node_high -->|"logs errors"| node_logger
node_district -->|"logs errors"| node_logger
node_cms -->|"logs errors"| node_logger
node_supreme -->|"logs errors"| node_logger

click node_front "https://github.com/prosaugat/nepal-cause-list-api/blob/main/public/index.php"
click node_api "https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Http/Api.php"
click node_client "https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/CauseListClient.php"
click node_calendar "https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Courts/NepaliCalendar.php"
click node_high "https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Courts/HighCourtService.php"
click node_district "https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Courts/DistrictCourtService.php"
click node_supreme "https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Courts/SupremeCourtService.php"
click node_cms "https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Courts/CmsCourtService.php"
click node_cache "https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Support/FileCache.php"
click node_logger "https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Support/Log.php"

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_front,node_api toneBlue
class node_client,node_calendar toneAmber
class node_high,node_district,node_supreme,node_cms,node_caller toneMint
class node_cache,node_logger toneRose
class node_courtsites,node_selenium toneIndigo
```

## Components

### API interface

- [HTTP front controller](https://github.com/prosaugat/nepal-cause-list-api/blob/main/public/index.php): `public/index.php`
- [REST API](https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Http/Api.php): `src/Http/Api.php`

### Client and calendar

- [Cause-list client](https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/CauseListClient.php): `src/CauseListClient.php`
- [BS calendar](https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Courts/NepaliCalendar.php): `src/Courts/NepaliCalendar.php`

### Court scrapers

- [High Court scraper](https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Courts/HighCourtService.php): `src/Courts/HighCourtService.php`
- [District scraper](https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Courts/DistrictCourtService.php): `src/Courts/DistrictCourtService.php`
- [Supreme scraper](https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Courts/SupremeCourtService.php): `src/Courts/SupremeCourtService.php`
- [Special and Consumer scraper](https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Courts/CmsCourtService.php): `src/Courts/CmsCourtService.php`

### Runtime support

- [Response file cache](https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Support/FileCache.php): `src/Support/FileCache.php`
- [Scraper logging](https://github.com/prosaugat/nepal-cause-list-api/blob/main/src/Support/Log.php): `src/Support/Log.php`

### Other components

- **API caller**
- **Court websites**
- **Selenium hub**

## Connections

- API caller → HTTP front controller: sends request (evidence: `README.md`)
- HTTP front controller → REST API: invokes (evidence: `public/index.php`)
- REST API → Cause-list client: routes requests (evidence: `src/Http/Api.php`)
- REST API → Response file cache: reads cache (evidence: `src/Http/Api.php`)
- REST API → Response file cache: writes results (evidence: `src/Http/Api.php`)
- Cause-list client → BS calendar: gets BS date (evidence: `src/CauseListClient.php`)
- Cause-list client → High Court scraper: dispatches high court (evidence: `src/CauseListClient.php`)
- Cause-list client → District scraper: dispatches district court (evidence: `src/CauseListClient.php`)
- Cause-list client → Supreme scraper: dispatches Supreme Court (evidence: `src/CauseListClient.php`)
- Cause-list client → Special and Consumer scraper: dispatches CMS courts (evidence: `src/CauseListClient.php`)
- High Court scraper → Court websites: fetches lists (evidence: `README.md`)
- District scraper → Court websites: fetches lists (evidence: `README.md`)
- Special and Consumer scraper → Court websites: fetches lists (evidence: `README.md`)
- Supreme scraper → Court websites: fetches lists (evidence: `README.md`)
- Supreme scraper → Selenium hub: solves WAF challenge (evidence: `README.md`)
- High Court scraper → Scraper logging: logs errors (evidence: `src/Courts/HighCourtService.php`)
- District scraper → Scraper logging: logs errors (evidence: `src/Courts/DistrictCourtService.php`)
- Special and Consumer scraper → Scraper logging: logs errors (evidence: `src/Courts/CmsCourtService.php`)
- Supreme scraper → Scraper logging: logs errors (evidence: `src/Courts/SupremeCourtService.php`)
