How ssrhy/langchaintest works
Project Overview
• This is a full-stack web application named “3D Scene Generator.”
• Its main purpose is to take natural language scene descriptions and generate interactive 3D scenes using an AI-powered, multi-agent system.
• The backend is built in Python using FastAPI and LangChain (with GPT-4) for AI tasks, while the frontend uses HTML/CSS/JavaScript with Three.js for 3D rendering.
Main Components
a. Frontend
• Web UI: Represented by static files (index.html, main.js, styles.css)
• Dynamic 3D Renderer: Uses Three.js for rendering the scene and a sandbox component to safely execute generated code.
b. Backend
• FastAPI Server: The core server script is in main.py.
• AI Agents: Represent the multi-agent system that includes planning, code generation, and code review. Configuration and template files in the .cursor/rules directory support these agents.
• Supporting Tools: tools.py and any helper scripts.
c. Communication Channels
• REST Endpoints: For generating 3D scene code (e.g., POST request to /generate).
• WebSockets (as mentioned in the README for real-time updates).
d. Environment and Configuration
• .env for environment variables (such as OpenAI API key)
• requirements.txt for Python dependency management
Relationships and Interactions
• User Interaction: A user enters a natural language prompt via the frontend web interface.
• Data Flow:
1. The frontend sends the prompt to the FastAPI backend using a REST API call.
2. The backend passes the prompt to one or more AI agents (configured via the .cursor rules) that use LangChain to generate Three.js code.
3. The backend processes the generated code, performing any safety checks.
4. The safe code is returned to the frontend.
5. The frontend executes the code within a secure sandbox to render the 3D scene.
Architectural Patterns and Technologies
• Full-stack separation: Clearly distinguish the frontend (visual rendering and user interaction) from the backend (AI and REST API logic).
• Security Layer: Illustrate the safe code execution/sandbox environment where generated code is run, emphasizing the security aspect.
• Technologies to note:
• Python, FastAPI, LangChain, GPT-4 (backend/AI)
• JavaScript, Three.js (frontend/3D rendering)
• WebSockets (real-time updates)
• REST APIs (communication)