# nand-o/tampt architecture

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

- Interactive diagram: https://gitdiagram.com/nand-o/tampt
- Repository: https://github.com/nand-o/tampt

## Overview

Tampt turns a rough idea into an editable prompt through purpose/depth selection, optional clarification, and result review; users can copy/share results and resume drafts or saved prompts from local history. The Flutter app calls a FastAPI compose service, which validates requests, reserves quota, invokes a configured provider, and validates the response. Reporting is a separate backend capability. Mobile component relationships are limited to the README’s documented workflow because mobile implementation files were not excerpted; backend links cite sampled source.

Main entry points: [`backend/app/main.py`](https://github.com/nand-o/tampt/blob/main/backend/app/main.py) (FastAPI endpoints), [`mobile/lib/features/session/session_controller.dart`](https://github.com/nand-o/tampt/blob/main/mobile/lib/features/session/session_controller.dart) (Session controller), [`backend/app/providers/base.py`](https://github.com/nand-o/tampt/blob/main/backend/app/providers/base.py) (Provider interface), [`backend/app/providers/gemini.py`](https://github.com/nand-o/tampt/blob/main/backend/app/providers/gemini.py) (Gemini adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Flutter app"]
  node_app["App shell<br/>[app.dart]"]
  node_home["Start and purpose<br/>[home_screen.dart]"]
  node_home_sheets["Purpose and depth<br/>[home_sheets.dart]"]
  node_session["Session screen"]
  node_controller["Session controller"]
  node_clarify["Clarification view<br/>[clarify_view.dart]"]
  node_result["Prompt result<br/>[result_view.dart]"]
  node_compose_api["Compose API client<br/>[compose_api.dart]"]
  node_history_screen["History screen"]
  node_settings_screen["Settings screen"]
end

subgraph group_backend["Compose service"]
  node_api["FastAPI endpoints<br/>[main.py]"]
  node_schemas["API contracts<br/>[schemas.py]"]
  node_quota["Quota enforcement<br/>[quota.py]"]
  node_rules["Response rules<br/>[rules.py]"]
  node_instructions["Model instructions<br/>[instructions.py]"]
  node_report_file[("Report JSONL file<br/>[main.py]")]
end

subgraph group_provider["Model providers"]
  node_provider_contract["Provider interface<br/>[base.py]"]
  node_fake_provider["Fake provider<br/>[fake.py]"]
  node_gemini_provider["Gemini adapter<br/>[gemini.py]"]
end

subgraph group_state["Local state"]
  node_session_repo["Session repository"]
  node_local_db[("Local database")]
  node_settings_store[("Settings store")]
end

node_user(("App user"))
node_gemini["Gemini API"]

node_user -->|"starts workflow"| node_home
node_home -->|"chooses purpose and depth"| node_home_sheets
node_home -->|"starts session"| node_session
node_session -->|"manages session"| node_controller
node_controller -->|"requests composition"| node_compose_api
node_compose_api -->|"sends compose request"| node_api
node_api -->|"validates request"| node_schemas
node_api -->|"reserves quota"| node_quota
node_api -->|"invokes provider"| node_provider_contract
node_api -->|"builds response"| node_rules
node_rules -->|"validates output"| node_schemas
node_provider_contract -->|"accepts compose request"| node_schemas
node_fake_provider -->|"implements interface"| node_provider_contract
node_gemini_provider -->|"implements interface"| node_provider_contract
node_gemini_provider -->|"uses instructions"| node_instructions
node_gemini_provider -->|"generates content"| node_gemini
node_api -->|"appends report"| node_report_file
node_controller -->|"shows questions"| node_clarify
node_controller -->|"shows editable prompt"| node_result
node_result -->|"copies or shares"| node_user
node_controller -->|"resumes drafts"| node_session_repo
node_session_repo -.->|"stores sessions"| node_local_db
node_history_screen -->|"opens saved prompts"| node_session_repo
node_settings_screen -.->|"manages settings"| node_settings_store

click node_app "https://github.com/nand-o/tampt/blob/main/mobile/lib/app.dart"
click node_home "https://github.com/nand-o/tampt/blob/main/mobile/lib/features/home/home_screen.dart"
click node_home_sheets "https://github.com/nand-o/tampt/blob/main/mobile/lib/features/home/home_sheets.dart"
click node_session "https://github.com/nand-o/tampt/blob/main/mobile/lib/features/session/session_screen.dart"
click node_controller "https://github.com/nand-o/tampt/blob/main/mobile/lib/features/session/session_controller.dart"
click node_clarify "https://github.com/nand-o/tampt/blob/main/mobile/lib/features/session/clarify_view.dart"
click node_result "https://github.com/nand-o/tampt/blob/main/mobile/lib/features/session/result_view.dart"
click node_compose_api "https://github.com/nand-o/tampt/blob/main/mobile/lib/data/api/compose_api.dart"
click node_history_screen "https://github.com/nand-o/tampt/blob/main/mobile/lib/features/history/history_screen.dart"
click node_settings_screen "https://github.com/nand-o/tampt/blob/main/mobile/lib/features/settings/settings_screen.dart"
click node_session_repo "https://github.com/nand-o/tampt/blob/main/mobile/lib/data/session_repository.dart"
click node_local_db "https://github.com/nand-o/tampt/blob/main/mobile/lib/data/db/tampt_database.dart"
click node_settings_store "https://github.com/nand-o/tampt/blob/main/mobile/lib/data/settings_store.dart"
click node_api "https://github.com/nand-o/tampt/blob/main/backend/app/main.py"
click node_schemas "https://github.com/nand-o/tampt/blob/main/backend/app/schemas.py"
click node_quota "https://github.com/nand-o/tampt/blob/main/backend/app/quota.py"
click node_rules "https://github.com/nand-o/tampt/blob/main/backend/app/rules.py"
click node_instructions "https://github.com/nand-o/tampt/blob/main/backend/app/instructions.py"
click node_provider_contract "https://github.com/nand-o/tampt/blob/main/backend/app/providers/base.py"
click node_fake_provider "https://github.com/nand-o/tampt/blob/main/backend/app/providers/fake.py"
click node_gemini_provider "https://github.com/nand-o/tampt/blob/main/backend/app/providers/gemini.py"
click node_report_file "https://github.com/nand-o/tampt/blob/main/backend/app/main.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_home,node_home_sheets,node_session,node_controller,node_clarify,node_result,node_compose_api,node_history_screen,node_settings_screen,node_user toneBlue
class node_api,node_schemas,node_quota,node_rules,node_instructions,node_report_file toneAmber
class node_provider_contract,node_fake_provider,node_gemini_provider,node_gemini toneMint
class node_session_repo,node_local_db,node_settings_store toneRose
```

## Components

### Flutter app

- [App shell](https://github.com/nand-o/tampt/blob/main/mobile/lib/app.dart): `mobile/lib/app.dart`
- [Start and purpose](https://github.com/nand-o/tampt/blob/main/mobile/lib/features/home/home_screen.dart): `mobile/lib/features/home/home_screen.dart`
- [Purpose and depth](https://github.com/nand-o/tampt/blob/main/mobile/lib/features/home/home_sheets.dart): `mobile/lib/features/home/home_sheets.dart`
- [Session screen](https://github.com/nand-o/tampt/blob/main/mobile/lib/features/session/session_screen.dart): `mobile/lib/features/session/session_screen.dart`
- [Session controller](https://github.com/nand-o/tampt/blob/main/mobile/lib/features/session/session_controller.dart): `mobile/lib/features/session/session_controller.dart`
- [Clarification view](https://github.com/nand-o/tampt/blob/main/mobile/lib/features/session/clarify_view.dart): `mobile/lib/features/session/clarify_view.dart`
- [Prompt result](https://github.com/nand-o/tampt/blob/main/mobile/lib/features/session/result_view.dart): `mobile/lib/features/session/result_view.dart`
- [Compose API client](https://github.com/nand-o/tampt/blob/main/mobile/lib/data/api/compose_api.dart): `mobile/lib/data/api/compose_api.dart`
- [History screen](https://github.com/nand-o/tampt/blob/main/mobile/lib/features/history/history_screen.dart): `mobile/lib/features/history/history_screen.dart`
- [Settings screen](https://github.com/nand-o/tampt/blob/main/mobile/lib/features/settings/settings_screen.dart): `mobile/lib/features/settings/settings_screen.dart`

### Compose service

- [FastAPI endpoints](https://github.com/nand-o/tampt/blob/main/backend/app/main.py): `backend/app/main.py`
- [API contracts](https://github.com/nand-o/tampt/blob/main/backend/app/schemas.py): `backend/app/schemas.py`
- [Quota enforcement](https://github.com/nand-o/tampt/blob/main/backend/app/quota.py): `backend/app/quota.py`
- [Response rules](https://github.com/nand-o/tampt/blob/main/backend/app/rules.py): `backend/app/rules.py`
- [Model instructions](https://github.com/nand-o/tampt/blob/main/backend/app/instructions.py): `backend/app/instructions.py`
- [Report JSONL file](https://github.com/nand-o/tampt/blob/main/backend/app/main.py): `backend/app/main.py`

### Model providers

- [Provider interface](https://github.com/nand-o/tampt/blob/main/backend/app/providers/base.py): `backend/app/providers/base.py`
- [Fake provider](https://github.com/nand-o/tampt/blob/main/backend/app/providers/fake.py): `backend/app/providers/fake.py`
- [Gemini adapter](https://github.com/nand-o/tampt/blob/main/backend/app/providers/gemini.py): `backend/app/providers/gemini.py`

### Local state

- [Session repository](https://github.com/nand-o/tampt/blob/main/mobile/lib/data/session_repository.dart): `mobile/lib/data/session_repository.dart`
- [Local database](https://github.com/nand-o/tampt/blob/main/mobile/lib/data/db/tampt_database.dart): `mobile/lib/data/db/tampt_database.dart`
- [Settings store](https://github.com/nand-o/tampt/blob/main/mobile/lib/data/settings_store.dart): `mobile/lib/data/settings_store.dart`

### Other components

- **App user**
- **Gemini API**

## Connections

- App user → Start and purpose: starts workflow (evidence: `README.md`)
- Start and purpose → Purpose and depth: chooses purpose and depth (evidence: `README.md`)
- Start and purpose → Session screen: starts session (evidence: `README.md`)
- Session screen → Session controller: manages session (evidence: `README.md`)
- Session controller → Compose API client: requests composition (evidence: `README.md`)
- Compose API client → FastAPI endpoints: sends compose request (evidence: `README.md`)
- FastAPI endpoints → API contracts: validates request (evidence: `backend/app/main.py`)
- FastAPI endpoints → Quota enforcement: reserves quota (evidence: `backend/app/main.py`)
- FastAPI endpoints → Provider interface: invokes provider (evidence: `backend/app/main.py`)
- FastAPI endpoints → Response rules: builds response (evidence: `backend/app/main.py`)
- Response rules → API contracts: validates output (evidence: `backend/app/rules.py`)
- Provider interface → API contracts: accepts compose request (evidence: `backend/app/providers/base.py`)
- Fake provider → Provider interface: implements interface (evidence: `backend/app/providers/fake.py`)
- Gemini adapter → Provider interface: implements interface (evidence: `backend/app/providers/gemini.py`)
- Gemini adapter → Model instructions: uses instructions (evidence: `backend/app/providers/gemini.py`)
- Gemini adapter → Gemini API: generates content (evidence: `backend/app/providers/gemini.py`)
- FastAPI endpoints → Report JSONL file: appends report (evidence: `backend/app/main.py`)
- Session controller → Clarification view: shows questions (evidence: `README.md`)
- Session controller → Prompt result: shows editable prompt (evidence: `README.md`)
- Prompt result → App user: copies or shares (evidence: `README.md`)
- Session controller → Session repository: resumes drafts (evidence: `README.md`)
- Session repository → Local database: stores sessions
- History screen → Session repository: opens saved prompts (evidence: `README.md`)
- Settings screen → Settings store: manages settings
