# msferraresi/service_doppel architecture

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

- Interactive diagram: https://gitdiagram.com/msferraresi/service_doppel
- Repository: https://github.com/msferraresi/service_doppel

## Overview

ServiceDoppel is a configurable HTTP mock hub: callers send requests to a catch-all route, which matches an active service endpoint, selects a response scenario, records the request, applies configured latency, and returns the scenario response. The SQLite-backed configuration describes services, endpoint patterns, and scenarios; a seed routine provides an example setup. Relationships below are limited to those shown in the excerpts or source index; the README is empty, and unshown administrative capabilities are not inferred.

Main entry points: [`src/server/app.py`](https://github.com/msferraresi/service_doppel/blob/main/src/server/app.py) (Catch-all API), [`src/db/models.py`](https://github.com/msferraresi/service_doppel/blob/main/src/db/models.py) (Service records), [`src/db/database.py`](https://github.com/msferraresi/service_doppel/blob/main/src/db/database.py) (SQLite database), [`main.py`](https://github.com/msferraresi/service_doppel/blob/main/main.py) (App startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingress["Request ingress"]
  node_startup["App startup<br/>[main.py]"]
  node_api["Catch-all API<br/>[app.py]"]
end

subgraph group_execution["Matching and response"]
  node_matcher["Endpoint matcher<br/>[matcher.py]"]
  node_dispatcher["Scenario selector<br/>[dispatcher.py]"]
  node_latency["Latency simulation<br/>[dispatcher.py]"]
  node_response["Mock response<br/>[app.py]"]
end

subgraph group_persistence["Configuration and storage"]
  node_seed["Example seeding<br/>[seed.py]"]
  node_records["Service records<br/>[models.py]"]
  node_audit["Request audit<br/>[models.py]"]
  node_sqlite[("SQLite database<br/>[database.py]")]
end

node_caller(("API caller"))

node_caller -->|"sends request"| node_api
node_startup -->|"initializes schema"| node_sqlite
node_startup -->|"runs app"| node_api
node_api -->|"matches route"| node_matcher
node_matcher -->|"queries endpoints"| node_records
node_api -->|"resolves scenario"| node_dispatcher
node_dispatcher -->|"reads scenarios"| node_records
node_api -->|"records request"| node_audit
node_api -->|"commits audit"| node_sqlite
node_api -->|"simulates delay"| node_latency
node_api -->|"returns scenario body"| node_response
node_response -->|"sends response"| node_caller
node_seed -->|"creates examples"| node_records
node_seed -->|"persists seed data"| node_sqlite
node_records -->|"defines schema"| node_sqlite

click node_startup "https://github.com/msferraresi/service_doppel/blob/main/main.py"
click node_api "https://github.com/msferraresi/service_doppel/blob/main/src/server/app.py"
click node_matcher "https://github.com/msferraresi/service_doppel/blob/main/src/engine/matcher.py"
click node_dispatcher "https://github.com/msferraresi/service_doppel/blob/main/src/engine/dispatcher.py"
click node_latency "https://github.com/msferraresi/service_doppel/blob/main/src/engine/dispatcher.py"
click node_response "https://github.com/msferraresi/service_doppel/blob/main/src/server/app.py"
click node_seed "https://github.com/msferraresi/service_doppel/blob/main/src/seed.py"
click node_records "https://github.com/msferraresi/service_doppel/blob/main/src/db/models.py"
click node_audit "https://github.com/msferraresi/service_doppel/blob/main/src/db/models.py"
click node_sqlite "https://github.com/msferraresi/service_doppel/blob/main/src/db/database.py"

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_startup,node_api toneBlue
class node_matcher,node_dispatcher,node_latency,node_response toneAmber
class node_seed,node_records,node_audit,node_sqlite,node_caller toneMint
```

## Components

### Request ingress

- [App startup](https://github.com/msferraresi/service_doppel/blob/main/main.py): `main.py`
- [Catch-all API](https://github.com/msferraresi/service_doppel/blob/main/src/server/app.py): `src/server/app.py`

### Matching and response

- [Endpoint matcher](https://github.com/msferraresi/service_doppel/blob/main/src/engine/matcher.py): `src/engine/matcher.py`
- [Scenario selector](https://github.com/msferraresi/service_doppel/blob/main/src/engine/dispatcher.py): `src/engine/dispatcher.py`
- [Latency simulation](https://github.com/msferraresi/service_doppel/blob/main/src/engine/dispatcher.py): `src/engine/dispatcher.py`
- [Mock response](https://github.com/msferraresi/service_doppel/blob/main/src/server/app.py): `src/server/app.py`

### Configuration and storage

- [Example seeding](https://github.com/msferraresi/service_doppel/blob/main/src/seed.py): `src/seed.py`
- [Service records](https://github.com/msferraresi/service_doppel/blob/main/src/db/models.py): `src/db/models.py`
- [Request audit](https://github.com/msferraresi/service_doppel/blob/main/src/db/models.py): `src/db/models.py`
- [SQLite database](https://github.com/msferraresi/service_doppel/blob/main/src/db/database.py): `src/db/database.py`

### Other components

- **API caller**

## Connections

- API caller → Catch-all API: sends request (evidence: `src/server/app.py`)
- App startup → SQLite database: initializes schema (evidence: `main.py`)
- App startup → Catch-all API: runs app (evidence: `main.py`)
- Catch-all API → Endpoint matcher: matches route (evidence: `src/server/app.py`)
- Endpoint matcher → Service records: queries endpoints (evidence: `src/engine/matcher.py`)
- Catch-all API → Scenario selector: resolves scenario (evidence: `src/server/app.py`)
- Scenario selector → Service records: reads scenarios (evidence: `src/engine/dispatcher.py`)
- Catch-all API → Request audit: records request (evidence: `src/server/app.py`)
- Catch-all API → SQLite database: commits audit (evidence: `src/server/app.py`)
- Catch-all API → Latency simulation: simulates delay (evidence: `src/server/app.py`)
- Catch-all API → Mock response: returns scenario body (evidence: `src/server/app.py`)
- Mock response → API caller: sends response (evidence: `src/server/app.py`)
- Example seeding → Service records: creates examples (evidence: `src/seed.py`)
- Example seeding → SQLite database: persists seed data (evidence: `src/seed.py`)
- Service records → SQLite database: defines schema (evidence: `src/db/models.py`)
