# aifanfou/nightreign-map architecture

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

- Interactive diagram: https://gitdiagram.com/aifanfou/nightreign-map
- Repository: https://github.com/aifanfou/nightreign-map

## Overview

Nightreign Seed Finder lets players narrow map seeds by choosing a map, Nightlord, and building slots, then inspect a matching result. Its main flow is map selection → interactive slot configuration → seed filtering → result map. A separate OCR service detects game-map details from captured screens or uploaded images and supports live overlay updates and optional SMS. The repository also includes update notices and feedback/reporting endpoints. The OCR service’s full orchestration and frontend integration are only partially evidenced by the sampled excerpts, so those links are kept limited.

Main entry points: [`ocr-service/app/main.py`](https://github.com/aifanfou/nightreign-map/blob/main/ocr-service/app/main.py) (OCR API), [`src/components/MapBuilder.tsx`](https://github.com/aifanfou/nightreign-map/blob/main/src/components/MapBuilder.tsx) (Map Builder), [`src/lib/updates/updateManager.ts`](https://github.com/aifanfou/nightreign-map/blob/main/src/lib/updates/updateManager.ts) (Update Notices), [`src/app/page.tsx`](https://github.com/aifanfou/nightreign-map/blob/main/src/app/page.tsx) (Map Selection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_seed["Seed Finder"]
  node_home["Map Selection<br/>[page.tsx]"]
  node_builder["Map Builder<br/>[MapBuilder.tsx]"]
  node_search["Seed Search<br/>[useSeedSearch.ts]"]
  node_seeddata["Seed Matching<br/>[seedSearch.ts]"]
  node_resultpage["Result Page<br/>[page.tsx]"]
end

subgraph group_maps["Map Experience"]
  node_resultmap["Result Map<br/>[MapResult.tsx]"]
  node_basemap["Interactive Map<br/>[BaseMap.tsx]"]
  node_markers["Slot Markers"]
  node_mapdata["Map Coordinates<br/>[mapCoordinates.ts]"]
end

subgraph group_ocr["OCR Service"]
  node_capturepage["Capture Page<br/>[page.tsx]"]
  node_capturecontrol["OCR Controls"]
  node_capturehook["Capture Client<br/>[useOCRCapture.ts]"]
  node_ocrapi["OCR API<br/>[main.py]"]
  node_screen["Screen Capture<br/>[screen_capture.py]"]
  node_processor["Frame Processing<br/>[frame_processor.py]"]
  node_detectors["Game Detection"]
  node_overlay["Overlay Updates<br/>[manager.py]"]
  node_sms["SMS Messaging<br/>[imessage.py]"]
end

subgraph group_support["Updates And Feedback"]
  node_updates["Update Notices<br/>[updateManager.ts]"]
  node_preferences[("Update Preferences<br/>[storage.ts]")]
  node_logapi["Usage Logging<br/>[route.ts]"]
  node_bugapi["Bug Reports<br/>[route.ts]"]
end

node_player(("Player"))
node_supabase[("Supabase<br/>[supabaseClient.ts]")]
node_smsservice["SMS Provider"]

node_player -->|"chooses map"| node_home
node_player -->|"sets slots"| node_builder
node_home -->|"opens builder"| node_builder
node_builder -->|"renders map"| node_basemap
node_builder -->|"filters selections"| node_search
node_search -->|"queries seeds"| node_seeddata
node_builder -->|"opens match"| node_resultpage
node_resultpage -->|"renders result"| node_resultmap
node_basemap -->|"manages markers"| node_markers
node_markers -->|"reads coordinates"| node_mapdata
node_player -->|"opens capture"| node_capturepage
node_capturepage -->|"shows controls"| node_capturecontrol
node_capturecontrol -->|"uses capture"| node_capturehook
node_ocrapi -->|"captures monitor"| node_screen
node_ocrapi -->|"extracts map region"| node_processor
node_ocrapi -->|"runs detection"| node_detectors
node_ocrapi -->|"broadcasts updates"| node_overlay
node_ocrapi -.->|"sends messages"| node_sms
node_sms -.->|"delivers SMS"| node_smsservice
node_player -->|"views notices"| node_updates
node_updates -->|"reads preferences"| node_preferences
node_updates -->|"saves preferences"| node_preferences
node_player -->|"submits usage"| node_logapi
node_player -->|"reports bug"| node_bugapi
node_logapi -->|"inserts logs"| node_supabase
node_bugapi -->|"inserts reports"| node_supabase

click node_home "https://github.com/aifanfou/nightreign-map/blob/main/src/app/page.tsx"
click node_builder "https://github.com/aifanfou/nightreign-map/blob/main/src/components/MapBuilder.tsx"
click node_search "https://github.com/aifanfou/nightreign-map/blob/main/src/hooks/useSeedSearch.ts"
click node_seeddata "https://github.com/aifanfou/nightreign-map/blob/main/src/lib/data/seedSearch.ts"
click node_resultpage "https://github.com/aifanfou/nightreign-map/blob/main/src/app/result/%5Bid%5D/page.tsx"
click node_resultmap "https://github.com/aifanfou/nightreign-map/blob/main/src/components/MapResult.tsx"
click node_basemap "https://github.com/aifanfou/nightreign-map/blob/main/src/components/BaseMap/BaseMap.tsx"
click node_markers "https://github.com/aifanfou/nightreign-map/blob/main/src/components/BaseMap/hooks/useMarkerManager.ts"
click node_mapdata "https://github.com/aifanfou/nightreign-map/blob/main/src/lib/constants/mapCoordinates.ts"
click node_capturepage "https://github.com/aifanfou/nightreign-map/blob/main/src/app/capture/page.tsx"
click node_capturecontrol "https://github.com/aifanfou/nightreign-map/blob/main/src/components/OCRCaptureControl.tsx"
click node_capturehook "https://github.com/aifanfou/nightreign-map/blob/main/src/hooks/useOCRCapture.ts"
click node_ocrapi "https://github.com/aifanfou/nightreign-map/blob/main/ocr-service/app/main.py"
click node_screen "https://github.com/aifanfou/nightreign-map/blob/main/ocr-service/app/capture/screen_capture.py"
click node_processor "https://github.com/aifanfou/nightreign-map/blob/main/ocr-service/app/capture/frame_processor.py"
click node_detectors "https://github.com/aifanfou/nightreign-map/tree/main/ocr-service/app/detection"
click node_overlay "https://github.com/aifanfou/nightreign-map/blob/main/ocr-service/app/websocket/manager.py"
click node_sms "https://github.com/aifanfou/nightreign-map/blob/main/ocr-service/app/messaging/imessage.py"
click node_updates "https://github.com/aifanfou/nightreign-map/blob/main/src/lib/updates/updateManager.ts"
click node_preferences "https://github.com/aifanfou/nightreign-map/blob/main/src/lib/updates/storage.ts"
click node_logapi "https://github.com/aifanfou/nightreign-map/blob/main/src/app/api/log/route.ts"
click node_bugapi "https://github.com/aifanfou/nightreign-map/blob/main/src/app/api/report-bug/route.ts"
click node_supabase "https://github.com/aifanfou/nightreign-map/blob/main/src/lib/supabaseClient.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_home,node_builder,node_search,node_seeddata,node_resultpage toneBlue
class node_resultmap,node_basemap,node_markers,node_mapdata,node_supabase toneAmber
class node_capturepage,node_capturecontrol,node_capturehook,node_ocrapi,node_screen,node_processor,node_detectors,node_overlay,node_sms toneMint
class node_updates,node_preferences,node_logapi,node_bugapi toneRose
class node_player,node_smsservice toneIndigo
```

## Components

### Seed Finder

- [Map Selection](https://github.com/aifanfou/nightreign-map/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Map Builder](https://github.com/aifanfou/nightreign-map/blob/main/src/components/MapBuilder.tsx): `src/components/MapBuilder.tsx`
- [Seed Search](https://github.com/aifanfou/nightreign-map/blob/main/src/hooks/useSeedSearch.ts): `src/hooks/useSeedSearch.ts`
- [Seed Matching](https://github.com/aifanfou/nightreign-map/blob/main/src/lib/data/seedSearch.ts): `src/lib/data/seedSearch.ts`
- [Result Page](https://github.com/aifanfou/nightreign-map/blob/main/src/app/result/%5Bid%5D/page.tsx): `src/app/result/[id]/page.tsx`

### Map Experience

- [Result Map](https://github.com/aifanfou/nightreign-map/blob/main/src/components/MapResult.tsx): `src/components/MapResult.tsx`
- [Interactive Map](https://github.com/aifanfou/nightreign-map/blob/main/src/components/BaseMap/BaseMap.tsx): `src/components/BaseMap/BaseMap.tsx`
- [Slot Markers](https://github.com/aifanfou/nightreign-map/blob/main/src/components/BaseMap/hooks/useMarkerManager.ts): `src/components/BaseMap/hooks/useMarkerManager.ts`
- [Map Coordinates](https://github.com/aifanfou/nightreign-map/blob/main/src/lib/constants/mapCoordinates.ts): `src/lib/constants/mapCoordinates.ts`

### OCR Service

- [Capture Page](https://github.com/aifanfou/nightreign-map/blob/main/src/app/capture/page.tsx): `src/app/capture/page.tsx`
- [OCR Controls](https://github.com/aifanfou/nightreign-map/blob/main/src/components/OCRCaptureControl.tsx): `src/components/OCRCaptureControl.tsx`
- [Capture Client](https://github.com/aifanfou/nightreign-map/blob/main/src/hooks/useOCRCapture.ts): `src/hooks/useOCRCapture.ts`
- [OCR API](https://github.com/aifanfou/nightreign-map/blob/main/ocr-service/app/main.py): `ocr-service/app/main.py`
- [Screen Capture](https://github.com/aifanfou/nightreign-map/blob/main/ocr-service/app/capture/screen_capture.py): `ocr-service/app/capture/screen_capture.py`
- [Frame Processing](https://github.com/aifanfou/nightreign-map/blob/main/ocr-service/app/capture/frame_processor.py): `ocr-service/app/capture/frame_processor.py`
- [Game Detection](https://github.com/aifanfou/nightreign-map/tree/main/ocr-service/app/detection): `ocr-service/app/detection`
- [Overlay Updates](https://github.com/aifanfou/nightreign-map/blob/main/ocr-service/app/websocket/manager.py): `ocr-service/app/websocket/manager.py`
- [SMS Messaging](https://github.com/aifanfou/nightreign-map/blob/main/ocr-service/app/messaging/imessage.py): `ocr-service/app/messaging/imessage.py`

### Updates And Feedback

- [Update Notices](https://github.com/aifanfou/nightreign-map/blob/main/src/lib/updates/updateManager.ts): `src/lib/updates/updateManager.ts`
- [Update Preferences](https://github.com/aifanfou/nightreign-map/blob/main/src/lib/updates/storage.ts): `src/lib/updates/storage.ts`
- [Usage Logging](https://github.com/aifanfou/nightreign-map/blob/main/src/app/api/log/route.ts): `src/app/api/log/route.ts`
- [Bug Reports](https://github.com/aifanfou/nightreign-map/blob/main/src/app/api/report-bug/route.ts): `src/app/api/report-bug/route.ts`

### Other components

- **Player**
- [Supabase](https://github.com/aifanfou/nightreign-map/blob/main/src/lib/supabaseClient.ts): `src/lib/supabaseClient.ts`
- **SMS Provider**

## Connections

- Player → Map Selection: chooses map
- Player → Map Builder: sets slots
- Map Selection → Map Builder: opens builder
- Map Builder → Interactive Map: renders map
- Map Builder → Seed Search: filters selections
- Seed Search → Seed Matching: queries seeds
- Map Builder → Result Page: opens match
- Result Page → Result Map: renders result
- Interactive Map → Slot Markers: manages markers
- Slot Markers → Map Coordinates: reads coordinates
- Player → Capture Page: opens capture
- Capture Page → OCR Controls: shows controls
- OCR Controls → Capture Client: uses capture
- OCR API → Screen Capture: captures monitor
- OCR API → Frame Processing: extracts map region
- OCR API → Game Detection: runs detection
- OCR API → Overlay Updates: broadcasts updates
- OCR API → SMS Messaging: sends messages
- SMS Messaging → SMS Provider: delivers SMS
- Player → Update Notices: views notices
- Update Notices → Update Preferences: reads preferences
- Update Notices → Update Preferences: saves preferences
- Player → Usage Logging: submits usage
- Player → Bug Reports: reports bug
- Usage Logging → Supabase: inserts logs
- Bug Reports → Supabase: inserts reports
