# ardalis/stockpricetracker architecture

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

- Interactive diagram: https://gitdiagram.com/ardalis/stockpricetracker
- Repository: https://github.com/ardalis/stockpricetracker

## Overview

StockPriceTracker is a small authenticated stock-price API, while its main product value is the reusable integration-test harness. The graph covers both: HTTP requests exercise registration/login, antiforgery, and stock lookup/creation; shared tests boot the app against SQLite or PostgreSQL with controlled identities and seeded data. Source evidence is sampled, so relationships for documented but unsampled app setup are cited to the README; unsupported implementation links are omitted.

Main entry points: [`StockPriceTracker.Tests.Integration/WebAppFixtureBase.cs`](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/WebAppFixtureBase.cs) (Fixture Lifecycle), [`StockPriceTracker/Data/AppDbContext.cs`](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Data/AppDbContext.cs) (EF Context), [`StockPriceTracker.Tests.Integration/AuthenticationHandlers/AuthenticatedClientBuilder.cs`](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/AuthenticationHandlers/AuthenticatedClientBuilder.cs) (Auth Client Builder), [`StockPriceTracker/Endpoints/AuthEndpoints.cs`](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Endpoints/AuthEndpoints.cs) (Auth Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Stock API"]
  node_apphost["API Host<br/>[Program.cs]"]
  node_authroutes["Auth Routes<br/>[AuthEndpoints.cs]"]
  node_stockroutes["Stock Routes<br/>[StockEndpoints.cs]"]
  node_csrf["Cookie CSRF"]
end

subgraph group_authdata["Identity and Data"]
  node_authconfig["Auth Configuration"]
  node_token["JWT Issuance<br/>[TokenService.cs]"]
  node_initializer["Startup Seeding"]
  node_context["EF Context<br/>[AppDbContext.cs]"]
  node_stock["Stock Entity<br/>[Stock.cs]"]
end

subgraph group_testharness["Test Harness"]
  node_testcases["Stock Endpoint Tests<br/>[AddStockTests.cs]"]
  node_gettests["Lookup Tests<br/>[GetStockTests.cs]"]
  node_testhost["Test Web Host<br/>[Program.cs]"]
  node_fixture["Fixture Lifecycle"]
  node_testbase["Test Base<br/>[WebAppTestBase.cs]"]
  node_clientbuilder["Auth Client Builder"]
  node_claims["Claims Builder<br/>[ClaimsBuilder.cs]"]
  node_testauth["Test Auth Handler"]
  node_csrfclient["CSRF Client Helpers"]
end

subgraph group_providers["Test Databases"]
  node_sqlite["SQLite Fixture<br/>[SQLiteFixture.cs]"]
  node_postgres["PostgreSQL Fixture"]
end

node_client(("API Client"))
node_database[("Relational Database")]

node_client -->|"requests auth"| node_authroutes
node_client -->|"requests stocks"| node_stockroutes
node_client -->|"requests token"| node_csrf
node_apphost -->|"maps routes"| node_authroutes
node_apphost -->|"maps routes"| node_stockroutes
node_authroutes -->|"creates JWT"| node_token
node_authroutes -.->|"uses Identity store"| node_context
node_stockroutes -->|"queries stocks"| node_context
node_stockroutes -->|"applies protection"| node_csrf
node_context -->|"maps entity"| node_stock
node_authconfig -->|"configures providers"| node_context
node_authconfig -->|"registers service"| node_token
node_initializer -->|"seeds roles"| node_context
node_testcases -->|"extends base"| node_testbase
node_gettests -->|"extends base"| node_testbase
node_testbase -->|"uses fixture"| node_fixture
node_fixture -->|"builds host"| node_testhost
node_fixture -->|"seeds data"| node_context
node_fixture -->|"creates builder"| node_clientbuilder
node_clientbuilder -->|"builds claims"| node_claims
node_clientbuilder -->|"registers handler"| node_testauth
node_clientbuilder -.->|"supports CSRF"| node_csrfclient
node_fixture -->|"selects provider"| node_sqlite
node_fixture -->|"selects provider"| node_postgres
node_sqlite -->|"uses SQLite"| node_database
node_postgres -->|"starts container"| node_database
node_testcases -->|"drives HTTP"| node_client

click node_apphost "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Program.cs"
click node_authroutes "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Endpoints/AuthEndpoints.cs"
click node_stockroutes "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Endpoints/StockEndpoints.cs"
click node_csrf "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Security/CookieAntiforgeryFilter.cs"
click node_authconfig "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Extensions/ServiceExtensions.cs"
click node_token "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Services/TokenService.cs"
click node_initializer "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Data/DatabaseInitializer.cs"
click node_context "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Data/AppDbContext.cs"
click node_stock "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Models/Stock.cs"
click node_testcases "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/StockEndpointTests/AddStockTests.cs"
click node_gettests "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/StockEndpointTests/GetStockTests.cs"
click node_testhost "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/Program.cs"
click node_fixture "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/WebAppFixtureBase.cs"
click node_testbase "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/WebAppTestBase.cs"
click node_clientbuilder "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/AuthenticationHandlers/AuthenticatedClientBuilder.cs"
click node_claims "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/AuthenticationHandlers/ClaimsBuilder.cs"
click node_testauth "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/AuthenticationHandlers/ConfigurableTestAuthHandler.cs"
click node_csrfclient "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/AuthenticationHandlers/HttpClientCsrfExtensions.cs"
click node_sqlite "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/DatabaseFixtures/SQLiteFixture.cs"
click node_postgres "https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/DatabaseFixtures/PostgreSqlFixture.cs"

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_apphost,node_authroutes,node_stockroutes,node_csrf,node_client toneBlue
class node_authconfig,node_token,node_initializer,node_context,node_stock,node_database toneAmber
class node_testcases,node_gettests,node_testhost,node_fixture,node_testbase,node_clientbuilder,node_claims,node_testauth,node_csrfclient toneMint
class node_sqlite,node_postgres toneRose
```

## Components

### Stock API

- [API Host](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Program.cs): `StockPriceTracker/Program.cs`
- [Auth Routes](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Endpoints/AuthEndpoints.cs): `StockPriceTracker/Endpoints/AuthEndpoints.cs`
- [Stock Routes](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Endpoints/StockEndpoints.cs): `StockPriceTracker/Endpoints/StockEndpoints.cs`
- [Cookie CSRF](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Security/CookieAntiforgeryFilter.cs): `StockPriceTracker/Security/CookieAntiforgeryFilter.cs`

### Identity and Data

- [Auth Configuration](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Extensions/ServiceExtensions.cs): `StockPriceTracker/Extensions/ServiceExtensions.cs`
- [JWT Issuance](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Services/TokenService.cs): `StockPriceTracker/Services/TokenService.cs`
- [Startup Seeding](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Data/DatabaseInitializer.cs): `StockPriceTracker/Data/DatabaseInitializer.cs`
- [EF Context](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Data/AppDbContext.cs): `StockPriceTracker/Data/AppDbContext.cs`
- [Stock Entity](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker/Models/Stock.cs): `StockPriceTracker/Models/Stock.cs`

### Test Harness

- [Stock Endpoint Tests](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/StockEndpointTests/AddStockTests.cs): `StockPriceTracker.Tests.Integration/StockEndpointTests/AddStockTests.cs`
- [Lookup Tests](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/StockEndpointTests/GetStockTests.cs): `StockPriceTracker.Tests.Integration/StockEndpointTests/GetStockTests.cs`
- [Test Web Host](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/Program.cs): `StockPriceTracker.Tests.Integration/Program.cs`
- [Fixture Lifecycle](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/WebAppFixtureBase.cs): `StockPriceTracker.Tests.Integration/WebAppFixtureBase.cs`
- [Test Base](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/WebAppTestBase.cs): `StockPriceTracker.Tests.Integration/WebAppTestBase.cs`
- [Auth Client Builder](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/AuthenticationHandlers/AuthenticatedClientBuilder.cs): `StockPriceTracker.Tests.Integration/AuthenticationHandlers/AuthenticatedClientBuilder.cs`
- [Claims Builder](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/AuthenticationHandlers/ClaimsBuilder.cs): `StockPriceTracker.Tests.Integration/AuthenticationHandlers/ClaimsBuilder.cs`
- [Test Auth Handler](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/AuthenticationHandlers/ConfigurableTestAuthHandler.cs): `StockPriceTracker.Tests.Integration/AuthenticationHandlers/ConfigurableTestAuthHandler.cs`
- [CSRF Client Helpers](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/AuthenticationHandlers/HttpClientCsrfExtensions.cs): `StockPriceTracker.Tests.Integration/AuthenticationHandlers/HttpClientCsrfExtensions.cs`

### Test Databases

- [SQLite Fixture](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/DatabaseFixtures/SQLiteFixture.cs): `StockPriceTracker.Tests.Integration/DatabaseFixtures/SQLiteFixture.cs`
- [PostgreSQL Fixture](https://github.com/ardalis/stockpricetracker/blob/master/StockPriceTracker.Tests.Integration/DatabaseFixtures/PostgreSqlFixture.cs): `StockPriceTracker.Tests.Integration/DatabaseFixtures/PostgreSqlFixture.cs`

### Other components

- **API Client**
- **Relational Database**

## Connections

- API Client → Auth Routes: requests auth (evidence: `README.md`)
- API Client → Stock Routes: requests stocks (evidence: `README.md`)
- API Client → Cookie CSRF: requests token (evidence: `README.md`)
- API Host → Auth Routes: maps routes (evidence: `README.md`)
- API Host → Stock Routes: maps routes (evidence: `README.md`)
- Auth Routes → JWT Issuance: creates JWT (evidence: `StockPriceTracker/Endpoints/AuthEndpoints.cs`)
- Auth Routes → EF Context: uses Identity store
- Stock Routes → EF Context: queries stocks (evidence: `StockPriceTracker/Endpoints/StockEndpoints.cs`)
- Stock Routes → Cookie CSRF: applies protection (evidence: `StockPriceTracker/Endpoints/StockEndpoints.cs`)
- EF Context → Stock Entity: maps entity (evidence: `StockPriceTracker/Data/AppDbContext.cs`)
- Auth Configuration → EF Context: configures providers (evidence: `StockPriceTracker/Extensions/ServiceExtensions.cs`)
- Auth Configuration → JWT Issuance: registers service (evidence: `StockPriceTracker/Extensions/ServiceExtensions.cs`)
- Startup Seeding → EF Context: seeds roles (evidence: `StockPriceTracker/Data/DatabaseInitializer.cs`)
- Stock Endpoint Tests → Test Base: extends base (evidence: `StockPriceTracker.Tests.Integration/StockEndpointTests/AddStockTests.cs`)
- Lookup Tests → Test Base: extends base (evidence: `StockPriceTracker.Tests.Integration/StockEndpointTests/GetStockTests.cs`)
- Test Base → Fixture Lifecycle: uses fixture (evidence: `StockPriceTracker.Tests.Integration/WebAppTestBase.cs`)
- Fixture Lifecycle → Test Web Host: builds host (evidence: `StockPriceTracker.Tests.Integration/WebAppFixtureBase.cs`)
- Fixture Lifecycle → EF Context: seeds data (evidence: `StockPriceTracker.Tests.Integration/WebAppFixtureBase.cs`)
- Fixture Lifecycle → Auth Client Builder: creates builder (evidence: `StockPriceTracker.Tests.Integration/WebAppFixtureBase.cs`)
- Auth Client Builder → Claims Builder: builds claims (evidence: `StockPriceTracker.Tests.Integration/AuthenticationHandlers/AuthenticatedClientBuilder.cs`)
- Auth Client Builder → Test Auth Handler: registers handler (evidence: `StockPriceTracker.Tests.Integration/AuthenticationHandlers/AuthenticatedClientBuilder.cs`)
- Auth Client Builder → CSRF Client Helpers: supports CSRF
- Fixture Lifecycle → SQLite Fixture: selects provider (evidence: `StockPriceTracker.Tests.Integration/DatabaseFixtures/SQLiteFixture.cs`)
- Fixture Lifecycle → PostgreSQL Fixture: selects provider (evidence: `StockPriceTracker.Tests.Integration/DatabaseFixtures/PostgreSqlFixture.cs`)
- SQLite Fixture → Relational Database: uses SQLite (evidence: `README.md`)
- PostgreSQL Fixture → Relational Database: starts container (evidence: `StockPriceTracker.Tests.Integration/DatabaseFixtures/PostgreSqlFixture.cs`)
- Stock Endpoint Tests → API Client: drives HTTP (evidence: `StockPriceTracker.Tests.Integration/StockEndpointTests/AddStockTests.cs`)
