# raycal49/outage_clone architecture

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

- Interactive diagram: https://gitdiagram.com/raycal49/outage_clone
- Repository: https://github.com/raycal49/outage_clone

## Overview

#### Purpose and entry points
OutageMap is a full-stack outage visualization system: an ASP.NET Core server ingests and persists outage events, exposes map-ready data, and pushes updates; a TypeScript client renders the live outage map. Server composition starts in `OutageMap.Server/Program.cs`; client bootstrap is `outagemap.client/src/main.tsx` and `outagemap.client/src/App.tsx`.

#### Server API and realtime boundary
HTTP map access is handled by `OutageMap.Server/Controllers/OutageMapController.cs`. Realtime delivery uses the SignalR hub at `OutageMap.Server/Hubs/OutageHub.cs`. These are the server’s outward-facing contracts: REST-style retrieval for initial/current state and hub notifications for changes, consumed by `outagemap.client/src/lib/outageHub.ts`.

#### Ingestion and scheduled synchronization
A hosted poller, `OutageMap.Server/Services/BackgroundServices/OutagePoller.cs`, drives recurring synchronization through `OutageMap.Server/Services/OutageSyncService.cs`. Source abstraction is `OutageMap.Server/Infrastructure/Http/IOutageSource.cs`; production polling appears in `OutageMap.Server/Infrastructure/Http/PollOutageSource.cs`, while `OutageMap.Server/Infrastructure/Http/FixtureOutageService.cs` supports fixture-backed input. Feed endpoint/settings are isolated in `OutageMap.Server/Infrastructure/Http/OutageFeedOptions.cs`.

#### Validation, reconciliation, and update publication
Incoming DTOs enter through `OutageMap.Server/Dtos/OutageDto.cs` and are mapped into persisted entities by `OutageMap.Server/Dtos/Mappers/OutageDtoToEntity.cs`. `OutageMap.Server/Services/OutageValidator.cs` enforces input validity; `OutageMap.Server/Services/OutageUpdater.cs` applies detected changes. `OutageMap.Server/Services/OutageSyncResult.cs` carries synchronization outcomes, likely separating source-fetch/reconciliation results from controller and hub concerns.

#### Persistence and spatial response representation
Entity Framework Core persistence centers on `OutageMap.Server/Models/AppDbContext.cs` and `OutageMap.Server/Models/OutageEntity.cs`, with schema rules in `OutageMap.Server/Models/OutageEntityConfiguration.cs`. Database evolution is captured under `OutageMap.Server/Migrations/`. `OutageMap.Server/Models/OutageEntityToGeojson.cs` is the important API-format boundary: stored outage records are transformed into GeoJSON suitable for map rendering.

#### Read model and client map flow
`OutageMap.Server/Services/IOutageReader.cs` and `OutageMap.Server/Services/OutageReader.cs` provide a read-side service boundary between persisted data and API delivery. On the client, `outagemap.client/src/hooks/useOutageFeed.ts` obtains and maintains outage state, while `outagemap.client/src/map/OutageMap.tsx`, `outagemap.client/src/map/layers.ts`, and `outagemap.client/src/map/interactions.ts` render and interact with map features. Selection and detail UI flow through `outagemap.client/src/hooks/useOutageSelection.ts` and `outagemap.client/src/components/OutagePopup.tsx`.

#### Runtime, infrastructure, and verification
The server is .NET/ASP.NET Core with EF Core migrations and SignalR; its integration tests use SQL Server infrastructure in `OutageMap.Server.Tests/Integration/Infrastructure/SqlServerFixture.cs`. The client is a Vite-based TypeScript/React application, with map-oriented styling and components under `outagemap.client/src/`. CI is defined by `azure-pipelines.yml`.

Main entry points: [`OutageMap.Server/Services/OutageSyncService.cs`](https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Services/OutageSyncService.cs) (Outage sync), [`outagemap.client/src/hooks/useOutageFeed.ts`](https://github.com/raycal49/outage_clone/blob/main/outagemap.client/src/hooks/useOutageFeed.ts) (Live outage feed), [`OutageMap.Server/Program.cs`](https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Program.cs) (Server composition), [`OutageMap.Server/Services/OutageReader.cs`](https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Services/OutageReader.cs) (Outage reader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["ASP.NET Core server"]
  node_server_bootstrap{{"Server composition<br/>ASP.NET Core startup<br/>[Program.cs]"}}
  node_poller["Scheduled poller<br/>hosted service<br/>[OutagePoller.cs]"]
  node_sync["Outage sync<br/>synchronization service"]
  node_validation_mapping["DTO validation and mapping<br/>ingestion transform<br/>[OutageDto.cs]"]
  node_updater["Outage updater<br/>reconciliation service<br/>[OutageUpdater.cs]"]
  node_database[("Outage database<br/>EF Core persistence<br/>[AppDbContext.cs]")]
  node_reader["Outage reader<br/>read service<br/>[OutageReader.cs]"]
  node_geojson["GeoJSON projection<br/>spatial formatter"]
  node_map_api["Map API<br/>REST controller"]
  node_outage_hub["Outage hub<br/>SignalR hub<br/>[OutageHub.cs]"]
end

subgraph group_client["React map client"]
  node_client_bootstrap{{"Client bootstrap<br/>Vite React entry<br/>[main.tsx]"}}
  node_app["Application shell<br/>React app<br/>[App.tsx]"]
  node_feed_hook["Live outage feed<br/>React state hook<br/>[useOutageFeed.ts]"]
  node_hub_client["SignalR client<br/>realtime client<br/>[outageHub.ts]"]
  node_map["Outage map<br/>map renderer<br/>[OutageMap.tsx]"]
  node_selection["Selection and popup<br/>map detail UI"]
end

subgraph group_sources["Outage sources"]
  node_source_contract["Outage source contract<br/>source interface<br/>[IOutageSource.cs]"]
  node_poll_source["Production feed source<br/>HTTP source adapter"]
  node_fixture_source["Fixture source<br/>fixture adapter"]
end

node_server_bootstrap -->|"hosts"| node_poller
node_server_bootstrap -->|"exposes"| node_map_api
node_server_bootstrap -->|"hosts"| node_outage_hub
node_poller -->|"triggers"| node_sync
node_sync -->|"fetches through"| node_source_contract
node_poll_source -->|"implements"| node_source_contract
node_fixture_source -.->|"implements"| node_source_contract
node_sync -->|"processes DTOs"| node_validation_mapping
node_validation_mapping -->|"maps valid entities"| node_updater
node_updater -->|"persists changes"| node_database
node_sync -->|"publishes updates"| node_outage_hub
node_map_api -->|"queries"| node_reader
node_reader -->|"reads"| node_database
node_reader -->|"projects"| node_geojson
node_client_bootstrap -->|"mounts"| node_app
node_app -->|"uses"| node_feed_hook
node_feed_hook -->|"loads state"| node_map_api
node_feed_hook -->|"subscribes"| node_hub_client
node_hub_client -->|"connects"| node_outage_hub
node_feed_hook -->|"supplies features"| node_map
node_map -->|"drives selection"| node_selection

click node_server_bootstrap "https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Program.cs"
click node_poller "https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Services/BackgroundServices/OutagePoller.cs"
click node_sync "https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Services/OutageSyncService.cs"
click node_source_contract "https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Infrastructure/Http/IOutageSource.cs"
click node_poll_source "https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Infrastructure/Http/PollOutageSource.cs"
click node_fixture_source "https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Infrastructure/Http/FixtureOutageService.cs"
click node_validation_mapping "https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Dtos/OutageDto.cs"
click node_updater "https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Services/OutageUpdater.cs"
click node_database "https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Models/AppDbContext.cs"
click node_reader "https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Services/OutageReader.cs"
click node_geojson "https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Models/OutageEntityToGeojson.cs"
click node_map_api "https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Controllers/OutageMapController.cs"
click node_outage_hub "https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Hubs/OutageHub.cs"
click node_client_bootstrap "https://github.com/raycal49/outage_clone/blob/main/outagemap.client/src/main.tsx"
click node_app "https://github.com/raycal49/outage_clone/blob/main/outagemap.client/src/App.tsx"
click node_feed_hook "https://github.com/raycal49/outage_clone/blob/main/outagemap.client/src/hooks/useOutageFeed.ts"
click node_hub_client "https://github.com/raycal49/outage_clone/blob/main/outagemap.client/src/lib/outageHub.ts"
click node_map "https://github.com/raycal49/outage_clone/blob/main/outagemap.client/src/map/OutageMap.tsx"
click node_selection "https://github.com/raycal49/outage_clone/blob/main/outagemap.client/src/hooks/useOutageSelection.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_server_bootstrap,node_poller,node_sync,node_validation_mapping,node_updater,node_database,node_reader,node_geojson,node_map_api,node_outage_hub toneBlue
class node_client_bootstrap,node_app,node_feed_hook,node_hub_client,node_map,node_selection toneAmber
class node_source_contract,node_poll_source,node_fixture_source toneMint
```

## Components

### ASP.NET Core server

- [Server composition](https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Program.cs): ASP.NET Core startup · Registers HTTP, SignalR, hosted sync, and persistence. · `OutageMap.Server/Program.cs`
- [Scheduled poller](https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Services/BackgroundServices/OutagePoller.cs): hosted service · `OutageMap.Server/Services/BackgroundServices/OutagePoller.cs`
- [Outage sync](https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Services/OutageSyncService.cs): synchronization service · Fetches, validates, reconciles, and reports source updates. · `OutageMap.Server/Services/OutageSyncService.cs`
- [DTO validation and mapping](https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Dtos/OutageDto.cs): ingestion transform · Validates source DTOs and maps them to outage entities. · `OutageMap.Server/Dtos/OutageDto.cs`
- [Outage updater](https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Services/OutageUpdater.cs): reconciliation service · Applies detected entity changes. · `OutageMap.Server/Services/OutageUpdater.cs`
- [Outage database](https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Models/AppDbContext.cs): EF Core persistence · Stores outage entities and schema configuration. · `OutageMap.Server/Models/AppDbContext.cs`
- [Outage reader](https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Services/OutageReader.cs): read service · Read-side boundary over persisted outages. · `OutageMap.Server/Services/OutageReader.cs`
- [GeoJSON projection](https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Models/OutageEntityToGeojson.cs): spatial formatter · Transforms outage entities into map-ready GeoJSON. · `OutageMap.Server/Models/OutageEntityToGeojson.cs`
- [Map API](https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Controllers/OutageMapController.cs): REST controller · Serves initial and current map data. · `OutageMap.Server/Controllers/OutageMapController.cs`
- [Outage hub](https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Hubs/OutageHub.cs): SignalR hub · Publishes outage changes to connected clients. · `OutageMap.Server/Hubs/OutageHub.cs`

### React map client

- [Client bootstrap](https://github.com/raycal49/outage_clone/blob/main/outagemap.client/src/main.tsx): Vite React entry · `outagemap.client/src/main.tsx`
- [Application shell](https://github.com/raycal49/outage_clone/blob/main/outagemap.client/src/App.tsx): React app · `outagemap.client/src/App.tsx`
- [Live outage feed](https://github.com/raycal49/outage_clone/blob/main/outagemap.client/src/hooks/useOutageFeed.ts): React state hook · Combines initial map data with realtime updates. · `outagemap.client/src/hooks/useOutageFeed.ts`
- [SignalR client](https://github.com/raycal49/outage_clone/blob/main/outagemap.client/src/lib/outageHub.ts): realtime client · `outagemap.client/src/lib/outageHub.ts`
- [Outage map](https://github.com/raycal49/outage_clone/blob/main/outagemap.client/src/map/OutageMap.tsx): map renderer · Renders outage features, layers, and interactions. · `outagemap.client/src/map/OutageMap.tsx`
- [Selection and popup](https://github.com/raycal49/outage_clone/blob/main/outagemap.client/src/hooks/useOutageSelection.ts): map detail UI · Manages selected outages and their detail popup. · `outagemap.client/src/hooks/useOutageSelection.ts`

### Outage sources

- [Outage source contract](https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Infrastructure/Http/IOutageSource.cs): source interface · `OutageMap.Server/Infrastructure/Http/IOutageSource.cs`
- [Production feed source](https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Infrastructure/Http/PollOutageSource.cs): HTTP source adapter · `OutageMap.Server/Infrastructure/Http/PollOutageSource.cs`
- [Fixture source](https://github.com/raycal49/outage_clone/blob/main/OutageMap.Server/Infrastructure/Http/FixtureOutageService.cs): fixture adapter · `OutageMap.Server/Infrastructure/Http/FixtureOutageService.cs`

## Connections

- Server composition → Scheduled poller: hosts
- Server composition → Map API: exposes
- Server composition → Outage hub: hosts
- Scheduled poller → Outage sync: triggers
- Outage sync → Outage source contract: fetches through
- Production feed source → Outage source contract: implements
- Fixture source → Outage source contract: implements
- Outage sync → DTO validation and mapping: processes DTOs
- DTO validation and mapping → Outage updater: maps valid entities
- Outage updater → Outage database: persists changes
- Outage sync → Outage hub: publishes updates
- Map API → Outage reader: queries
- Outage reader → Outage database: reads
- Outage reader → GeoJSON projection: projects
- Client bootstrap → Application shell: mounts
- Application shell → Live outage feed: uses
- Live outage feed → Map API: loads state
- Live outage feed → SignalR client: subscribes
- SignalR client → Outage hub: connects
- Live outage feed → Outage map: supplies features
- Outage map → Selection and popup: drives selection
