How princerahul1/venomai-chat-app works
Project Type and Purpose
• Full-stack web application
• Real-time chat, collaborative coding, code execution in browser, AI chatbot assistance
High-Level File Structure Analysis
A. Backend (Node.js + Express)
• server.js, app.js: entry points
• /controllers: ai.controller, project.controller, user.controller (MVC controllers)
• /services: ai.service, project.service, user.service, redis.service (business logic & external integrations)
• /models: user.model (Mongo schema), project.model
• /routes: ai.routes, project.routes, user.routes (REST & WebSocket endpoints)
• /db/db.js: MongoDB connection
• /middleware/auth.middleware.js: JWT auth guard
B. Frontend (React + Vite)
• public/index.html, src/main.jsx: app initialization
• src/App.jsx, src/routes/AppRoutes.jsx: route definitions
• src/screens: Login, Register, Home, Project
• src/auth/UserAuth.jsx, src/context/user.context.jsx: authentication & global state
• src/config: axios (HTTP client), socket (WebSocket client), webContainer (in-browser code runner)
• assets, styles, tailwind.config
Key Architectural Patterns & Principles
• Separation of Concerns:
– Backend uses MVC (models, controllers, services)
– Frontend uses component-based UI + context for global state
• Layered Architecture:
– Presentation (React UI)
– API & Real-time layer (Express endpoints + WebSocket)
– Business logic (services)
– Data (MongoDB, Redis cache)
– External integrations (Google Gemini AI, Web Container)
• Stateless API with JWT for auth and Redis for session/cache
Main Components
1. Client Browser
• React App (Vite)
• WebSocket client
• Web Container iframe
2. API Server (Express)
• HTTP REST endpoints (/api/users, /api/projects, /api/ai)
• WebSocket server for real-time chat & code collaboration
• Auth middleware (JWT)
3. Business Services
• UserService, ProjectService, AIService, RedisService
4. Data Stores
• MongoDB (primary persistence)
• Redis (caching, session store)
5. External Services
• Google Gemini API (AI chatbot)
• Web Container Environment (in-browser code execution)
6. Deployment Targets
• Frontend on Vercel
• Backend on Render (or similar)
Relationships & Data Flows
• User ↔ Browser: UI interactions
• Browser → API (HTTP): user auth, project CRUD, file history
• Browser ↔ WebSocket: real-time messaging, collaborative code editing events
• API → MongoDB: read/write user & project documents
• API ↔ Redis: caching project sessions & auth tokens
• API → Google Gemini: send user prompt, receive AI response
• Browser → Web Container: send code, receive execution output