# matthew-kissinger/2dgag architecture

> Architecture diagram of the GitHub repository matthew-kissinger/2dgag, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/matthew-kissinger/2dgag
- Repository: https://github.com/matthew-kissinger/2dgag

## Overview

This archived Flask application generates 2D game assets through a user-guided workflow: describe a world, review its asset list, develop an aesthetic, approve image prompts, generate or regenerate images, then download a ZIP. The modular app registers separate route blueprints, with shared in-memory session storage and LM Studio and Stable Diffusion services. The README documents the product stages; source excerpts show the modular route calls. The repository also contains a legacy monolithic `app.py` implementation. Frontend-to-route wiring is not evidenced in the sampled files, so those links are omitted.

Main entry points: [`app/services/lm_studio_service.py`](https://github.com/matthew-kissinger/2dgag/blob/master/app/services/lm_studio_service.py) (LM Studio generation), [`app/__init__.py`](https://github.com/matthew-kissinger/2dgag/blob/master/app/__init__.py) (App factory), [`app/utils/helpers.py`](https://github.com/matthew-kissinger/2dgag/blob/master/app/utils/helpers.py) (Session asset state), [`app/routes/images.py`](https://github.com/matthew-kissinger/2dgag/blob/master/app/routes/images.py) (Image and export routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_ui["Studio interface<br/>[main.js]"]
  node_app_factory["App factory<br/>[__init__.py]"]
  node_page["Studio page<br/>[index.html]"]
end

subgraph group_workflow["Asset workflow"]
  node_world_routes["World and assets<br/>[game_world.py]"]
  node_aesthetic_routes["Aesthetic route<br/>[aesthetic.py]"]
  node_prompt_routes["Prompt routes<br/>[image_prompts.py]"]
  node_image_routes["Image and export routes<br/>[images.py]"]
  node_legacy_app["Legacy monolithic app<br/>[app.py]"]
end

subgraph group_services["Generation services"]
  node_lm_service["LM Studio generation"]
  node_sd_service["Stable Diffusion generation<br/>[sd3_service.py]"]
  node_config["Service configuration<br/>[config.py]"]
end

subgraph group_state["Session and export"]
  node_session_store["Session asset state<br/>[helpers.py]"]
  node_zip_export["ZIP export<br/>[helpers.py]"]
end

node_user(("Creator"))
node_lm_studio["LM Studio"]
node_stable_diffusion["Automatic1111 SD Web UI"]

node_user -.->|"uses"| node_ui
node_app_factory -->|"renders"| node_page
node_app_factory -->|"registers"| node_world_routes
node_app_factory -->|"registers"| node_aesthetic_routes
node_app_factory -->|"registers"| node_prompt_routes
node_app_factory -->|"registers"| node_image_routes
node_world_routes -->|"generates world"| node_lm_service
node_world_routes -->|"stores assets"| node_session_store
node_aesthetic_routes -->|"generates theme"| node_lm_service
node_aesthetic_routes -->|"reads and stores"| node_session_store
node_prompt_routes -->|"generates prompts"| node_lm_service
node_prompt_routes -->|"reads and stores"| node_session_store
node_image_routes -->|"generates images"| node_sd_service
node_image_routes -->|"reads and stores"| node_session_store
node_image_routes -->|"creates archive"| node_zip_export
node_zip_export -->|"reads image state"| node_session_store
node_lm_service -->|"requests completions"| node_lm_studio
node_sd_service -->|"requests images"| node_stable_diffusion
node_lm_service -->|"reads URL"| node_config
node_sd_service -->|"reads URL"| node_config
node_legacy_app -->|"calls generation"| node_lm_service
node_legacy_app -->|"requests images"| node_stable_diffusion

click node_ui "https://github.com/matthew-kissinger/2dgag/blob/master/static/js/main.js"
click node_app_factory "https://github.com/matthew-kissinger/2dgag/blob/master/app/__init__.py"
click node_page "https://github.com/matthew-kissinger/2dgag/blob/master/app/templates/index.html"
click node_world_routes "https://github.com/matthew-kissinger/2dgag/blob/master/app/routes/game_world.py"
click node_aesthetic_routes "https://github.com/matthew-kissinger/2dgag/blob/master/app/routes/aesthetic.py"
click node_prompt_routes "https://github.com/matthew-kissinger/2dgag/blob/master/app/routes/image_prompts.py"
click node_image_routes "https://github.com/matthew-kissinger/2dgag/blob/master/app/routes/images.py"
click node_legacy_app "https://github.com/matthew-kissinger/2dgag/blob/master/app.py"
click node_lm_service "https://github.com/matthew-kissinger/2dgag/blob/master/app/services/lm_studio_service.py"
click node_sd_service "https://github.com/matthew-kissinger/2dgag/blob/master/app/services/sd3_service.py"
click node_session_store "https://github.com/matthew-kissinger/2dgag/blob/master/app/utils/helpers.py"
click node_zip_export "https://github.com/matthew-kissinger/2dgag/blob/master/app/utils/helpers.py"
click node_config "https://github.com/matthew-kissinger/2dgag/blob/master/config.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_ui,node_app_factory,node_page,node_stable_diffusion toneBlue
class node_world_routes,node_aesthetic_routes,node_prompt_routes,node_image_routes,node_legacy_app toneAmber
class node_lm_service,node_sd_service,node_config toneMint
class node_session_store,node_zip_export toneRose
class node_user,node_lm_studio toneIndigo
```

## Components

### Web application

- [Studio interface](https://github.com/matthew-kissinger/2dgag/blob/master/static/js/main.js): `static/js/main.js`
- [App factory](https://github.com/matthew-kissinger/2dgag/blob/master/app/__init__.py): `app/__init__.py`
- [Studio page](https://github.com/matthew-kissinger/2dgag/blob/master/app/templates/index.html): `app/templates/index.html`

### Asset workflow

- [World and assets](https://github.com/matthew-kissinger/2dgag/blob/master/app/routes/game_world.py): `app/routes/game_world.py`
- [Aesthetic route](https://github.com/matthew-kissinger/2dgag/blob/master/app/routes/aesthetic.py): `app/routes/aesthetic.py`
- [Prompt routes](https://github.com/matthew-kissinger/2dgag/blob/master/app/routes/image_prompts.py): `app/routes/image_prompts.py`
- [Image and export routes](https://github.com/matthew-kissinger/2dgag/blob/master/app/routes/images.py): `app/routes/images.py`
- [Legacy monolithic app](https://github.com/matthew-kissinger/2dgag/blob/master/app.py): `app.py`

### Generation services

- [LM Studio generation](https://github.com/matthew-kissinger/2dgag/blob/master/app/services/lm_studio_service.py): `app/services/lm_studio_service.py`
- [Stable Diffusion generation](https://github.com/matthew-kissinger/2dgag/blob/master/app/services/sd3_service.py): `app/services/sd3_service.py`
- [Service configuration](https://github.com/matthew-kissinger/2dgag/blob/master/config.py): `config.py`

### Session and export

- [Session asset state](https://github.com/matthew-kissinger/2dgag/blob/master/app/utils/helpers.py): `app/utils/helpers.py`
- [ZIP export](https://github.com/matthew-kissinger/2dgag/blob/master/app/utils/helpers.py): `app/utils/helpers.py`

### Other components

- **Creator**
- **LM Studio**
- **Automatic1111 SD Web UI**

## Connections

- Creator → Studio interface: uses
- App factory → Studio page: renders (evidence: `app/__init__.py`)
- App factory → World and assets: registers (evidence: `app/__init__.py`)
- App factory → Aesthetic route: registers (evidence: `app/__init__.py`)
- App factory → Prompt routes: registers (evidence: `app/__init__.py`)
- App factory → Image and export routes: registers (evidence: `app/__init__.py`)
- World and assets → LM Studio generation: generates world (evidence: `app/routes/game_world.py`)
- World and assets → Session asset state: stores assets (evidence: `app/routes/game_world.py`)
- Aesthetic route → LM Studio generation: generates theme (evidence: `app/routes/aesthetic.py`)
- Aesthetic route → Session asset state: reads and stores (evidence: `app/routes/aesthetic.py`)
- Prompt routes → LM Studio generation: generates prompts (evidence: `app/routes/image_prompts.py`)
- Prompt routes → Session asset state: reads and stores (evidence: `app/routes/image_prompts.py`)
- Image and export routes → Stable Diffusion generation: generates images (evidence: `app/routes/images.py`)
- Image and export routes → Session asset state: reads and stores (evidence: `app/routes/images.py`)
- Image and export routes → ZIP export: creates archive (evidence: `app/routes/images.py`)
- ZIP export → Session asset state: reads image state (evidence: `app/utils/helpers.py`)
- LM Studio generation → LM Studio: requests completions (evidence: `app/services/lm_studio_service.py`)
- Stable Diffusion generation → Automatic1111 SD Web UI: requests images (evidence: `app/services/sd3_service.py`)
- LM Studio generation → Service configuration: reads URL (evidence: `app/services/lm_studio_service.py`)
- Stable Diffusion generation → Service configuration: reads URL (evidence: `app/services/sd3_service.py`)
- Legacy monolithic app → LM Studio generation: calls generation (evidence: `app.py`)
- Legacy monolithic app → Automatic1111 SD Web UI: requests images (evidence: `app.py`)
