- Node.js (v18 or higher)
- MongoDB (v5.0 or higher)
- npm or yarn
# Download MongoDB Community Server from:
# https://www.mongodb.com/try/download/community
# Or use Chocolatey:
choco install mongodb
# Start MongoDB service:
net start MongoDBbrew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community# Ubuntu/Debian
sudo apt-get install mongodb
# Start MongoDB
sudo systemctl start mongod
sudo systemctl enable mongod- Go to https://www.mongodb.com/cloud/atlas
- Create a free cluster
- Get your connection string
- Update
server/.envwith your connection string
# Install server dependencies
cd server
npm install
# Install frontend dependencies
cd ../frontend
npm installGROQ_API_KEY="your_groq_api_key_here"
DATABASE_URL="mongodb://localhost:27017/nutripick"
PORT=4000NEXT_PUBLIC_API_URL=http://localhost:4000/apicd server
# Generate Prisma Client
npm run db:generate
# Push schema to MongoDB
npm run db:pushTerminal 1 - Start Backend:
cd server
npm run devTerminal 2 - Start Frontend:
cd frontend
npm run dev# Build frontend
cd frontend
npm run build
npm start
# Start backend
cd ../server
npm start-
Check Backend: Open http://localhost:4000
- You should see the API welcome message
-
Check Database:
cd server npm run db:studio- Opens Prisma Studio to view your database
-
Check Frontend: Open http://localhost:3000
- You should see the NutriPick homepage
POST /api/food/analyze- Analyze food imageGET /api/food/analyses- Get all analysesGET /api/food/analyses/:id- Get specific analysis
POST /api/eateries- Create eateryGET /api/eateries- Get all eateriesGET /api/eateries/:id- Get specific eateryPOST /api/menu/analyze- Analyze menu image
POST /api/canteen/analyze- Analyze canteen mealGET /api/canteen/meals- Get all mealsGET /api/canteen/stats- Get statistics
POST /api/products/scan- Scan product barcodeGET /api/products/:id- Get product details
Error: "MongoServerError: connect ECONNREFUSED" Solution:
# Check if MongoDB is running
# Windows:
net start MongoDB
# macOS/Linux:
sudo systemctl status mongodError: "PrismaClient is unable to be run in the browser" Solution:
cd server
npm run db:generateError: "EADDRINUSE: address already in use" Solution:
# Windows:
netstat -ano | findstr :4000
taskkill /PID <PID> /F
# macOS/Linux:
lsof -ti:4000 | xargs kill -9Error: "CORS policy: No 'Access-Control-Allow-Origin' header"
Solution: Ensure frontend .env has correct API URL:
NEXT_PUBLIC_API_URL=http://localhost:4000/apicd server
npm run db:studiocd server
npm run db:push -- --force-resetmongodump --db nutripick --out ./backupmongorestore --db nutripick ./backup/nutripick-
Hot Reload: Both frontend and backend support hot reload in dev mode
-
API Testing: Use tools like Postman or Thunder Client to test API endpoints
-
Database Inspection: Use Prisma Studio (
npm run db:studio) to view and edit data -
Logs: Check console output for detailed error messages
Set these in your production environment:
DATABASE_URL="mongodb+srv://user:pass@cluster.mongodb.net/nutripick"
GROQ_API_KEY="your_production_key"
PORT=4000
NODE_ENV=production# Frontend
cd frontend
npm run build
# Backend
cd server
npm run db:generate
npm startFor issues or questions:
- Check the logs in console
- Review DATABASE_ARCHITECTURE.md for API documentation
- Ensure all environment variables are set correctly
- Verify MongoDB is running and accessible