# dhruvasai/edge---evidence-driven-game-engine architecture

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

- Interactive diagram: https://gitdiagram.com/dhruvasai/edge---evidence-driven-game-engine
- Repository: https://github.com/dhruvasai/edge---evidence-driven-game-engine

## Overview

EDGE is a cricket intelligence platform that turns ball-by-ball and player data into analytics, recommendations, and dashboards. Its main user workflow is to explore the dashboard or submit a match situation, which is served by API routes that query cricket data and return statistics or advice. The repository also documents an ingestion and processing path for enriching its data. The tree contains parallel layered and root-level copies; this map uses the sampled root-level serving modules and documented capabilities. Unsampled route internals are represented at subsystem level.

Main entry points: [`src/app/api`](https://github.com/dhruvasai/edge---evidence-driven-game-engine/tree/master/src/app/api) (Feature API routes), [`src/app/api/recommend/route.ts`](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/app/api/recommend/route.ts) (Match recommendations), [`src/app/api/xi-recommendations/route.ts`](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/app/api/xi-recommendations/route.ts) (Playing XI advice), [`src/ingestion/cricapi_ingest.py`](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/ingestion/cricapi_ingest.py) (Live data ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_formview["Player form view<br/>[index.tsx]"]
end

subgraph group_serving["API and advice"]
  node_api_routes["Feature API routes"]
  node_recommend["Match recommendations<br/>[route.ts]"]
  node_xi["Playing XI advice<br/>[route.ts]"]
  node_ai["AI engine<br/>[ai_engine.py]"]
  node_ai_provider["AI provider<br/>[aiProvider.ts]"]
end

subgraph group_analytics["Analytics"]
  node_analytics_engine["Analytics engine"]
  node_form_features["Form features"]
  node_form_score["Form scoring"]
  node_aggregates["Match aggregates"]
end

subgraph group_data["Data foundation"]
  node_ingest["Cricsheet ingestion<br/>[parse_cricsheet.py]"]
  node_etl["Dataset ingestion<br/>[ingest_jsons.py]"]
  node_postgres[("PostgreSQL")]
  node_prisma["Prisma client<br/>[prisma.ts]"]
  node_bigquery["BigQuery client<br/>[bigquery.ts]"]
end

subgraph group_live["Live cricket"]
  node_live_api["CricAPI"]
  node_live_ingest["Live data ingestion<br/>[cricapi_ingest.py]"]
  node_cache[("Response cache<br/>[cache.py]")]
end

node_user(("Cricket user"))

node_user -->|"opens"| node_dashboard
node_dashboard -->|"requests data"| node_api_routes
node_formview -.->|"requests insights"| node_api_routes
node_api_routes -->|"queries"| node_prisma
node_prisma -->|"reads data"| node_postgres
node_api_routes -.->|"fetches live scores"| node_live_ingest
node_live_ingest -->|"fetches"| node_live_api
node_live_ingest -->|"reads and writes"| node_cache
node_api_routes -.->|"routes advice"| node_recommend
node_recommend -->|"calls"| node_ai_provider
node_recommend -->|"queries match data"| node_postgres
node_api_routes -.->|"routes XI requests"| node_xi
node_xi -->|"queries scores"| node_bigquery
node_xi -->|"loads fallback"| node_prisma
node_ingest -.->|"transforms matches"| node_aggregates
node_aggregates -.->|"supports feature building"| node_form_features
node_form_features -.->|"supports scoring"| node_form_score
node_form_score -.->|"loads analytics"| node_bigquery
node_etl -.->|"loads datasets"| node_postgres
node_ai -.->|"uses AI service"| node_live_api
node_api_routes -.->|"serves analytics"| node_analytics_engine

click node_dashboard "https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/app/page.tsx"
click node_formview "https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/components/dashboard/PlayerFormDashboard/index.tsx"
click node_api_routes "https://github.com/dhruvasai/edge---evidence-driven-game-engine/tree/master/src/app/api"
click node_recommend "https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/app/api/recommend/route.ts"
click node_xi "https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/app/api/xi-recommendations/route.ts"
click node_ai "https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/ai/ai_engine.py"
click node_ai_provider "https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/lib/aiProvider.ts"
click node_analytics_engine "https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/processing/analytics_engine.py"
click node_form_features "https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/edge_pipeline/features/compute_form_features.py"
click node_form_score "https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/edge_pipeline/scoring/compute_form_score.py"
click node_aggregates "https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/edge_pipeline/transform/build_match_aggregates.py"
click node_ingest "https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/edge_pipeline/ingest/parse_cricsheet.py"
click node_etl "https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/tools/etl/ingest_jsons.py"
click node_prisma "https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/lib/prisma.ts"
click node_bigquery "https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/lib/bigquery.ts"
click node_live_ingest "https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/ingestion/cricapi_ingest.py"
click node_cache "https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/ingestion/cache.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_dashboard,node_formview,node_user toneBlue
class node_api_routes,node_recommend,node_xi,node_ai,node_ai_provider toneAmber
class node_analytics_engine,node_form_features,node_form_score,node_aggregates toneMint
class node_ingest,node_etl,node_postgres,node_prisma,node_bigquery toneRose
class node_live_api,node_live_ingest,node_cache toneIndigo
```

## Components

### User experience

- [Dashboard](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/app/page.tsx): `src/app/page.tsx`
- [Player form view](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/components/dashboard/PlayerFormDashboard/index.tsx): `src/components/dashboard/PlayerFormDashboard/index.tsx`

### API and advice

- [Feature API routes](https://github.com/dhruvasai/edge---evidence-driven-game-engine/tree/master/src/app/api): `src/app/api`
- [Match recommendations](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/app/api/recommend/route.ts): `src/app/api/recommend/route.ts`
- [Playing XI advice](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/app/api/xi-recommendations/route.ts): `src/app/api/xi-recommendations/route.ts`
- [AI engine](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/ai/ai_engine.py): `src/ai/ai_engine.py`
- [AI provider](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/lib/aiProvider.ts): `src/lib/aiProvider.ts`

### Analytics

- [Analytics engine](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/processing/analytics_engine.py): `src/processing/analytics_engine.py`
- [Form features](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/edge_pipeline/features/compute_form_features.py): `edge_pipeline/features/compute_form_features.py`
- [Form scoring](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/edge_pipeline/scoring/compute_form_score.py): `edge_pipeline/scoring/compute_form_score.py`
- [Match aggregates](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/edge_pipeline/transform/build_match_aggregates.py): `edge_pipeline/transform/build_match_aggregates.py`

### Data foundation

- [Cricsheet ingestion](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/edge_pipeline/ingest/parse_cricsheet.py): `edge_pipeline/ingest/parse_cricsheet.py`
- [Dataset ingestion](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/tools/etl/ingest_jsons.py): `tools/etl/ingest_jsons.py`
- **PostgreSQL**
- [Prisma client](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/lib/prisma.ts): `src/lib/prisma.ts`
- [BigQuery client](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/lib/bigquery.ts): `src/lib/bigquery.ts`

### Live cricket

- **CricAPI**
- [Live data ingestion](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/ingestion/cricapi_ingest.py): `src/ingestion/cricapi_ingest.py`
- [Response cache](https://github.com/dhruvasai/edge---evidence-driven-game-engine/blob/master/src/ingestion/cache.py): `src/ingestion/cache.py`

### Other components

- **Cricket user**

## Connections

- Cricket user → Dashboard: opens (evidence: `README.md`)
- Dashboard → Feature API routes: requests data (evidence: `README.md`)
- Player form view → Feature API routes: requests insights
- Feature API routes → Prisma client: queries (evidence: `README.md`)
- Prisma client → PostgreSQL: reads data (evidence: `README.md`)
- Feature API routes → Live data ingestion: fetches live scores (evidence: `README.md`)
- Live data ingestion → CricAPI: fetches (evidence: `src/ingestion/cricapi_ingest.py`)
- Live data ingestion → Response cache: reads and writes (evidence: `src/ingestion/cricapi_ingest.py`)
- Feature API routes → Match recommendations: routes advice
- Match recommendations → AI provider: calls (evidence: `src/app/api/recommend/route.ts`)
- Match recommendations → PostgreSQL: queries match data (evidence: `src/app/api/recommend/route.ts`)
- Feature API routes → Playing XI advice: routes XI requests
- Playing XI advice → BigQuery client: queries scores (evidence: `src/app/api/xi-recommendations/route.ts`)
- Playing XI advice → Prisma client: loads fallback (evidence: `src/app/api/xi-recommendations/route.ts`)
- Cricsheet ingestion → Match aggregates: transforms matches
- Match aggregates → Form features: supports feature building
- Form features → Form scoring: supports scoring
- Form scoring → BigQuery client: loads analytics (evidence: `README.md`)
- Dataset ingestion → PostgreSQL: loads datasets (evidence: `README.md`)
- AI engine → CricAPI: uses AI service
- Feature API routes → Analytics engine: serves analytics
