# lazyai-engineer/instaai-carousel architecture

> Architecture diagram of the GitHub repository lazyai-engineer/instaai-carousel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lazyai-engineer/instaai-carousel
- Repository: https://github.com/lazyai-engineer/instaai-carousel

## Overview

InstaAI is a terminal-driven generator that turns a topic into a validated, seven-slide educational carousel and exports seven 1080 × 1350 PNGs. The main flow runs from topic entry through prompt construction, SenseNova generation, JSON parsing and content/visual validation, then deterministic HTML/CSS/SVG rendering in Playwright/Chromium. The documented slide progression—hook, motivation, concept, mechanism, example, insight, takeaway—and seven visual layout types are represented in the content strategy and renderer nodes. The source excerpts are partial, so internal details beyond the documented flow are not inferred.

Main entry points: [`InstaAI/generator.py`](https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/generator.py) (Generation orchestrator), [`InstaAI/renderer.py`](https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/renderer.py) (Carousel renderer), [`InstaAI/app.py`](https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/app.py) (Terminal app), [`InstaAI/prompts.py`](https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/prompts.py) (Seven-slide strategy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Terminal interface"]
  node_app["Terminal app<br/>[app.py]"]
end

subgraph group_generation["Content generation"]
  node_generator["Generation orchestrator<br/>[generator.py]"]
  node_strategy["Seven-slide strategy<br/>[prompts.py]"]
end

subgraph group_validation["Carousel validation"]
  node_parser["Response parser<br/>[generator.py]"]
  node_validator["Content and visual checks<br/>[generator.py]"]
end

subgraph group_rendering["Visual rendering"]
  node_renderer["Carousel renderer<br/>[renderer.py]"]
  node_visuals["Layout and SVG scenes<br/>[renderer.py]"]
  node_pngs["Seven PNG slides"]
end

node_user(("Topic author"))
node_sensenova{{"SenseNova API"}}
node_browser{{"Playwright Chromium"}}

node_user -->|"enters topic"| node_app
node_app -->|"calls generation"| node_generator
node_app -->|"clears and verifies"| node_pngs
node_generator -->|"builds prompt"| node_strategy
node_strategy -->|"returns instructions"| node_generator
node_generator -->|"requests carousel"| node_sensenova
node_sensenova -->|"returns response"| node_generator
node_generator -->|"parses JSON"| node_parser
node_parser -->|"supplies carousel"| node_validator
node_generator -->|"passes validated slides"| node_renderer
node_renderer -->|"builds slide layouts"| node_visuals
node_renderer -->|"renders pages"| node_browser
node_renderer -->|"writes slide images"| node_pngs

click node_app "https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/app.py"
click node_generator "https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/generator.py"
click node_strategy "https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/prompts.py"
click node_parser "https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/generator.py"
click node_validator "https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/generator.py"
click node_renderer "https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/renderer.py"
click node_visuals "https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/renderer.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 toneBlue
class node_generator,node_strategy toneAmber
class node_parser,node_validator,node_sensenova toneMint
class node_renderer,node_visuals,node_pngs toneRose
class node_user,node_browser toneIndigo
```

## Components

### Terminal interface

- [Terminal app](https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/app.py): `InstaAI/app.py`

### Content generation

- [Generation orchestrator](https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/generator.py): `InstaAI/generator.py`
- [Seven-slide strategy](https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/prompts.py): `InstaAI/prompts.py`

### Carousel validation

- [Response parser](https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/generator.py): `InstaAI/generator.py`
- [Content and visual checks](https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/generator.py): `InstaAI/generator.py`

### Visual rendering

- [Carousel renderer](https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/renderer.py): `InstaAI/renderer.py`
- [Layout and SVG scenes](https://github.com/lazyai-engineer/instaai-carousel/blob/main/InstaAI/renderer.py): `InstaAI/renderer.py`
- **Seven PNG slides**

### Other components

- **Topic author**
- **SenseNova API**
- **Playwright Chromium**

## Connections

- Topic author → Terminal app: enters topic
- Terminal app → Generation orchestrator: calls generation
- Terminal app → Seven PNG slides: clears and verifies
- Generation orchestrator → Seven-slide strategy: builds prompt
- Seven-slide strategy → Generation orchestrator: returns instructions
- Generation orchestrator → SenseNova API: requests carousel
- SenseNova API → Generation orchestrator: returns response
- Generation orchestrator → Response parser: parses JSON
- Response parser → Content and visual checks: supplies carousel
- Generation orchestrator → Carousel renderer: passes validated slides
- Carousel renderer → Layout and SVG scenes: builds slide layouts
- Carousel renderer → Playwright Chromium: renders pages
- Carousel renderer → Seven PNG slides: writes slide images
