How rajaram-mohanty/genforge works
Project Type and Purpose
• GenForge is a full-stack web application platform that lets users generate complete web apps via natural-language prompts.
• Frontend: EJS views, CSS/JS assets (Monaco Editor integration, live preview panels).
• Backend: Express.js server, session-based authentication, virtual file system, AI code generation engine.
• External Service: Google Gemini AI for code generation.
File Structure
• Top-level files:
• server.js / index.js / agent.js: Express app and AI agent logic
• virtual-file-system.js: In-memory project VFS
• test-no-duplicate-folders.js: Unit test for VFS
• Directories:
• public/: static assets (CSS, JS, Monaco editor)
• views/: EJS templates (auth, dashboard, preview, error pages)
• Config files: .env (via dotenv), package.json, .gitignore
• Patterns: MVC-like separation (views/ for presentation, server.js routing/controllers, VFS as model), API routes under /api/*.
Key Insights from README
• Architecture Overview: Frontend ↔ Backend ↔ AI Service triangle.
• Core Components: Authentication, AI Code Generation Engine, Virtual File System, Real-Time Code Editor, Application Preview.
• Tech stack: Node.js, Express, EJS, Monaco Editor, Google Gemini AI client.
Main Components
a. Frontend Layer
• EJS Views & Static Assets (HTML/CSS/JS).
• Monaco Editor client component for code editing.
• Live Preview iframe or renderer.
b. Backend Layer
• Express Server (server.js / index.js) handling HTTP & template rendering.
• Authentication Module (bcryptjs, express-session).
• API Layer (/api/generate-prompt, /api/update-file, etc.).
• Virtual File System module (virtual-file-system.js).
• AI Agent (agent.js) invoking Google Gemini via Generative AI SDK.
c. External Services
• Google Gemini AI (code generation service).
d. Data Stores / State
• In-memory VFS (project structure & file contents).
• Session store (express-session, default in-memory or configurable store).
e. (Future) Database Layer
• Placeholder for persistent storage if database integration is added.
Relationships & Data Flows
• User Browser ↔ HTTP(S) ↔ Express Server
• Express Server renders EJS views and serves static assets.
• Frontend scripts call backend API endpoints (AJAX/fetch) for code generation, file CRUD, preview.
• Backend API → Virtual File System → returns file structure or content.
• Backend API → AI Agent → Google Gemini AI → returns generated code.
• Backend merges AI output into VFS, sends updates to frontend.
• Frontend updates Monaco Editor and Preview pane.
Architectural Patterns & Principles
• MVC-style layering: Views (EJS) / Controllers (Express routes) / Model (VFS).
• Modular separation: Authentication, AI Engine, VFS, Editor, Preview.
• Stateless API design, session-based auth.
• Lazy loading of Monaco, debounced updates for performance.