# fatihsahin/test-flask architecture

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

- Interactive diagram: https://gitdiagram.com/fatihsahin/test-flask
- Repository: https://github.com/fatihsahin/test-flask

## Overview

TestFlask records .NET method invocations and replays them as scenario-scoped mocks. The main path is marked methods woven into playback logic, which reads request headers and communicates with the REST API to record or retrieve invocations; the API persists scenarios and invocation data in MongoDB. The repository also includes scenario-management UI, client header helpers, and a CLI that generates MSTest scenarios. Edges reflect README statements and indexed or excerpted source references; some API and integration details are documented but not sampled directly.

Main entry points: [`TestFlask.API/Controllers`](https://github.com/fatihsahin/test-flask/tree/master/TestFlask.API/Controllers) (REST API), [`TestFlask.Aspects/Player/FuncPlayer.cs`](https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Aspects/Player/FuncPlayer.cs) (Invocation players), [`TestFlask.Data/Repos/ScenarioRepo.cs`](https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Data/Repos/ScenarioRepo.cs) (Mongo repositories), [`TestFlask.Models/Entity/Invocation.cs`](https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Models/Entity/Invocation.cs) (Scenario data model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_playback["Interception and playback"]
  node_weaver["IL weaver<br/>[ModuleWeaver.cs]"]
  node_players["Invocation players<br/>[FuncPlayer.cs]"]
  node_context["Request context"]
  node_api_client["API client<br/>[TestFlaskApi.cs]"]
end

subgraph group_persistence["Scenario persistence"]
  node_api["REST API<br/>[Controllers]"]
  node_loader["Step loader<br/>[StepLoader.cs]"]
  node_repos["Mongo repositories<br/>[ScenarioRepo.cs]"]
  node_cache["API cache<br/>[ApiCache.cs]"]
  node_entities["Scenario data model<br/>[Invocation.cs]"]
end

subgraph group_assistant["Header and scenario tools"]
  node_assistant_core["Header middleware"]
  node_assistant_ui["Scenario assistant UI"]
  node_assistant_api["Assistant API client<br/>[TestFlaskApi.cs]"]
end

subgraph group_generation["Test generation"]
  node_cli["MSTest generator<br/>[MSTestGen.cs]"]
end

node_app(("Instrumented .NET app"))
node_mongo[("MongoDB")]
node_service(("WCF or REST service"))
node_generated_tests["Generated scenario tests"]

node_app -->|"builds marked methods"| node_weaver
node_weaver -->|"injects players"| node_players
node_players -->|"reads mode"| node_context
node_players -->|"calls API"| node_api_client
node_context -->|"reads request headers"| node_service
node_api_client -->|"records or retrieves"| node_api
node_api -->|"uses repositories"| node_repos
node_api -->|"loads steps"| node_loader
node_api -->|"invalidates cache"| node_cache
node_repos -->|"persists data"| node_mongo
node_repos -->|"stores entities"| node_entities
node_api -->|"handles scenarios"| node_entities
node_assistant_core -->|"adds test headers"| node_service
node_assistant_ui -->|"requests scenarios"| node_assistant_api
node_assistant_api -.->|"manages scenarios"| node_api
node_cli -->|"generates tests"| node_generated_tests
node_cli -->|"reads scenarios"| node_entities

click node_weaver "https://github.com/fatihsahin/test-flask/blob/master/TestFlaskAddin/ModuleWeaver.cs"
click node_players "https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Aspects/Player/FuncPlayer.cs"
click node_context "https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Aspects/Context/TestFlaskContext.cs"
click node_api_client "https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Aspects/ApiClient/TestFlaskApi.cs"
click node_api "https://github.com/fatihsahin/test-flask/tree/master/TestFlask.API/Controllers"
click node_loader "https://github.com/fatihsahin/test-flask/blob/master/TestFlask.API/Loader/StepLoader.cs"
click node_repos "https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Data/Repos/ScenarioRepo.cs"
click node_cache "https://github.com/fatihsahin/test-flask/blob/master/TestFlask.API/Cache/ApiCache.cs"
click node_entities "https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Models/Entity/Invocation.cs"
click node_assistant_core "https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Assistant.Core/WebApi/TestFlaskMessageHandler.cs"
click node_assistant_ui "https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Assistant.Mvc/Areas/TestFlask/Controllers/TestFlaskAssistantController.cs"
click node_assistant_api "https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Assistant.Mvc/ApiClient/TestFlaskApi.cs"
click node_cli "https://github.com/fatihsahin/test-flask/blob/master/TestFlask.CLI/UnitTestGen/T4/MSTestGen.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_weaver,node_players,node_context,node_api_client toneBlue
class node_api,node_loader,node_repos,node_cache,node_entities,node_mongo toneAmber
class node_assistant_core,node_assistant_ui,node_assistant_api toneMint
class node_cli toneRose
class node_app,node_service,node_generated_tests toneIndigo
```

## Components

### Interception and playback

- [IL weaver](https://github.com/fatihsahin/test-flask/blob/master/TestFlaskAddin/ModuleWeaver.cs): `TestFlaskAddin/ModuleWeaver.cs`
- [Invocation players](https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Aspects/Player/FuncPlayer.cs): `TestFlask.Aspects/Player/FuncPlayer.cs`
- [Request context](https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Aspects/Context/TestFlaskContext.cs): `TestFlask.Aspects/Context/TestFlaskContext.cs`
- [API client](https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Aspects/ApiClient/TestFlaskApi.cs): `TestFlask.Aspects/ApiClient/TestFlaskApi.cs`

### Scenario persistence

- [REST API](https://github.com/fatihsahin/test-flask/tree/master/TestFlask.API/Controllers): `TestFlask.API/Controllers`
- [Step loader](https://github.com/fatihsahin/test-flask/blob/master/TestFlask.API/Loader/StepLoader.cs): `TestFlask.API/Loader/StepLoader.cs`
- [Mongo repositories](https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Data/Repos/ScenarioRepo.cs): `TestFlask.Data/Repos/ScenarioRepo.cs`
- [API cache](https://github.com/fatihsahin/test-flask/blob/master/TestFlask.API/Cache/ApiCache.cs): `TestFlask.API/Cache/ApiCache.cs`
- [Scenario data model](https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Models/Entity/Invocation.cs): `TestFlask.Models/Entity/Invocation.cs`

### Header and scenario tools

- [Header middleware](https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Assistant.Core/WebApi/TestFlaskMessageHandler.cs): `TestFlask.Assistant.Core/WebApi/TestFlaskMessageHandler.cs`
- [Scenario assistant UI](https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Assistant.Mvc/Areas/TestFlask/Controllers/TestFlaskAssistantController.cs): `TestFlask.Assistant.Mvc/Areas/TestFlask/Controllers/TestFlaskAssistantController.cs`
- [Assistant API client](https://github.com/fatihsahin/test-flask/blob/master/TestFlask.Assistant.Mvc/ApiClient/TestFlaskApi.cs): `TestFlask.Assistant.Mvc/ApiClient/TestFlaskApi.cs`

### Test generation

- [MSTest generator](https://github.com/fatihsahin/test-flask/blob/master/TestFlask.CLI/UnitTestGen/T4/MSTestGen.cs): `TestFlask.CLI/UnitTestGen/T4/MSTestGen.cs`

### Other components

- **Instrumented .NET app**
- **MongoDB**
- **WCF or REST service**
- **Generated scenario tests**

## Connections

- Instrumented .NET app → IL weaver: builds marked methods
- IL weaver → Invocation players: injects players (evidence: `TestFlaskAddin/ModuleWeaver.cs`)
- Invocation players → Request context: reads mode
- Invocation players → API client: calls API
- Request context → WCF or REST service: reads request headers (evidence: `TestFlask.Aspects/Context/TestFlaskContext.cs`)
- API client → REST API: records or retrieves
- REST API → Mongo repositories: uses repositories (evidence: `TestFlask.API/Controllers/ScenarioController.cs`)
- REST API → Step loader: loads steps (evidence: `TestFlask.API/Controllers/ScenarioController.cs`)
- REST API → API cache: invalidates cache (evidence: `TestFlask.API/Controllers/ScenarioController.cs`)
- Mongo repositories → MongoDB: persists data
- Mongo repositories → Scenario data model: stores entities (evidence: `TestFlask.Data/Repos/ScenarioRepo.cs`)
- REST API → Scenario data model: handles scenarios (evidence: `TestFlask.API/Controllers/ScenarioController.cs`)
- Header middleware → WCF or REST service: adds test headers (evidence: `TestFlask.Assistant.Core/WebApi/TestFlaskMessageHandler.cs`)
- Scenario assistant UI → Assistant API client: requests scenarios (evidence: `TestFlask.Assistant.Mvc/Areas/TestFlask/Controllers/TestFlaskAssistantController.cs`)
- Assistant API client → REST API: manages scenarios
- MSTest generator → Generated scenario tests: generates tests
- MSTest generator → Scenario data model: reads scenarios (evidence: `TestFlask.CLI/UnitTestGen/T4/MSTestGen.cs`)
