# 100-hours-a-week/ktb4-17th-ai architecture

> Architecture diagram of the GitHub repository 100-hours-a-week/ktb4-17th-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/100-hours-a-week/ktb4-17th-ai
- Repository: https://github.com/100-hours-a-week/ktb4-17th-ai

## Overview

This is a FastAPI AI API for a dating application. Its central user journey is persona onboarding: interview a user, extract and confirm a profile, then use confirmed personas in simulations or streaming practice conversations. Separate profile-trust endpoints inspect primary photos and verify a live face against one. The graph preserves documented capabilities and substantial indexed modules; many feature implementations were not sampled, so their internal links are omitted unless the README, entry point, or source index supports them.

Main entry points: [`app/main.py`](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/main.py) (FastAPI application), [`app/features/persona/service.py`](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/persona/service.py) (Onboarding workflow), [`app/features/face_verification/service.py`](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/face_verification/service.py) (Face verification), [`app/features/simulation/service.py`](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/simulation/service.py) (Simulation workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and orchestration"]
  node_app["FastAPI application<br/>[main.py]"]
end

subgraph group_persona["Persona lifecycle"]
  node_onboarding_api["Persona API<br/>[api.py]"]
  node_onboarding["Onboarding workflow<br/>[service.py]"]
  node_persona_domain["Persona domain<br/>[schemas.py]"]
  node_persona_agents["Persona agents<br/>[agents.py]"]
  node_persona_store["Persona repository<br/>[repository.py]"]
  node_extraction_api["Extraction API<br/>[api.py]"]
  node_extraction["Style extraction<br/>[service.py]"]
  node_extraction_agent["Style agent<br/>[agents.py]"]
end

subgraph group_conversation["AI conversations"]
  node_simulation_api["Simulation API<br/>[api.py]"]
  node_simulation["Simulation workflow<br/>[service.py]"]
  node_simulation_agent["Simulation agent<br/>[agents.py]"]
  node_simulation_report["Matching report<br/>[report.py]"]
  node_migration_api["Migration API<br/>[api.py]"]
  node_migration_manager["Run manager<br/>[manager.py]"]
  node_migration_graph["Run graph<br/>[graph.py]"]
  node_migration_repo["Run repository<br/>[repository.py]"]
  node_practice_api["Practice API<br/>[api.py]"]
  node_practice["Practice workflow<br/>[service.py]"]
  node_practice_agent["Practice agent<br/>[agents.py]"]
  node_chat_end["Chat ending<br/>[service.py]"]
  node_chat_end_agent["Ending agent<br/>[agents.py]"]
end

subgraph group_trust["Profile trust"]
  node_photo_api["Photo check API<br/>[api.py]"]
  node_photo_check["Frontal photo check<br/>[service.py]"]
  node_photo_analyzer["Photo analyzer<br/>[analyzer.py]"]
  node_synthetic_api["Synthetic check API<br/>[api.py]"]
  node_synthetic_check["Synthetic detection<br/>[service.py]"]
  node_face_api["Face verification API<br/>[api.py]"]
  node_face_check["Face verification<br/>[service.py]"]
  node_liveness["Liveness detection<br/>[liveness.py]"]
  node_face_matcher["Face matcher<br/>[matcher.py]"]
end

subgraph group_platform["Shared platform"]
  node_media["Media handling<br/>[media.py]"]
  node_guardrail["Guardrail engine<br/>[engine.py]"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_app
node_app -->|"routes to"| node_onboarding_api
node_app -->|"routes to"| node_extraction_api
node_app -->|"routes to"| node_simulation_api
node_app -->|"routes to"| node_migration_api
node_app -->|"routes to"| node_practice_api
node_app -->|"routes to"| node_photo_api
node_app -->|"routes to"| node_synthetic_api
node_app -->|"routes to"| node_face_api
node_onboarding_api -->|"handles onboarding"| node_onboarding
node_onboarding -->|"generates prompts"| node_persona_agents
node_onboarding -->|"persists profiles"| node_persona_store
node_onboarding -->|"uses definitions"| node_persona_domain
node_extraction_api -->|"starts jobs"| node_extraction
node_extraction -->|"extracts style"| node_extraction_agent
node_simulation_api -->|"starts simulation"| node_simulation
node_simulation -->|"generates dialogue"| node_simulation_agent
node_simulation -->|"builds report"| node_simulation_report
node_migration_api -->|"manages runs"| node_migration_manager
node_migration_manager -->|"executes graph"| node_migration_graph
node_migration_manager -->|"persists run state"| node_migration_repo
node_practice_api -->|"handles sessions"| node_practice
node_practice -->|"generates replies"| node_practice_agent
node_practice -->|"checks responses"| node_guardrail
node_chat_end -->|"generates endings"| node_chat_end_agent
node_photo_api -->|"checks photos"| node_photo_check
node_photo_check -->|"analyzes image"| node_photo_analyzer
node_synthetic_api -->|"checks authenticity"| node_synthetic_check
node_face_api -->|"verifies identity"| node_face_check
node_face_check -->|"checks liveness"| node_liveness
node_face_check -->|"compares faces"| node_face_matcher
node_photo_check -->|"decodes uploads"| node_media
node_face_check -->|"reads media"| node_media
node_synthetic_check -->|"reads uploads"| node_media

click node_app "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/main.py"
click node_onboarding_api "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/persona/api.py"
click node_onboarding "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/persona/service.py"
click node_persona_domain "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/persona/schemas.py"
click node_persona_agents "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/persona/agents.py"
click node_persona_store "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/persona/repository.py"
click node_extraction_api "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/persona_extraction/api.py"
click node_extraction "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/persona_extraction/service.py"
click node_extraction_agent "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/persona_extraction/agents.py"
click node_simulation_api "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/simulation/api.py"
click node_simulation "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/simulation/service.py"
click node_simulation_agent "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/simulation/agents.py"
click node_simulation_report "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/simulation/report.py"
click node_migration_api "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/simulation_migration/api.py"
click node_migration_manager "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/simulation_migration/manager.py"
click node_migration_graph "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/simulation_migration/graph.py"
click node_migration_repo "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/simulation_migration/repository.py"
click node_practice_api "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/practice/api.py"
click node_practice "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/practice/service.py"
click node_practice_agent "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/practice/agents.py"
click node_chat_end "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/chat_end/service.py"
click node_chat_end_agent "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/chat_end/agents.py"
click node_photo_api "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/primary_photo/api.py"
click node_photo_check "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/primary_photo/service.py"
click node_photo_analyzer "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/primary_photo/analyzer.py"
click node_synthetic_api "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/synthetic_detection/api.py"
click node_synthetic_check "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/synthetic_detection/service.py"
click node_face_api "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/face_verification/api.py"
click node_face_check "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/face_verification/service.py"
click node_liveness "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/face_verification/liveness.py"
click node_face_matcher "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/face_verification/matcher.py"
click node_media "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/core/media.py"
click node_guardrail "https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/core/guardrail/engine.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_app,node_client toneBlue
class node_onboarding_api,node_onboarding,node_persona_domain,node_persona_agents,node_persona_store,node_extraction_api,node_extraction,node_extraction_agent toneAmber
class node_simulation_api,node_simulation,node_simulation_agent,node_simulation_report,node_migration_api,node_migration_manager,node_migration_graph,node_migration_repo,node_practice_api,node_practice,node_practice_agent,node_chat_end,node_chat_end_agent toneMint
class node_photo_api,node_photo_check,node_photo_analyzer,node_synthetic_api,node_synthetic_check,node_face_api,node_face_check,node_liveness,node_face_matcher toneRose
class node_media,node_guardrail toneIndigo
```

## Components

### API and orchestration

- [FastAPI application](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/main.py): `app/main.py`

### Persona lifecycle

- [Persona API](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/persona/api.py): `app/features/persona/api.py`
- [Onboarding workflow](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/persona/service.py): `app/features/persona/service.py`
- [Persona domain](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/persona/schemas.py): `app/features/persona/schemas.py`
- [Persona agents](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/persona/agents.py): `app/features/persona/agents.py`
- [Persona repository](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/persona/repository.py): `app/features/persona/repository.py`
- [Extraction API](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/persona_extraction/api.py): `app/features/persona_extraction/api.py`
- [Style extraction](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/persona_extraction/service.py): `app/features/persona_extraction/service.py`
- [Style agent](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/persona_extraction/agents.py): `app/features/persona_extraction/agents.py`

### AI conversations

- [Simulation API](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/simulation/api.py): `app/features/simulation/api.py`
- [Simulation workflow](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/simulation/service.py): `app/features/simulation/service.py`
- [Simulation agent](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/simulation/agents.py): `app/features/simulation/agents.py`
- [Matching report](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/simulation/report.py): `app/features/simulation/report.py`
- [Migration API](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/simulation_migration/api.py): `app/features/simulation_migration/api.py`
- [Run manager](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/simulation_migration/manager.py): `app/features/simulation_migration/manager.py`
- [Run graph](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/simulation_migration/graph.py): `app/features/simulation_migration/graph.py`
- [Run repository](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/simulation_migration/repository.py): `app/features/simulation_migration/repository.py`
- [Practice API](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/practice/api.py): `app/features/practice/api.py`
- [Practice workflow](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/practice/service.py): `app/features/practice/service.py`
- [Practice agent](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/practice/agents.py): `app/features/practice/agents.py`
- [Chat ending](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/chat_end/service.py): `app/features/chat_end/service.py`
- [Ending agent](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/chat_end/agents.py): `app/features/chat_end/agents.py`

### Profile trust

- [Photo check API](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/primary_photo/api.py): `app/features/primary_photo/api.py`
- [Frontal photo check](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/primary_photo/service.py): `app/features/primary_photo/service.py`
- [Photo analyzer](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/primary_photo/analyzer.py): `app/features/primary_photo/analyzer.py`
- [Synthetic check API](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/synthetic_detection/api.py): `app/features/synthetic_detection/api.py`
- [Synthetic detection](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/synthetic_detection/service.py): `app/features/synthetic_detection/service.py`
- [Face verification API](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/face_verification/api.py): `app/features/face_verification/api.py`
- [Face verification](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/face_verification/service.py): `app/features/face_verification/service.py`
- [Liveness detection](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/face_verification/liveness.py): `app/features/face_verification/liveness.py`
- [Face matcher](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/features/face_verification/matcher.py): `app/features/face_verification/matcher.py`

### Shared platform

- [Media handling](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/core/media.py): `app/core/media.py`
- [Guardrail engine](https://github.com/100-hours-a-week/ktb4-17th-ai/blob/main/app/core/guardrail/engine.py): `app/core/guardrail/engine.py`

### Other components

- **API client**

## Connections

- API client → FastAPI application: sends requests (evidence: `README.md`)
- FastAPI application → Persona API: routes to (evidence: `app/main.py`)
- FastAPI application → Extraction API: routes to (evidence: `app/main.py`)
- FastAPI application → Simulation API: routes to (evidence: `app/main.py`)
- FastAPI application → Migration API: routes to (evidence: `app/main.py`)
- FastAPI application → Practice API: routes to (evidence: `app/main.py`)
- FastAPI application → Photo check API: routes to (evidence: `app/main.py`)
- FastAPI application → Synthetic check API: routes to (evidence: `app/main.py`)
- FastAPI application → Face verification API: routes to (evidence: `app/main.py`)
- Persona API → Onboarding workflow: handles onboarding
- Onboarding workflow → Persona agents: generates prompts (evidence: `app/features/persona/service.py`)
- Onboarding workflow → Persona repository: persists profiles (evidence: `app/features/persona/service.py`)
- Onboarding workflow → Persona domain: uses definitions (evidence: `app/features/persona/service.py`)
- Extraction API → Style extraction: starts jobs
- Style extraction → Style agent: extracts style (evidence: `app/features/persona_extraction/service.py`)
- Simulation API → Simulation workflow: starts simulation (evidence: `README.md`)
- Simulation workflow → Simulation agent: generates dialogue (evidence: `app/features/simulation/service.py`)
- Simulation workflow → Matching report: builds report (evidence: `app/features/simulation/service.py`)
- Migration API → Run manager: manages runs
- Run manager → Run graph: executes graph (evidence: `app/features/simulation_migration/manager.py`)
- Run manager → Run repository: persists run state (evidence: `app/features/simulation_migration/manager.py`)
- Practice API → Practice workflow: handles sessions (evidence: `README.md`)
- Practice workflow → Practice agent: generates replies (evidence: `app/features/practice/service.py`)
- Practice workflow → Guardrail engine: checks responses (evidence: `app/features/practice/service.py`)
- Chat ending → Ending agent: generates endings (evidence: `app/features/chat_end/service.py`)
- Photo check API → Frontal photo check: checks photos (evidence: `README.md`)
- Frontal photo check → Photo analyzer: analyzes image (evidence: `app/features/primary_photo/service.py`)
- Synthetic check API → Synthetic detection: checks authenticity (evidence: `README.md`)
- Face verification API → Face verification: verifies identity (evidence: `README.md`)
- Face verification → Liveness detection: checks liveness (evidence: `app/features/face_verification/service.py`)
- Face verification → Face matcher: compares faces (evidence: `app/features/face_verification/service.py`)
- Frontal photo check → Media handling: decodes uploads (evidence: `app/features/primary_photo/service.py`)
- Face verification → Media handling: reads media (evidence: `app/features/face_verification/service.py`)
- Synthetic detection → Media handling: reads uploads (evidence: `app/features/synthetic_detection/service.py`)
