# naren-kanchi/riten-graph architecture

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

- Interactive diagram: https://gitdiagram.com/naren-kanchi/riten-graph
- Repository: https://github.com/naren-kanchi/riten-graph

## Overview

RITEN-GRAPH is a historical, partly synthetic research application for exploring semiconductor trade, restrictions, AI infrastructure, energy, macroeconomic indicators, and technology companies. Analysts use a Next.js interface to query a FastAPI service, which serves relational analysis from PostgreSQL and graph questions from Neo4j; users can also curate records and administer access. Its data workflow validates and loads CSV sources, projects graph data, and produces a quality report. Source excerpts establish several backend calls; some frontend and ETL connections are documented only in the README, so those edges cite it.

Main entry points: [`backend/riten/main.py`](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/main.py) (FastAPI application), [`backend/riten/db.py`](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/db.py) (PostgreSQL access), [`backend/riten/etl/run.py`](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/etl/run.py) (ETL orchestration), [`backend/riten/routers/graph.py`](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/routers/graph.py) (Graph queries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Analyst experience"]
  node_web["Research interface"]
  node_api_client["API client<br/>[api.ts]"]
  node_api_proxy["API route proxy<br/>[route.ts]"]
  node_auth_ui["Sign-in<br/>[page.tsx]"]
end

subgraph group_api["API and access"]
  node_api_app["FastAPI application<br/>[main.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_curation["Curation<br/>[curation.py]"]
  node_admin["Administration<br/>[admin.py]"]
  node_relational["Relational queries<br/>[relational.py]"]
  node_graph_api["Graph queries<br/>[graph.py]"]
  node_params["Request validation<br/>[params.py]"]
  node_security["Session security<br/>[security.py]"]
end

subgraph group_analysis["Analytical services"]
  node_views["Shared read views<br/>[views.py]"]
  node_discovery["Graph discoveries<br/>[discovery.py]"]
  node_cache["Cache and prefetch<br/>[cache.py]"]
  node_worker["Prefetch worker<br/>[worker.py]"]
end

subgraph group_data["Data stores"]
  node_postgres_access["PostgreSQL access<br/>[db.py]"]
  node_postgres[("PostgreSQL")]
  node_graph_access["Neo4j access<br/>[graphdb.py]"]
  node_neo4j[("Neo4j")]
  node_redis[("Redis cache")]
end

subgraph group_ingestion["Data ingestion"]
  node_etl_run["ETL orchestration<br/>[run.py]"]
  node_contract["Source contract<br/>[contract.py]"]
  node_validate["Data validation<br/>[validate.py]"]
  node_load["Relational loading<br/>[load.py]"]
  node_projection["Graph projection<br/>[graph.py]"]
  node_report["Quality report<br/>[report.py]"]
end

node_analyst(("Analyst"))
node_csv_sources["Source CSVs"]

node_analyst -->|"explores"| node_web
node_web -.->|"requests data"| node_api_client
node_api_client -.->|"forwards requests"| node_api_proxy
node_api_proxy -.->|"routes to API"| node_api_app
node_auth_ui -.->|"signs in"| node_api_app
node_api_app -->|"registers router"| node_auth
node_api_app -->|"registers router"| node_relational
node_api_app -->|"registers router"| node_graph_api
node_api_app -->|"registers router"| node_curation
node_api_app -->|"registers router"| node_admin
node_auth -->|"reads users"| node_postgres_access
node_auth -->|"issues tokens"| node_security
node_curation -->|"reads and writes"| node_postgres_access
node_relational -->|"queries records"| node_postgres_access
node_relational -->|"uses shared views"| node_views
node_relational -->|"caches results"| node_cache
node_graph_api -->|"runs graph queries"| node_graph_access
node_graph_api -->|"requests discoveries"| node_discovery
node_graph_api -->|"uses graph views"| node_views
node_graph_api -->|"caches results"| node_cache
node_postgres_access -->|"queries"| node_postgres
node_graph_access -->|"runs Cypher"| node_neo4j
node_views -->|"reads relational data"| node_postgres_access
node_views -->|"reads graph data"| node_graph_access
node_cache -->|"reads and writes"| node_redis
node_cache -->|"gets data version"| node_postgres_access
node_worker -->|"reads navigation"| node_postgres_access
node_worker -->|"computes prefetched views"| node_views
node_worker -->|"stores prefetched results"| node_cache
node_csv_sources -->|"provides inputs"| node_etl_run
node_etl_run -->|"checks source contract"| node_contract
node_etl_run -->|"validates rows"| node_validate
node_etl_run -->|"loads data"| node_load
node_etl_run -->|"projects graph"| node_projection
node_etl_run -->|"writes report"| node_report
node_load -->|"stores normalized data"| node_postgres
node_projection -->|"populates graph"| node_neo4j

click node_web "https://github.com/naren-kanchi/riten-graph/tree/main/frontend/app"
click node_api_client "https://github.com/naren-kanchi/riten-graph/blob/main/frontend/lib/api.ts"
click node_api_proxy "https://github.com/naren-kanchi/riten-graph/blob/main/frontend/app/api/%5B...path%5D/route.ts"
click node_auth_ui "https://github.com/naren-kanchi/riten-graph/blob/main/frontend/app/login/page.tsx"
click node_api_app "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/main.py"
click node_auth "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/routers/auth.py"
click node_curation "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/routers/curation.py"
click node_admin "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/routers/admin.py"
click node_relational "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/routers/relational.py"
click node_graph_api "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/routers/graph.py"
click node_params "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/routers/params.py"
click node_security "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/security.py"
click node_views "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/views.py"
click node_discovery "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/discovery.py"
click node_cache "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/cache.py"
click node_worker "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/worker.py"
click node_postgres_access "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/db.py"
click node_graph_access "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/graphdb.py"
click node_etl_run "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/etl/run.py"
click node_contract "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/etl/contract.py"
click node_validate "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/etl/validate.py"
click node_load "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/etl/load.py"
click node_projection "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/etl/graph.py"
click node_report "https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/etl/report.py"

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_web,node_api_client,node_api_proxy,node_auth_ui toneBlue
class node_api_app,node_auth,node_curation,node_admin,node_relational,node_graph_api,node_params,node_security toneAmber
class node_views,node_discovery,node_cache,node_worker toneMint
class node_postgres_access,node_postgres,node_graph_access,node_neo4j,node_redis toneRose
class node_etl_run,node_contract,node_validate,node_load,node_projection,node_report,node_analyst,node_csv_sources toneIndigo
```

## Components

### Analyst experience

- [Research interface](https://github.com/naren-kanchi/riten-graph/tree/main/frontend/app): `frontend/app`
- [API client](https://github.com/naren-kanchi/riten-graph/blob/main/frontend/lib/api.ts): `frontend/lib/api.ts`
- [API route proxy](https://github.com/naren-kanchi/riten-graph/blob/main/frontend/app/api/%5B...path%5D/route.ts): `frontend/app/api/[...path]/route.ts`
- [Sign-in](https://github.com/naren-kanchi/riten-graph/blob/main/frontend/app/login/page.tsx): `frontend/app/login/page.tsx`

### API and access

- [FastAPI application](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/main.py): `backend/riten/main.py`
- [Authentication](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/routers/auth.py): `backend/riten/routers/auth.py`
- [Curation](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/routers/curation.py): `backend/riten/routers/curation.py`
- [Administration](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/routers/admin.py): `backend/riten/routers/admin.py`
- [Relational queries](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/routers/relational.py): `backend/riten/routers/relational.py`
- [Graph queries](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/routers/graph.py): `backend/riten/routers/graph.py`
- [Request validation](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/routers/params.py): `backend/riten/routers/params.py`
- [Session security](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/security.py): `backend/riten/security.py`

### Analytical services

- [Shared read views](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/views.py): `backend/riten/views.py`
- [Graph discoveries](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/discovery.py): `backend/riten/discovery.py`
- [Cache and prefetch](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/cache.py): `backend/riten/cache.py`
- [Prefetch worker](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/worker.py): `backend/riten/worker.py`

### Data stores

- [PostgreSQL access](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/db.py): `backend/riten/db.py`
- **PostgreSQL**
- [Neo4j access](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/graphdb.py): `backend/riten/graphdb.py`
- **Neo4j**
- **Redis cache**

### Data ingestion

- [ETL orchestration](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/etl/run.py): `backend/riten/etl/run.py`
- [Source contract](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/etl/contract.py): `backend/riten/etl/contract.py`
- [Data validation](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/etl/validate.py): `backend/riten/etl/validate.py`
- [Relational loading](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/etl/load.py): `backend/riten/etl/load.py`
- [Graph projection](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/etl/graph.py): `backend/riten/etl/graph.py`
- [Quality report](https://github.com/naren-kanchi/riten-graph/blob/main/backend/riten/etl/report.py): `backend/riten/etl/report.py`

### Other components

- **Analyst**
- **Source CSVs**

## Connections

- Analyst → Research interface: explores (evidence: `README.md`)
- Research interface → API client: requests data
- API client → API route proxy: forwards requests
- API route proxy → FastAPI application: routes to API
- Sign-in → FastAPI application: signs in
- FastAPI application → Authentication: registers router (evidence: `backend/riten/main.py`)
- FastAPI application → Relational queries: registers router (evidence: `backend/riten/main.py`)
- FastAPI application → Graph queries: registers router (evidence: `backend/riten/main.py`)
- FastAPI application → Curation: registers router (evidence: `backend/riten/main.py`)
- FastAPI application → Administration: registers router (evidence: `backend/riten/main.py`)
- Authentication → PostgreSQL access: reads users (evidence: `backend/riten/routers/auth.py`)
- Authentication → Session security: issues tokens (evidence: `backend/riten/routers/auth.py`)
- Curation → PostgreSQL access: reads and writes (evidence: `backend/riten/routers/curation.py`)
- Relational queries → PostgreSQL access: queries records (evidence: `backend/riten/routers/relational.py`)
- Relational queries → Shared read views: uses shared views (evidence: `backend/riten/routers/relational.py`)
- Relational queries → Cache and prefetch: caches results (evidence: `backend/riten/routers/relational.py`)
- Graph queries → Neo4j access: runs graph queries (evidence: `backend/riten/routers/graph.py`)
- Graph queries → Graph discoveries: requests discoveries (evidence: `backend/riten/routers/graph.py`)
- Graph queries → Shared read views: uses graph views (evidence: `backend/riten/routers/graph.py`)
- Graph queries → Cache and prefetch: caches results (evidence: `backend/riten/routers/graph.py`)
- PostgreSQL access → PostgreSQL: queries (evidence: `backend/riten/db.py`)
- Neo4j access → Neo4j: runs Cypher (evidence: `backend/riten/graphdb.py`)
- Shared read views → PostgreSQL access: reads relational data (evidence: `backend/riten/views.py`)
- Shared read views → Neo4j access: reads graph data (evidence: `backend/riten/views.py`)
- Cache and prefetch → Redis cache: reads and writes (evidence: `backend/riten/cache.py`)
- Cache and prefetch → PostgreSQL access: gets data version (evidence: `backend/riten/cache.py`)
- Prefetch worker → PostgreSQL access: reads navigation (evidence: `backend/riten/worker.py`)
- Prefetch worker → Shared read views: computes prefetched views (evidence: `backend/riten/worker.py`)
- Prefetch worker → Cache and prefetch: stores prefetched results (evidence: `backend/riten/worker.py`)
- Source CSVs → ETL orchestration: provides inputs (evidence: `README.md`)
- ETL orchestration → Source contract: checks source contract
- ETL orchestration → Data validation: validates rows
- ETL orchestration → Relational loading: loads data (evidence: `README.md`)
- ETL orchestration → Graph projection: projects graph (evidence: `README.md`)
- ETL orchestration → Quality report: writes report (evidence: `README.md`)
- Relational loading → PostgreSQL: stores normalized data (evidence: `README.md`)
- Graph projection → Neo4j: populates graph (evidence: `README.md`)
