A browser extension with a Node.js backend for AI-powered productivity features.
ai-productivity-extension/
├── backend/ # Node.js/Express backend
│ ├── src/
│ │ ├── app.js
│ │ ├── server.js
│ │ ├── config/
│ │ ├── controllers/
│ │ ├── middleware/
│ │ ├── models/
│ │ ├── routes/
│ │ ├── services/
│ │ └── utils/
│ └── package.json
└── extension/ # Browser extension
├── manifest.json
├── background.js
├── contentScript.js
└── popup/
- Node.js (v14 or higher)
- MongoDB (running locally or MongoDB Atlas)
- OpenAI API key
cd backend
npm installCreate a .env file in the backend directory:
cp .env.example .envEdit .env and add your configuration:
PORT=5000
MONGO_URI=mongodb://localhost:27017/ai-productivity
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
OPENAI_API_KEY=your-openai-api-key-hereImportant:
- Replace
MONGO_URIwith your MongoDB connection string - Generate a strong random string for
JWT_SECRET - Get your OpenAI API key from OpenAI Platform
Make sure MongoDB is running:
Local MongoDB:
# Windows
net start MongoDB
# macOS/Linux
sudo systemctl start mongod
# or
mongodMongoDB Atlas (Cloud):
- Use your MongoDB Atlas connection string in
MONGO_URI
npm startThe server will start on http://localhost:5000 (or the port specified in .env).
- Open Chrome/Edge and navigate to
chrome://extensions/oredge://extensions/ - Enable "Developer mode" (toggle in top right)
- Click "Load unpacked"
- Select the
extensionfolder from this project
The extension is configured to connect to http://localhost:5000 by default.
POST /api/auth/register- Register a new userPOST /api/auth/login- Login user
POST /api/ai/chat- Send chat message (requires authentication)GET /api/ai/history- Get conversation history (requires authentication)
GET /api/history- Get user history (requires authentication)
-
Check if MongoDB is running:
# Test MongoDB connection mongosh -
Check environment variables:
- Ensure
.envfile exists inbackenddirectory - Verify all required variables are set
- Ensure
-
Check port availability:
- Make sure port 5000 (or your configured PORT) is not in use
- Change PORT in
.envif needed
- Verify MongoDB is running
- Check
MONGO_URIin.envis correct - For MongoDB Atlas, ensure your IP is whitelisted
If you get module not found errors:
cd backend
npm install- Verify your
OPENAI_API_KEYis correct in.env - Check your OpenAI account has credits/quota
- Ensure the API key has proper permissions
cd backend
npm run devISC