# adithyakulal/nwis architecture

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

- Interactive diagram: https://gitdiagram.com/adithyakulal/nwis
- Repository: https://github.com/adithyakulal/nwis

## Overview

This Next.js application provides a well-field intelligence dashboard: users load well records, search and filter them, inspect wells on a map, and open operational analyses such as drilling logs, events, formations, risk, nearby offsets, comparisons, target evaluation, AI assistance, and analytics. The page composes these views; API routes supply well data and perform nearby-well, analytics, and assistant queries against the Prisma-backed database. The graph follows documented imports and sampled calls; several view-to-API connections are omitted because their implementations were not shown.

Main entry points: [`src/app/page.tsx`](https://github.com/adithyakulal/nwis/blob/main/src/app/page.tsx) (Dashboard page), [`src/prisma/db.ts`](https://github.com/adithyakulal/nwis/blob/main/src/prisma/db.ts) (Prisma database client), [`src/app/api/wells/nearby/route.ts`](https://github.com/adithyakulal/nwis/blob/main/src/app/api/wells/nearby/route.ts) (Nearby wells API), [`src/app/api/ai/assistant/route.ts`](https://github.com/adithyakulal/nwis/blob/main/src/app/api/ai/assistant/route.ts) (Assistant API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_page["Dashboard page<br/>[page.tsx]"]
  node_header["Dashboard header<br/>[Header.tsx]"]
  node_stats["Field statistics<br/>[StatsBar.tsx]"]
end

subgraph group_well_intelligence["Well Intelligence"]
  node_search["Well search"]
  node_map["Wells map<br/>[WellsMap.tsx]"]
  node_leaflet["Map renderer<br/>[LeafletMap.tsx]"]
  node_intelligence["Well intelligence"]
  node_nearby_view["Nearby wells"]
  node_comparison["Well comparison"]
  node_geo["Geospatial utilities<br/>[geo.ts]"]
end

subgraph group_analysis["Engineering Analysis"]
  node_drilling["Drilling logs"]
  node_events["Well events<br/>[WellEventsView.tsx]"]
  node_formations["Formation analysis<br/>[FormationView.tsx]"]
  node_risk["Drilling risk"]
  node_target["Target analysis"]
  node_analytics["Field analytics<br/>[AnalyticsView.tsx]"]
  node_ai_view["AI assistant view"]
  node_relevance["Offset relevance<br/>[relevanceEngine.ts]"]
  node_risk_engine["Risk engine<br/>[riskEngine.ts]"]
end

subgraph group_data["Data Access"]
  node_wells_api["Wells API<br/>[route.ts]"]
  node_nearby_api["Nearby wells API<br/>[route.ts]"]
  node_analytics_api["Analytics API<br/>[route.ts]"]
  node_assistant_api["Assistant API<br/>[route.ts]"]
  node_db_client["Prisma database client<br/>[db.ts]"]
end

node_user(("Dashboard user"))
node_postgres[("PostgreSQL database")]

node_user -->|"opens"| node_page
node_page -->|"fetches wells"| node_wells_api
node_wells_api -->|"queries wells"| node_db_client
node_nearby_api -->|"reads wells and events"| node_db_client
node_nearby_api -->|"calculates distance and bearing"| node_geo
node_analytics_api -->|"reads wells and events"| node_db_client
node_assistant_api -->|"queries well data"| node_db_client
node_assistant_api -->|"calculates distances"| node_geo
node_db_client -.->|"connects"| node_postgres
node_page -->|"renders"| node_header
node_page -->|"renders"| node_stats
node_page -->|"renders"| node_search
node_page -->|"renders"| node_map
node_page -->|"renders"| node_intelligence
node_page -->|"renders"| node_nearby_view
node_page -->|"renders"| node_comparison
node_page -->|"renders"| node_drilling
node_page -->|"renders"| node_events
node_page -->|"renders"| node_formations
node_page -->|"renders"| node_risk
node_page -->|"renders"| node_target
node_page -->|"renders"| node_analytics
node_page -->|"renders"| node_ai_view
node_page -->|"evaluates targets"| node_relevance
node_page -->|"filters by distance"| node_geo
node_map -.->|"uses map renderer"| node_leaflet
node_risk -.->|"uses risk calculations"| node_risk_engine
node_ai_view -.->|"requests answers"| node_assistant_api
node_nearby_view -.->|"requests offsets"| node_nearby_api
node_analytics -.->|"requests metrics"| node_analytics_api

click node_page "https://github.com/adithyakulal/nwis/blob/main/src/app/page.tsx"
click node_header "https://github.com/adithyakulal/nwis/blob/main/src/components/dashboard/Header.tsx"
click node_stats "https://github.com/adithyakulal/nwis/blob/main/src/components/dashboard/StatsBar.tsx"
click node_search "https://github.com/adithyakulal/nwis/blob/main/src/components/wells/WellSearchToolbar.tsx"
click node_map "https://github.com/adithyakulal/nwis/blob/main/src/components/map/WellsMap.tsx"
click node_leaflet "https://github.com/adithyakulal/nwis/blob/main/src/components/map/LeafletMap.tsx"
click node_intelligence "https://github.com/adithyakulal/nwis/blob/main/src/components/wells/WellIntelligencePanel.tsx"
click node_nearby_view "https://github.com/adithyakulal/nwis/blob/main/src/components/wells/NearbyWellsView.tsx"
click node_comparison "https://github.com/adithyakulal/nwis/blob/main/src/components/wells/WellComparisonView.tsx"
click node_drilling "https://github.com/adithyakulal/nwis/blob/main/src/components/drilling/DrillingLogView.tsx"
click node_events "https://github.com/adithyakulal/nwis/blob/main/src/components/events/WellEventsView.tsx"
click node_formations "https://github.com/adithyakulal/nwis/blob/main/src/components/formations/FormationView.tsx"
click node_risk "https://github.com/adithyakulal/nwis/blob/main/src/components/risk/DrillingRiskView.tsx"
click node_target "https://github.com/adithyakulal/nwis/blob/main/src/components/target/TargetAnalysisView.tsx"
click node_analytics "https://github.com/adithyakulal/nwis/blob/main/src/components/analytics/AnalyticsView.tsx"
click node_ai_view "https://github.com/adithyakulal/nwis/blob/main/src/components/ai/AIAssistantView.tsx"
click node_relevance "https://github.com/adithyakulal/nwis/blob/main/src/lib/relevanceEngine.ts"
click node_risk_engine "https://github.com/adithyakulal/nwis/blob/main/src/lib/riskEngine.ts"
click node_geo "https://github.com/adithyakulal/nwis/blob/main/src/lib/geo.ts"
click node_wells_api "https://github.com/adithyakulal/nwis/blob/main/src/app/api/wells/route.ts"
click node_nearby_api "https://github.com/adithyakulal/nwis/blob/main/src/app/api/wells/nearby/route.ts"
click node_analytics_api "https://github.com/adithyakulal/nwis/blob/main/src/app/api/analytics/route.ts"
click node_assistant_api "https://github.com/adithyakulal/nwis/blob/main/src/app/api/ai/assistant/route.ts"
click node_db_client "https://github.com/adithyakulal/nwis/blob/main/src/prisma/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_page,node_header,node_stats,node_user toneBlue
class node_search,node_map,node_leaflet,node_intelligence,node_nearby_view,node_comparison,node_geo,node_postgres toneAmber
class node_drilling,node_events,node_formations,node_risk,node_target,node_analytics,node_ai_view,node_relevance,node_risk_engine toneMint
class node_wells_api,node_nearby_api,node_analytics_api,node_assistant_api,node_db_client toneRose
```

## Components

### Dashboard

- [Dashboard page](https://github.com/adithyakulal/nwis/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Dashboard header](https://github.com/adithyakulal/nwis/blob/main/src/components/dashboard/Header.tsx): `src/components/dashboard/Header.tsx`
- [Field statistics](https://github.com/adithyakulal/nwis/blob/main/src/components/dashboard/StatsBar.tsx): `src/components/dashboard/StatsBar.tsx`

### Well Intelligence

- [Well search](https://github.com/adithyakulal/nwis/blob/main/src/components/wells/WellSearchToolbar.tsx): `src/components/wells/WellSearchToolbar.tsx`
- [Wells map](https://github.com/adithyakulal/nwis/blob/main/src/components/map/WellsMap.tsx): `src/components/map/WellsMap.tsx`
- [Map renderer](https://github.com/adithyakulal/nwis/blob/main/src/components/map/LeafletMap.tsx): `src/components/map/LeafletMap.tsx`
- [Well intelligence](https://github.com/adithyakulal/nwis/blob/main/src/components/wells/WellIntelligencePanel.tsx): `src/components/wells/WellIntelligencePanel.tsx`
- [Nearby wells](https://github.com/adithyakulal/nwis/blob/main/src/components/wells/NearbyWellsView.tsx): `src/components/wells/NearbyWellsView.tsx`
- [Well comparison](https://github.com/adithyakulal/nwis/blob/main/src/components/wells/WellComparisonView.tsx): `src/components/wells/WellComparisonView.tsx`
- [Geospatial utilities](https://github.com/adithyakulal/nwis/blob/main/src/lib/geo.ts): `src/lib/geo.ts`

### Engineering Analysis

- [Drilling logs](https://github.com/adithyakulal/nwis/blob/main/src/components/drilling/DrillingLogView.tsx): `src/components/drilling/DrillingLogView.tsx`
- [Well events](https://github.com/adithyakulal/nwis/blob/main/src/components/events/WellEventsView.tsx): `src/components/events/WellEventsView.tsx`
- [Formation analysis](https://github.com/adithyakulal/nwis/blob/main/src/components/formations/FormationView.tsx): `src/components/formations/FormationView.tsx`
- [Drilling risk](https://github.com/adithyakulal/nwis/blob/main/src/components/risk/DrillingRiskView.tsx): `src/components/risk/DrillingRiskView.tsx`
- [Target analysis](https://github.com/adithyakulal/nwis/blob/main/src/components/target/TargetAnalysisView.tsx): `src/components/target/TargetAnalysisView.tsx`
- [Field analytics](https://github.com/adithyakulal/nwis/blob/main/src/components/analytics/AnalyticsView.tsx): `src/components/analytics/AnalyticsView.tsx`
- [AI assistant view](https://github.com/adithyakulal/nwis/blob/main/src/components/ai/AIAssistantView.tsx): `src/components/ai/AIAssistantView.tsx`
- [Offset relevance](https://github.com/adithyakulal/nwis/blob/main/src/lib/relevanceEngine.ts): `src/lib/relevanceEngine.ts`
- [Risk engine](https://github.com/adithyakulal/nwis/blob/main/src/lib/riskEngine.ts): `src/lib/riskEngine.ts`

### Data Access

- [Wells API](https://github.com/adithyakulal/nwis/blob/main/src/app/api/wells/route.ts): `src/app/api/wells/route.ts`
- [Nearby wells API](https://github.com/adithyakulal/nwis/blob/main/src/app/api/wells/nearby/route.ts): `src/app/api/wells/nearby/route.ts`
- [Analytics API](https://github.com/adithyakulal/nwis/blob/main/src/app/api/analytics/route.ts): `src/app/api/analytics/route.ts`
- [Assistant API](https://github.com/adithyakulal/nwis/blob/main/src/app/api/ai/assistant/route.ts): `src/app/api/ai/assistant/route.ts`
- [Prisma database client](https://github.com/adithyakulal/nwis/blob/main/src/prisma/db.ts): `src/prisma/db.ts`

### Other components

- **Dashboard user**
- **PostgreSQL database**

## Connections

- Dashboard user → Dashboard page: opens (evidence: `src/app/page.tsx`)
- Dashboard page → Wells API: fetches wells (evidence: `src/app/page.tsx`)
- Wells API → Prisma database client: queries wells (evidence: `src/app/api/wells/route.ts`)
- Nearby wells API → Prisma database client: reads wells and events (evidence: `src/app/api/wells/nearby/route.ts`)
- Nearby wells API → Geospatial utilities: calculates distance and bearing (evidence: `src/app/api/wells/nearby/route.ts`)
- Analytics API → Prisma database client: reads wells and events (evidence: `src/app/api/analytics/route.ts`)
- Assistant API → Prisma database client: queries well data (evidence: `src/app/api/ai/assistant/route.ts`)
- Assistant API → Geospatial utilities: calculates distances (evidence: `src/app/api/ai/assistant/route.ts`)
- Prisma database client → PostgreSQL database: connects (evidence: `src/prisma/db.ts`)
- Dashboard page → Dashboard header: renders (evidence: `src/app/page.tsx`)
- Dashboard page → Field statistics: renders (evidence: `src/app/page.tsx`)
- Dashboard page → Well search: renders (evidence: `src/app/page.tsx`)
- Dashboard page → Wells map: renders (evidence: `src/app/page.tsx`)
- Dashboard page → Well intelligence: renders (evidence: `src/app/page.tsx`)
- Dashboard page → Nearby wells: renders (evidence: `src/app/page.tsx`)
- Dashboard page → Well comparison: renders (evidence: `src/app/page.tsx`)
- Dashboard page → Drilling logs: renders (evidence: `src/app/page.tsx`)
- Dashboard page → Well events: renders (evidence: `src/app/page.tsx`)
- Dashboard page → Formation analysis: renders (evidence: `src/app/page.tsx`)
- Dashboard page → Drilling risk: renders (evidence: `src/app/page.tsx`)
- Dashboard page → Target analysis: renders (evidence: `src/app/page.tsx`)
- Dashboard page → Field analytics: renders (evidence: `src/app/page.tsx`)
- Dashboard page → AI assistant view: renders (evidence: `src/app/page.tsx`)
- Dashboard page → Offset relevance: evaluates targets (evidence: `src/app/page.tsx`)
- Dashboard page → Geospatial utilities: filters by distance (evidence: `src/app/page.tsx`)
- Wells map → Map renderer: uses map renderer
- Drilling risk → Risk engine: uses risk calculations
- AI assistant view → Assistant API: requests answers
- Nearby wells → Nearby wells API: requests offsets
- Field analytics → Analytics API: requests metrics
