# Local Backend Setup Guide ## Prerequisites - Node.js 16+ installed - MongoDB installed and running - Git for cloning repository ## Step 1: Clone and Setup Backend ```bash # Clone the MeetMe backend repository git clone https://github.com/Andyss4545/meetme-backend-api.git cd meetme-backend-api # Install dependencies npm install # Create environment file cp .env.example .env ``` ## Step 2: Configure Environment Create `.env` file with local configuration: ```env # Server Configuration PORT=3000 NODE_ENV=development # MongoDB Configuration MONGODB_URI=mongodb://localhost:27017/meetme_dev # JWT Configuration JWT_SECRET=your_jwt_secret_key_here JWT_EXPIRES_IN=7d # API Configuration API_BASE_URL=http://localhost:3000/api/v1 CORS_ORIGIN=http://localhost:3000 # Bot Configuration BOT_RATE_LIMIT=100 BOT_TIMEOUT=30000 ``` ## Step 3: Database Setup ```bash # Start MongoDB (if not running) mongod # Create database and collections mongo meetme_dev ``` ## Step 4: Start Backend Server ```bash # Development mode with auto-reload npm run dev # Or production mode npm start ``` ## Step 5: Verify API Endpoints Test the API endpoints: ```bash # Health check curl http://localhost:3000/api/v1/health # Get users curl http://localhost:3000/api/v1/users # Create test user curl -X POST http://localhost:3000/api/v1/users \ -H "Content-Type: application/json" \ -d '{ "username": "testuser", "email": "test@example.com", "password": "password123" }' ``` ## Step 6: Bot Integration Testing Update Python bot configuration to use local API: ```env # In your .env file for Python bots API_BASE_URL=http://localhost:3000/api/v1 API_USERNAME=your_test_user API_PASSWORD=your_test_password ``` ## Troubleshooting ### Common Issues: 1. **MongoDB Connection**: Ensure MongoDB is running on port 27017 2. **Port Conflicts**: Change PORT in .env if 3000 is occupied 3. **CORS Issues**: Update CORS_ORIGIN in .env for your frontend 4. **JWT Errors**: Generate a strong JWT_SECRET ### Debug Commands: ```bash # Check MongoDB status mongo --eval "db.adminCommand('ping')" # Check Node.js server logs npm run dev # Test API endpoints curl -v http://localhost:3000/api/v1/health ```