# swajithanand/ai-artifact-generator architecture

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

- Interactive diagram: https://gitdiagram.com/swajithanand/ai-artifact-generator
- Repository: https://github.com/swajithanand/ai-artifact-generator

## Overview

AI Artifact Generator turns a business use case into Agile artifacts through a React UI, a FastAPI generation flow, and optional persistence. Users configure a BYOK provider, submit context and artifact type, receive structured output for Markdown display, and can revisit history. The documented product also includes provider-key validation, artifact-specific Epic/Feature/User Story prompts, and browser-only key storage. Backend route details are excerpted only in part; history and provider-to-vendor links are documented in the README, so those edges cite it.

Main entry points: [`main.py`](https://github.com/swajithanand/ai-artifact-generator/blob/main/main.py) (API routes), [`components/ArtifactGenerator.tsx`](https://github.com/swajithanand/ai-artifact-generator/blob/main/components/ArtifactGenerator.tsx) (Artifact workspace), [`strategies.py`](https://github.com/swajithanand/ai-artifact-generator/blob/main/strategies.py) (Provider factory), [`components/SettingsModal.tsx`](https://github.com/swajithanand/ai-artifact-generator/blob/main/components/SettingsModal.tsx) (Provider settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser experience"]
  node_app["App shell<br/>[App.tsx]"]
  node_generator["Artifact workspace"]
  node_settings["Provider settings<br/>[SettingsModal.tsx]"]
  node_key_storage[("Browser key storage<br/>[llmSettings.ts]")]
  node_api_config["API endpoint config<br/>[config.ts]"]
  node_markdown["Markdown result"]
end

subgraph group_backend["Generation backend"]
  node_api["API routes<br/>[main.py]"]
  node_request_models["Artifact models<br/>[models.py]"]
  node_prompt_router["Prompt router<br/>[prompts.py]"]
  node_parser["Artifact parser<br/>[main.py]"]
end

subgraph group_providers["LLM providers"]
  node_provider_registry["Provider factory<br/>[strategies.py]"]
  node_gemini["Gemini"]
  node_openai["OpenAI"]
  node_anthropic["Anthropic"]
end

subgraph group_persistence["Artifact history"]
  node_persistence_service["Persistence service<br/>[main.py]"]
  node_database[("History database<br/>[database.py]")]
  node_postgres[("Supabase Postgres")]
end

node_user(("User"))

node_user -->|"opens app"| node_app
node_app -->|"renders"| node_generator
node_user -->|"configures provider"| node_settings
node_settings -->|"saves settings"| node_key_storage
node_generator -->|"loads settings"| node_key_storage
node_settings -->|"tests key"| node_api
node_generator -->|"submits request"| node_api
node_generator -->|"uses endpoint"| node_api_config
node_api -->|"builds provider"| node_provider_registry
node_api -->|"accepts models"| node_request_models
node_provider_registry -->|"constructs prompt"| node_prompt_router
node_api -->|"validates prompt"| node_prompt_router
node_provider_registry -->|"calls API"| node_gemini
node_provider_registry -->|"calls API"| node_openai
node_provider_registry -->|"calls API"| node_anthropic
node_provider_registry -->|"returns raw text"| node_api
node_api -->|"parses output"| node_parser
node_api -->|"saves artifact"| node_persistence_service
node_persistence_service -->|"uses session"| node_database
node_database -->|"stores history"| node_postgres
node_api -->|"returns artifact"| node_generator
node_generator -->|"renders markdown"| node_markdown
node_generator -->|"fetches history"| node_api

click node_app "https://github.com/swajithanand/ai-artifact-generator/blob/main/App.tsx"
click node_generator "https://github.com/swajithanand/ai-artifact-generator/blob/main/components/ArtifactGenerator.tsx"
click node_settings "https://github.com/swajithanand/ai-artifact-generator/blob/main/components/SettingsModal.tsx"
click node_key_storage "https://github.com/swajithanand/ai-artifact-generator/blob/main/llmSettings.ts"
click node_api_config "https://github.com/swajithanand/ai-artifact-generator/blob/main/config.ts"
click node_api "https://github.com/swajithanand/ai-artifact-generator/blob/main/main.py"
click node_request_models "https://github.com/swajithanand/ai-artifact-generator/blob/main/models.py"
click node_prompt_router "https://github.com/swajithanand/ai-artifact-generator/blob/main/prompts.py"
click node_provider_registry "https://github.com/swajithanand/ai-artifact-generator/blob/main/strategies.py"
click node_parser "https://github.com/swajithanand/ai-artifact-generator/blob/main/main.py"
click node_persistence_service "https://github.com/swajithanand/ai-artifact-generator/blob/main/main.py"
click node_database "https://github.com/swajithanand/ai-artifact-generator/blob/main/database.py"
click node_markdown "https://github.com/swajithanand/ai-artifact-generator/blob/main/components/ArtifactGenerator.tsx"

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_generator,node_settings,node_key_storage,node_api_config,node_markdown,node_user toneBlue
class node_api,node_request_models,node_prompt_router,node_parser toneAmber
class node_provider_registry,node_gemini,node_openai,node_anthropic toneMint
class node_persistence_service,node_database,node_postgres toneRose
```

## Components

### Browser experience

- [App shell](https://github.com/swajithanand/ai-artifact-generator/blob/main/App.tsx): `App.tsx`
- [Artifact workspace](https://github.com/swajithanand/ai-artifact-generator/blob/main/components/ArtifactGenerator.tsx): `components/ArtifactGenerator.tsx`
- [Provider settings](https://github.com/swajithanand/ai-artifact-generator/blob/main/components/SettingsModal.tsx): `components/SettingsModal.tsx`
- [Browser key storage](https://github.com/swajithanand/ai-artifact-generator/blob/main/llmSettings.ts): `llmSettings.ts`
- [API endpoint config](https://github.com/swajithanand/ai-artifact-generator/blob/main/config.ts): `config.ts`
- [Markdown result](https://github.com/swajithanand/ai-artifact-generator/blob/main/components/ArtifactGenerator.tsx): `components/ArtifactGenerator.tsx`

### Generation backend

- [API routes](https://github.com/swajithanand/ai-artifact-generator/blob/main/main.py): `main.py`
- [Artifact models](https://github.com/swajithanand/ai-artifact-generator/blob/main/models.py): `models.py`
- [Prompt router](https://github.com/swajithanand/ai-artifact-generator/blob/main/prompts.py): `prompts.py`
- [Artifact parser](https://github.com/swajithanand/ai-artifact-generator/blob/main/main.py): `main.py`

### LLM providers

- [Provider factory](https://github.com/swajithanand/ai-artifact-generator/blob/main/strategies.py): `strategies.py`
- **Gemini**
- **OpenAI**
- **Anthropic**

### Artifact history

- [Persistence service](https://github.com/swajithanand/ai-artifact-generator/blob/main/main.py): `main.py`
- [History database](https://github.com/swajithanand/ai-artifact-generator/blob/main/database.py): `database.py`
- **Supabase Postgres**

### Other components

- **User**

## Connections

- User → App shell: opens app (evidence: `README.md`)
- App shell → Artifact workspace: renders (evidence: `App.tsx`)
- User → Provider settings: configures provider (evidence: `README.md`)
- Provider settings → Browser key storage: saves settings (evidence: `components/SettingsModal.tsx`)
- Artifact workspace → Browser key storage: loads settings (evidence: `components/ArtifactGenerator.tsx`)
- Provider settings → API routes: tests key (evidence: `components/SettingsModal.tsx`)
- Artifact workspace → API routes: submits request (evidence: `components/ArtifactGenerator.tsx`)
- Artifact workspace → API endpoint config: uses endpoint (evidence: `components/ArtifactGenerator.tsx`)
- API routes → Provider factory: builds provider (evidence: `main.py`)
- API routes → Artifact models: accepts models (evidence: `main.py`)
- Provider factory → Prompt router: constructs prompt (evidence: `strategies.py`)
- API routes → Prompt router: validates prompt (evidence: `main.py`)
- Provider factory → Gemini: calls API (evidence: `README.md`)
- Provider factory → OpenAI: calls API (evidence: `README.md`)
- Provider factory → Anthropic: calls API (evidence: `README.md`)
- Provider factory → API routes: returns raw text (evidence: `README.md`)
- API routes → Artifact parser: parses output (evidence: `README.md`)
- API routes → Persistence service: saves artifact (evidence: `main.py`)
- Persistence service → History database: uses session (evidence: `main.py`)
- History database → Supabase Postgres: stores history (evidence: `README.md`)
- API routes → Artifact workspace: returns artifact (evidence: `README.md`)
- Artifact workspace → Markdown result: renders markdown (evidence: `components/ArtifactGenerator.tsx`)
- Artifact workspace → API routes: fetches history (evidence: `README.md`)
