Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

QuickMind

An intelligent, real-time Perplexity-like AI search engine and chat platform powered by multi-LLM orchestration and web search grounding.

Node.js React Express MongoDB License: ISC


⚑ Quick Overview

QuickMind is a full-stack AI research assistant and conversational platform inspired by Perplexity AI. It combines real-time Web Search Grounding with Multi-LLM Orchestration (Groq, Mistral AI, Google Gemini) to deliver fast, accurate, and source-cited responses to user queries.


🌟 Key Features

  • 🌐 Live Web Search Grounding & Citations: Automatically detects real-time or time-sensitive user queries (latest, news, today, current, 2026, recent) and triggers live Tavily web searches, feeding structured web results to the LLM and displaying cited sources (title and URL) with every response.
  • πŸ€– Multi-LLM Orchestration:
    • Groq (llama-3.3-70b-versatile): Provides ultra-fast responses for general conversational queries.
    • Mistral AI (mistral-small-latest): Synthesizes structured, fact-grounded responses when web search results are retrieved.
    • Google Gemini (gemini-2.5-flash-lite): Generates concise, 2-to-4-word thread titles automatically from the initial prompt.
  • ⚑ Real-Time WebSockets: Powered by Socket.IO for live room management (join) and real-time message broadcasting (new-message).
  • πŸ” Authentication & Security:
    • JWT authentication with secure HTTP-only cookies (sameSite: "None").
    • Password encryption using bcrypt (10 rounds).
    • Express request validation (express-validator).
  • πŸ“§ Email Verification Workflow: Integrated with Nodemailer via Google OAuth2 to send styled verification emails with 10-minute expiring tokens.
  • πŸ’… Responsive & Rich UI: Built with React 19, Redux Toolkit, React Router v7, Vite, Tailwind CSS v4, Framer Motion, and markdown rendering (react-markdown, remark-gfm, react-syntax-highlighter).

πŸ—οΈ Architecture & Communication Flow

                     +---------------------------+
                     |    React 19 Frontend      |
                     |  (Redux Toolkit, Vite)    |
                     +-------------+-------------+
                                   |
             +---------------------+---------------------+
             | REST API (Axios)                          | WebSockets (Socket.IO Client)
             v                                           v
+----------------------------+             +----------------------------+
|   Express 5 HTTP Server    |             |    Socket.IO WS Server      |
|  (Auth, Chats, Middleware) |             | (Room Join, New Message)   |
+--------------+-------------+             +--------------+-------------+
               |                                          |
               +--------------------+---------------------+
                                    |
            +-----------------------+-----------------------+
            |               Backend Services                |
            +-------+---------------+---------------+-------+
                    |               |               |
                    v               v               v
            +---------------+ +-----------+ +---------------+
            |  MongoDB Atlas| | Tavily AI | | Multi-LLM Core|
            | (Users/Chats) | | (Search)  | | Groq/Mistral/ |
            +---------------+ +-----------+ |     Gemini    |
                                            +---------------+
  1. Authentication: Users register, receive an email verification link, and log in to receive an HTTP-only JWT cookie.
  2. Chat & Title Creation: On sending the first message of a thread, Gemini generates a 2-4 word title, creating a new Chat session.
  3. Query Grounding: If the prompt requests live/current information, Tavily search is executed, and Mistral AI synthesizes the answer with citations. Otherwise, Groq generates the response directly.
  4. Broadcast: Responses are saved to MongoDB and emitted via Socket.IO to the user's private room.

πŸ› οΈ Tech Stack

Backend

  • Runtime: Node.js
  • Framework: Express 5
  • Database: MongoDB & Mongoose ODM
  • Real-Time: Socket.IO
  • AI & Search Frameworks: LangChain, Groq SDK, Tavily Search SDK
  • LLM Models: llama-3.3-70b-versatile (Groq), mistral-small-latest (Mistral), gemini-2.5-flash-lite (Google)
  • Auth & Email: jsonwebtoken, bcrypt, cookie-parser, nodemailer

Frontend

  • Core: React 19, Vite
  • State Management: Redux Toolkit, React Redux
  • Routing: React Router v7
  • Styling & UI: Tailwind CSS v4, Framer Motion, Lucide React, React Icons
  • Markdown & Code: react-markdown, remark-gfm, react-syntax-highlighter
  • Networking: Axios, socket.io-client

πŸ—„οΈ Database Schema

User Schema

{
  username: { type: String, required: true, trim: true },
  email: { type: String, required: true, unique: true, lowercase: true },
  password: { type: String, required: true, minlength: 6 }, // Hashed with bcrypt
  isVerified: { type: Boolean, default: false },
  timestamps: true
}

Chat Schema

{
  user: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true, index: true },
  title: { type: String, default: "New Chat" },
  timestamps: true
}

Message Schema

{
  chat: { type: mongoose.Schema.Types.ObjectId, ref: "Chat", required: true, index: true },
  role: { type: String, enum: ["user", "ai"], required: true },
  content: { type: String, required: true },
  sources: [{ title: String, url: String }],
  timestamps: true
}

πŸ“‚ Project Directory Structure

QuickMind/
β”œβ”€β”€ Backend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/          # Database connection (database.js)
β”‚   β”‚   β”œβ”€β”€ controllers/     # Auth & Chat handlers (auth.controller.js, chat.controller.js)
β”‚   β”‚   β”œβ”€β”€ middlewares/     # Auth guard & validation (auth.middleware.js, validate.js)
β”‚   β”‚   β”œβ”€β”€ models/          # Mongoose models (user.model.js, chat.model.js, message.model.js)
β”‚   β”‚   β”œβ”€β”€ routes/          # Express route declarations (auth.routes.js, chat.routes.js)
β”‚   β”‚   β”œβ”€β”€ services/        # AI orchestration, web search & email services
β”‚   β”‚   β”œβ”€β”€ sockets/         # Socket.IO setup (chat.socket.js)
β”‚   β”‚   └── app.js           # Express app setup & CORS configuration
β”‚   β”œβ”€β”€ server.js            # HTTP & WebSocket server launcher
β”‚   β”œβ”€β”€ package.json
β”‚   └── .env                 # Environment variables
└── Frontend/
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ app/             # Main App component, store & router configuration
    β”‚   β”œβ”€β”€ features/
    β”‚   β”‚   β”œβ”€β”€ auth/        # Auth state slice, services, hooks, & pages
    β”‚   β”‚   β”œβ”€β”€ chat/        # Chat components (ChatWindow, Sidebar, Message, InputBox), slice, & sockets
    β”‚   β”‚   └── components/  # Protected & PublicRoute guards, Loading UI
    β”‚   β”œβ”€β”€ pages/           # Landing page (Welcome.jsx)
    β”‚   └── main.jsx         # React application entry point
    β”œβ”€β”€ vite.config.js
    └── package.json

πŸ”‘ Environment Variables Configuration

Create a .env file in the Backend folder:

# Server Configuration
PORT=3000
CLIENT_URL=http://localhost:5173

# Database Connection
MONGO_URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/quickmind

# JWT Secret
JWT_SECRET=your_jwt_secret_key

# AI API Keys
GOOGLE_API_KEY=your_google_gemini_api_key
GROQ_API_KEY=your_groq_api_key
MISTRAL_API_KEY=your_mistral_api_key

# Search API Key
TAVITY_API=your_tavily_search_api_key

# Nodemailer Google OAuth2 Configuration
GOOGLE_USER=your_email@gmail.com
GOOGLE_CLIENT_ID=your_oauth_client_id
GOOGLE_CLIENT_SECRET=your_oauth_client_secret
GOOGLE_REFRESH_TOKEN=your_oauth_refresh_token
GOOGLE_APP_PASSWORD=your_app_password

πŸš€ Quick Start Guide

Prerequisites

  • Node.js: v18.0.0 or higher
  • MongoDB: Local instance or MongoDB Atlas URI
  • API Keys for Groq, Mistral AI, Google Gemini, and Tavily AI

1. Set Up Backend

# Navigate to the Backend folder
cd Backend

# Install dependencies
npm install

# Run backend in development mode
npm run dev

The server will start on http://localhost:3000.

2. Set Up Frontend

# Open a new terminal and navigate to the Frontend folder
cd Frontend

# Install dependencies
npm install

# Start Vite dev server
npm run dev

The client will be running on http://localhost:5173.


πŸ“‘ API Endpoints Reference

Authentication (/api/auth)

Method Endpoint Description Authentication
POST /api/auth/register Register a new user & trigger verification email None
POST /api/auth/login Authenticate user & receive HTTP-only JWT cookie None
GET /api/auth/verify-email?token= Verify user email token None
GET /api/auth/get-me Get currently logged-in user profile JWT Cookie
POST /api/auth/logout Clear authentication cookie None

Chats & Messages (/api/chats)

Method Endpoint Description Authentication
POST /api/chats/message Send message, trigger AI/Search pipeline & return answer JWT Cookie
GET /api/chats Fetch all chat sessions for the authenticated user JWT Cookie
GET /api/chats/:chatId/messages Fetch all messages for a specific chat JWT Cookie
DELETE /api/chats/:chatId/delete Delete a chat session and associated messages JWT Cookie

⚑ Socket.IO Events

Event Name Direction Payload / Description
join Client βž” Server userId (String) β€” Joins user's private socket room
new-message Server βž” Client { title, chat, aiMessage } β€” Real-time AI response payload

🀝 Contributing

Contributions, issues, and feature requests are welcome!

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the ISC License.

Releases

Packages

Contributors

Languages