Prerequisites
Before you begin, ensure you have the following installed:Node.js
Version >= 18.0.0
MongoDB
Version >= 5.0
npm
Version >= 8.0.0
Installation Steps
Install Dependencies
Install all required packages using npm:This will install production dependencies including:
- Express 5.1.0 - Web framework
- Mongoose 8.18.0 - MongoDB ODM
- @anthropic-ai/sdk - Claude AI integration
- Socket.io 4.8.1 - Real-time notifications
- Winston 3.17.0 - Advanced logging
Configure Environment Variables
Create a Add the following configuration:
.env file in the root directory:.env
Available Scripts
The following npm scripts are available for development:Development
Production
Database Management
Code Quality
src/ directory.
Docker Commands
Development Workflow
Using Nodemon
Thenpm run dev command uses nodemon to watch for changes. By default, nodemon watches all .js files and automatically restarts the server when changes are detected.
Health Check
Verify the server is running correctly:Debugging Tips
Enable Debug Logs
The application uses Winston for logging. Logs are automatically written to:- Console (formatted based on
NODE_ENV) logs/application-%DATE%.log(rotated daily)logs/error-%DATE%.log(errors only)
Common Issues
MongoDB Connection Failed
MongoDB Connection Failed
Ensure MongoDB is running:Verify the
MONGODB_URI in your .env file is correct.ANTHROPIC_API_KEY Invalid
ANTHROPIC_API_KEY Invalid
The application validates the API key format on startup. Ensure:
- Key starts with
sk-ant- - Key is active and has sufficient credits
- No extra whitespace in the
.envfile
Port Already in Use
Port Already in Use
If port 3000 is already in use:Or change the
PORT in your .env file.Socket.IO Connection Issues
Socket.IO Connection Issues
Ensure CORS origins are properly configured:Check the browser console for CORS errors and add the origin to the allowed list.
Using Node.js Debugger
Start the server with the Node.js debugger:- VS Code: Use the built-in debugger with “Attach to Node Process”
- Chrome DevTools: Navigate to
chrome://inspect
Project Structure
Next Steps
Testing
Learn how to write and run tests
Deployment
Deploy to production
API Reference
Explore available endpoints
Architecture
Understand system design