How youcef3939/frostforge works
Purpose and Top-Level Shape
FrostForge is a local AI-assisted 3D world generator for the Frostbyte game jam. A React/Vite client collects a scene prompt and style, while a Python API enhances the prompt, invokes the adjacent WorldGen stack, persists GLB output, and exposes it for browser rendering. Core roots are frontend/, backend/, and WorldGen/.
Runtime Entry Points
• Python API: backend/main.py, launched through Uvicorn (python -m uvicorn main:app --reload) or backend/run_backend.bat; listens on localhost:8000.
• Browser client: frontend/src/main.jsx bootstraps the React application; Vite is configured by frontend/vite.config.js and normally serves localhost:5173.
• Generation runtime: backend/services.py integrates the externally supplied local WorldGen/ directory, expected as a sibling of backend/.
Frontend Interaction Layer
frontend/src/App.jsx composes the generation interface and owns high-level UI coordination. User input originates in frontend/src/components/PromptBar.jsx; style-related controls are provided by frontend/src/components/SettingsPanel.jsx. The client sends raw prompt input to the backend rather than performing prompt construction locally, preserving the API as the prompt and generation boundary.
Prompt Enrichment Stage
backend/prompt_engine.py centralizes prompt optimization and visual-style keyword injection. backend/main.py orchestrates this stage before model generation, allowing the UI’s selected style (such as realistic or low-poly) to become a WorldGen-ready textual request without exposing that transformation as a frontend concern.
Generation and Artifact Boundary
backend/services.py is the protective adapter around WorldGen imports and generation operations; it isolates the API from the underlying GPU/3D-library stack and its failure modes. backend/main.py coordinates request handling, prompt enrichment, service invocation, and response formation. Generated GLB artifacts are written under backend/static/models and served statically, separating potentially expensive generation from later asset retrieval.
3D Presentation Flow
frontend/src/components/Viewer3D.jsx loads and displays generated GLB models using React Three Fiber, including day/night display controls. The expected flow is: prompt/style input → API request → enhanced prompt → WorldGen output → static model URL → viewer load. frontend/src/components/Snowflakes.jsx and frontend/src/App.css support the themed presentation but are outside generation logic.
Material Dependencies and Infrastructure
The backend requires Python 3.10+, Uvicorn, WorldGen dependencies, PyTorch, and 3D libraries; CUDA is recommended for WorldGen execution. The frontend requires Node.js 18+, React/Vite, Tailwind configuration in frontend/tailwind.config.js, and React Three Fiber for model rendering. All described services are local-process infrastructure; no hosted external API is specified.
Main entry points: App.jsx Generation UI · main.py Generation API · services.py WorldGen Adapter · main.jsx React Bootstrap
Components 12
React Client
- Browser User
- React Bootstrap
frontend/src/main.jsx - Generation UI
frontend/src/App.jsx - Prompt Input
frontend/src/components/PromptBar.jsx - Style Controls
frontend/src/components/SettingsPanel.jsx - GLB Viewer · Loads generated models and provides day/night controls.
frontend/src/components/Viewer3D.jsx - Vite Dev Server
frontend/vite.config.js
Python API
- Generation API · Coordinates generation requests and static model delivery.
backend/main.py - Prompt Enrichment · Applies optimization and selected visual-style keywords.
backend/prompt_engine.py - WorldGen Adapter · Isolates API code from WorldGen and GPU/3D failures.
backend/services.py - Generated GLBs · Persisted models are available after generation.
Local WorldGen
- World Generator · Adjacent local runtime using PyTorch and 3D libraries.
WorldGen
Connections 15
- Browser User → Vite Dev Server: opens client
- Vite Dev Server → React Bootstrap: serves
- React Bootstrap → Generation UI: mounts
- Generation UI → Prompt Input: collects prompt
- Generation UI → Style Controls: collects style
- Generation UI → Generation API: raw prompt + style
- Generation API → Prompt Enrichment: enriches request
- Prompt Enrichment → WorldGen Adapter: WorldGen-ready prompt
- Generation API → WorldGen Adapter: orchestrates
- WorldGen Adapter → World Generator: invokes
- WorldGen Adapter → Generated GLBs: writes GLB
- Generation API → Generated GLBs: serves static URL
- Generation API → Generation UI: returns model URL
- Generation UI → GLB Viewer: passes model URL
- GLB Viewer → Generated GLBs: loads GLB