How inglepriyanshu/neobrain works
Project type and purpose
• This is a full-stack web application called “NeoBrain” that lets authenticated users upload documents (PDF/DOCX/TXT), process YouTube videos, chat with an AI (Google Gemini 2.5 Flash), store and search citations (RAG/vector search), and manage notebooks.
• Key features: user auth, file upload, video processing, AI chat, citation system, vector search.
File structure
• Top-level directories:
• client/ – React frontend
• server/ – Node.js/Express backend
• client/src/components/Auth & Dashboard – MVC‐style React component grouping
• client/src/contexts/AuthContext.js – global auth state via React Context
• server/routes/*.js – Express route handlers (auth, chat, notebooks, sources)
• server/middleware/auth.js – JWT/session authentication guard
• server/models/*.js – Mongoose schemas: User, Chat, Notebook, Source
• server/services/*.js – business logic modules: documentProcessor, geminiService, youtubeService
• server/uploads/ – local storage for uploaded files
README for additional insights
• Tech stack: React + Tailwind CSS + Framer Motion on the front end; Node.js/Express and MongoDB Atlas on the back end; Google Gemini AI API for chat.
• Local dev: front end on 3000, back end on 5000.
• Features call out vector search (implying an embedding store or MongoDB Atlas vector index).
a. Main components
• Frontend (React/Tailwind/Framer Motion)
• Backend API (Express)
• Authentication middleware
• Service modules: Document Processor, YouTube Service, Gemini AI Service
• Database: MongoDB Atlas (collections: users, chats, notebooks, sources)
• File storage (server/uploads or cloud bucket)
• External APIs: Google Gemini AI, YouTube Data API
b. Relationships & data flow
1. User → Frontend UI (HTTP/HTTPS)
2. Frontend → Backend (REST API calls)
3. Backend auth middleware verifies token/session
4. Routes delegate to controllers → services:
– documentProcessor reads uploaded files → extracts text/embeddings → persists to DB
– youtubeService fetches video data → transcripts → embeddings → DB
– geminiService calls Google Gemini for chat queries
5. Backend interacts with MongoDB (CRUD for users, chats, notebooks, sources)
6. Backend stores files locally (server/uploads) or could be extended to S3
c. Architectural patterns & principles
• Separation of concerns: UI vs API vs services vs persistence
• MVC‐inspired: routes/controllers vs services vs models
• Token‐based auth middleware
• Service‐oriented modules for each external integration
• Vector search/RAG pattern for AI retrieval
d. Key technologies & frameworks
• Frontend: React, Tailwind CSS, Framer Motion, React Context
• Backend: Node.js, Express, JWT or session middleware
• DB: MongoDB Atlas via mongoose
• AI: Google Gemini 2.5 Flash API
• File parsing: documentProcessor (pdf/text/docx libraries)
• External APIs: YouTube Data API