InsightChat is a real-time chat application built with the MERN stack (MongoDB, Express, React/Angular, Node.js) and powered by Google Gemini AI. It features real-time messaging, AI-assisted writing, and user authentication.
The project is divided into two main parts:
chat-server: The backend Node.js/Express server.chat-client: The frontend Angular application.
Before you begin, ensure you have the following installed:
- Node.js (v14 or higher recommended)
- Angular CLI (
npm install -g @angular/cli) - MongoDB (Local installation or Atlas URI)
Navigate to the chat-server directory and install dependencies:
cd chat-server
npm installNavigate to the chat-client directory and install dependencies:
cd chat-client
npm installYou need to configure the environment variables for the server.
- Create a
.envfile in thechat-serverdirectory. - Add the following variables:
MONGO_URL=your_mongodb_connection_string
PORT=3000
GEMINI_API_KEY=your_google_gemini_api_key
JWT_SECRET=your_jwt_secret_key| Variable | Description |
|---|---|
MONGO_URL |
Connection string for your MongoDB database. |
PORT |
Port for the server to run on (default: 3000). |
GEMINI_API_KEY |
API key for Google Gemini (required for AI features). |
JWT_SECRET |
Secret key used for signing JSON Web Tokens. |
In the chat-server directory, run:
# Production start
npm start
# Or directly with node
node index.jsThe server will start at http://localhost:3000 (or your configured port).
Socket.io will also listen on this port.
In the chat-client directory, run:
ng serveNavigate to http://localhost:4200/ in your browser. The application will automatically reload if you change any of the source files.
- Real-time Messaging: ID-based socket rooms for private chatting.
- AI Integration:
- Chat with "AI Bot" for queries.
- AI-powered message rewriting (Formal, Casual, Grammar fixes).
- Authentication: Secure signup and login with JWT.
- Message Status: Real-time delivered and read receipts.
- CORS Issues: If you experience connection issues between client and server, ensure
corsis configured correctly inchat-server/index.jsto allowhttp://localhost:4200. - MongoDB Connection: Ensure your IP is whitelisted if using MongoDB Atlas, or that your local MongoDB service is running.
- Gemini API: If AI features fail, verify your
GEMINI_API_KEYis valid and has quota.