# lywnl/ai-app-generation architecture

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

- Interactive diagram: https://gitdiagram.com/lywnl/ai-app-generation
- Repository: https://github.com/lywnl/ai-app-generation

## Overview

This is an AI web-app generation platform: users create or select an app, submit a prompt, watch an SSE-driven Plan/Execute/ReAct workflow, inspect generated files and plans, preview a successful build, and optionally download or publish the result. The Vue path adds persisted plans, tool-mediated file changes, build diagnostics and repair; HTML and multi-file generation retain separate generation flows. RAG and layered conversation memory enrich model context. The README documents several connections that the sampled source does not expose, so those links are shown only where explicitly described; unsampled subsystem internals are represented by exact enclosing paths.

Main entry points: [`src/main/java/com/lyw/appgeneration/controller/AppController.java`](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/controller/AppController.java) (App API), [`src/main/java/com/lyw/appgeneration/core/AiCodeGeneratorFacade.java`](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/core/AiCodeGeneratorFacade.java) (Generation facade), [`src/main/java/com/lyw/appgeneration/service/rag/RagRetrievalService.java`](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/rag/RagRetrievalService.java) (RAG retrieval), [`ai-app-generation-frontend/src/utils/generationSession.ts`](https://github.com/lywnl/ai-app-generation/blob/master/ai-app-generation-frontend/src/utils/generationSession.ts) (Generation session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Frontend"]
  node_chatui["Generation chat<br/>[AppChatPage.vue]"]
  node_session["Generation session"]
  node_previewui["Preview state"]
end

subgraph group_workflow["Generation workflow"]
  node_api["App API<br/>[AppController.java]"]
  node_appservice["App service<br/>[AppService.java]"]
  node_facade["Generation facade"]
  node_turn["Turn handling"]
  node_modelgen["Code generation model"]
  node_tools["Generation tools"]
  node_plan["Plan state"]
  node_planquery["Plan query"]
end

subgraph group_context["Context and retrieval"]
  node_rag["RAG retrieval"]
  node_vuehybrid["Vue hybrid search"]
  node_fusion["RRF fusion"]
  node_rerank["Candidate reranking"]
  node_images["Image references"]
  node_memory["Conversation memory"]
  node_summary["Memory summaries"]
  node_templates["Template ingest"]
end

subgraph group_data["Persistence"]
  node_businessdb[("Business database")]
  node_redis[("Redis memory store")]
  node_vectorstore[("Milvus templates")]
end

subgraph group_delivery["Build and delivery"]
  node_builder["Vue builder"]
  node_deployer["Site publishing"]
end

node_user(("User"))
node_ai(("AI services"))
node_site(("Published website"))

node_user -->|"enters prompt"| node_chatui
node_chatui -->|"starts generation"| node_session
node_session -->|"sends request"| node_api
node_api -->|"dispatches request"| node_appservice
node_appservice -->|"starts generation"| node_facade
node_facade -->|"manages turn"| node_turn
node_facade -->|"requests generation"| node_modelgen
node_modelgen -->|"streams model calls"| node_ai
node_facade -->|"executes tools"| node_tools
node_tools -->|"updates plan"| node_plan
node_tools -->|"requests build"| node_builder
node_turn -->|"streams events"| node_chatui
node_api -.->|"retrieves templates"| node_rag
node_rag -->|"retrieves Vue context"| node_vuehybrid
node_vuehybrid -->|"fuses rankings"| node_fusion
node_vuehybrid -->|"reranks candidates"| node_rerank
node_rag -->|"reranks candidates"| node_rerank
node_api -.->|"collects image context"| node_images
node_facade -->|"uses conversation context"| node_memory
node_memory -->|"reads and writes"| node_redis
node_summary -->|"reads history and saves summaries"| node_businessdb
node_api -->|"persists app data"| node_businessdb
node_api -->|"queries plan"| node_planquery
node_planquery -->|"loads plan"| node_plan
node_plan -.->|"persists plan state"| node_businessdb
node_templates -->|"ingests embeddings"| node_vectorstore
node_rag -->|"searches templates"| node_vectorstore
node_builder -->|"reports build outcome"| node_session
node_session -->|"updates preview state"| node_previewui
node_user -.->|"requests publishing"| node_api
node_api -.->|"publishes app"| node_deployer
node_deployer -.->|"provides website"| node_site

click node_chatui "https://github.com/lywnl/ai-app-generation/blob/master/ai-app-generation-frontend/src/pages/app/AppChatPage.vue"
click node_session "https://github.com/lywnl/ai-app-generation/blob/master/ai-app-generation-frontend/src/utils/generationSession.ts"
click node_previewui "https://github.com/lywnl/ai-app-generation/blob/master/ai-app-generation-frontend/src/composables/useGenerationPreview.ts"
click node_api "https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/controller/AppController.java"
click node_appservice "https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/AppService.java"
click node_facade "https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/core/AiCodeGeneratorFacade.java"
click node_turn "https://github.com/lywnl/ai-app-generation/tree/master/src/main/java/com/lyw/appgeneration/core/handler"
click node_modelgen "https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/ai/AiCodeGeneratorService.java"
click node_tools "https://github.com/lywnl/ai-app-generation/tree/master/src/main/java/com/lyw/appgeneration/ai/tools"
click node_plan "https://github.com/lywnl/ai-app-generation/tree/master/src/main/java/com/lyw/appgeneration/ai/plan"
click node_builder "https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/core/builder/VueProjectBuilder.java"
click node_rag "https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/rag/RagRetrievalService.java"
click node_vuehybrid "https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/rag/VueHybridRetrievalService.java"
click node_fusion "https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/rag/retrieval/RrfFusionService.java"
click node_rerank "https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/rag/RagRerankService.java"
click node_images "https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/ai/image/ImageCollectionService.java"
click node_memory "https://github.com/lywnl/ai-app-generation/tree/master/src/main/java/com/lyw/appgeneration/ai/memory"
click node_summary "https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/impl/MemorySummaryDraftEngine.java"
click node_planquery "https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/impl/AppPlanQueryServiceImpl.java"
click node_businessdb "https://github.com/lywnl/ai-app-generation/tree/master/src/main/java/com/lyw/appgeneration/mapper"
click node_redis "https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/ai/memory/SpringRedisChatMemoryStore.java"
click node_templates "https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/rag/ingest/TemplateIngestService.java"
click node_deployer "https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/AppDeploymentFileService.java"

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_chatui,node_session,node_previewui,node_user toneBlue
class node_api,node_appservice,node_facade,node_turn,node_modelgen,node_tools,node_plan,node_planquery toneAmber
class node_rag,node_vuehybrid,node_fusion,node_rerank,node_images,node_memory,node_summary,node_templates toneMint
class node_businessdb,node_redis,node_vectorstore toneRose
class node_builder,node_deployer,node_ai,node_site toneIndigo
```

## Components

### Frontend

- [Generation chat](https://github.com/lywnl/ai-app-generation/blob/master/ai-app-generation-frontend/src/pages/app/AppChatPage.vue): `ai-app-generation-frontend/src/pages/app/AppChatPage.vue`
- [Generation session](https://github.com/lywnl/ai-app-generation/blob/master/ai-app-generation-frontend/src/utils/generationSession.ts): `ai-app-generation-frontend/src/utils/generationSession.ts`
- [Preview state](https://github.com/lywnl/ai-app-generation/blob/master/ai-app-generation-frontend/src/composables/useGenerationPreview.ts): `ai-app-generation-frontend/src/composables/useGenerationPreview.ts`

### Generation workflow

- [App API](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/controller/AppController.java): `src/main/java/com/lyw/appgeneration/controller/AppController.java`
- [App service](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/AppService.java): `src/main/java/com/lyw/appgeneration/service/AppService.java`
- [Generation facade](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/core/AiCodeGeneratorFacade.java): `src/main/java/com/lyw/appgeneration/core/AiCodeGeneratorFacade.java`
- [Turn handling](https://github.com/lywnl/ai-app-generation/tree/master/src/main/java/com/lyw/appgeneration/core/handler): `src/main/java/com/lyw/appgeneration/core/handler`
- [Code generation model](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/ai/AiCodeGeneratorService.java): `src/main/java/com/lyw/appgeneration/ai/AiCodeGeneratorService.java`
- [Generation tools](https://github.com/lywnl/ai-app-generation/tree/master/src/main/java/com/lyw/appgeneration/ai/tools): `src/main/java/com/lyw/appgeneration/ai/tools`
- [Plan state](https://github.com/lywnl/ai-app-generation/tree/master/src/main/java/com/lyw/appgeneration/ai/plan): `src/main/java/com/lyw/appgeneration/ai/plan`
- [Plan query](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/impl/AppPlanQueryServiceImpl.java): `src/main/java/com/lyw/appgeneration/service/impl/AppPlanQueryServiceImpl.java`

### Context and retrieval

- [RAG retrieval](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/rag/RagRetrievalService.java): `src/main/java/com/lyw/appgeneration/service/rag/RagRetrievalService.java`
- [Vue hybrid search](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/rag/VueHybridRetrievalService.java): `src/main/java/com/lyw/appgeneration/service/rag/VueHybridRetrievalService.java`
- [RRF fusion](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/rag/retrieval/RrfFusionService.java): `src/main/java/com/lyw/appgeneration/service/rag/retrieval/RrfFusionService.java`
- [Candidate reranking](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/rag/RagRerankService.java): `src/main/java/com/lyw/appgeneration/service/rag/RagRerankService.java`
- [Image references](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/ai/image/ImageCollectionService.java): `src/main/java/com/lyw/appgeneration/ai/image/ImageCollectionService.java`
- [Conversation memory](https://github.com/lywnl/ai-app-generation/tree/master/src/main/java/com/lyw/appgeneration/ai/memory): `src/main/java/com/lyw/appgeneration/ai/memory`
- [Memory summaries](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/impl/MemorySummaryDraftEngine.java): `src/main/java/com/lyw/appgeneration/service/impl/MemorySummaryDraftEngine.java`
- [Template ingest](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/rag/ingest/TemplateIngestService.java): `src/main/java/com/lyw/appgeneration/service/rag/ingest/TemplateIngestService.java`

### Persistence

- [Business database](https://github.com/lywnl/ai-app-generation/tree/master/src/main/java/com/lyw/appgeneration/mapper): `src/main/java/com/lyw/appgeneration/mapper`
- [Redis memory store](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/ai/memory/SpringRedisChatMemoryStore.java): `src/main/java/com/lyw/appgeneration/ai/memory/SpringRedisChatMemoryStore.java`
- **Milvus templates**

### Build and delivery

- [Vue builder](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/core/builder/VueProjectBuilder.java): `src/main/java/com/lyw/appgeneration/core/builder/VueProjectBuilder.java`
- [Site publishing](https://github.com/lywnl/ai-app-generation/blob/master/src/main/java/com/lyw/appgeneration/service/AppDeploymentFileService.java): `src/main/java/com/lyw/appgeneration/service/AppDeploymentFileService.java`

### Other components

- **User**
- **AI services**
- **Published website**

## Connections

- User → Generation chat: enters prompt
- Generation chat → Generation session: starts generation
- Generation session → App API: sends request
- App API → App service: dispatches request
- App service → Generation facade: starts generation
- Generation facade → Turn handling: manages turn
- Generation facade → Code generation model: requests generation
- Code generation model → AI services: streams model calls
- Generation facade → Generation tools: executes tools
- Generation tools → Plan state: updates plan
- Generation tools → Vue builder: requests build
- Turn handling → Generation chat: streams events
- App API → RAG retrieval: retrieves templates
- RAG retrieval → Vue hybrid search: retrieves Vue context
- Vue hybrid search → RRF fusion: fuses rankings
- Vue hybrid search → Candidate reranking: reranks candidates
- RAG retrieval → Candidate reranking: reranks candidates
- App API → Image references: collects image context
- Generation facade → Conversation memory: uses conversation context
- Conversation memory → Redis memory store: reads and writes
- Memory summaries → Business database: reads history and saves summaries
- App API → Business database: persists app data
- App API → Plan query: queries plan
- Plan query → Plan state: loads plan
- Plan state → Business database: persists plan state
- Template ingest → Milvus templates: ingests embeddings
- RAG retrieval → Milvus templates: searches templates
- Vue builder → Generation session: reports build outcome
- Generation session → Preview state: updates preview state
- User → App API: requests publishing
- App API → Site publishing: publishes app
- Site publishing → Published website: provides website
