This guide will help you get the MongoDB backend running for SOWgen.ai in just a few steps.
- Persistent Data: Data stored in MongoDB survives page reloads
- Multi-device Access: Access your data from any device
- Shared Database: All users work with the same data
- Production Ready: Deploy to GitHub Pages with backend API
Best for: First-time users who want to try it quickly
# 1. Start everything (backend + MongoDB)
docker-compose up -d
# 2. Configure frontend
echo "VITE_API_URL=http://localhost:8000" > .env.local
echo "VITE_USE_BACKEND=true" >> .env.local
# 3. Start frontend
npm run dev
# 4. Open browser: http://localhost:5000
# Login: client@example.com / demo123That's it! 🎉
Best for: Developers who want full control
# 1. Run the automated setup script
./start-dev.sh
# The script will:
# - Check prerequisites (Python, Node, MongoDB)
# - Install dependencies
# - Configure environment variables
# - Start backend and frontend
# - Show you where to access the app
# 2. Open browser: http://localhost:5000
# Login: client@example.com / demo123Best for: Understanding each step
Option A: MongoDB Atlas (Cloud - Free)
- Create account at mongodb.com/cloud/atlas
- Create free cluster
- Get connection string
- Copy to
backend/.env:MONGODB_URL=mongodb+srv://...
Option B: Local MongoDB
# macOS
brew install mongodb-community
brew services start mongodb-community
# Linux
sudo apt install mongodb
sudo systemctl start mongod
# Windows
Download from mongodb.com and install as servicecd backend
# Create environment file
cp .env.example .env
# Edit .env with your settings
# At minimum, set: MONGODB_URL and SECRET_KEY# Install Python dependencies
pip3 install -r requirements.txt
# Run backend
python3 main.pyBackend will be running at http://localhost:8000
# In root directory
echo "VITE_API_URL=http://localhost:8000" > .env.local
echo "VITE_USE_BACKEND=true" >> .env.localnpm run devFrontend will be running at http://localhost:5000
curl http://localhost:8000/healthShould return: {"status":"healthy","database":"connected"}
- Open http://localhost:5000
- Login with:
client@example.com/demo123 - Create a SOW
- Refresh the page - data should still be there! ✅
Open http://localhost:8000/docs for interactive API documentation
Depending on your use case, refer to:
| Document | Best For |
|---|---|
| QUICKSTART.md | 5-minute setup guide |
| README.md | Complete backend documentation |
| DOCKER.md | Docker deployment |
| MONGODB_BACKEND_GUIDE.md | Production deployment |
| IMPLEMENTATION_SUMMARY.md | Technical overview |
┌─────────────────────┐
│ Your Browser │
│ (GitHub Pages) │
│ localhost:5000 │
└──────────┬──────────┘
│ HTTP + JWT Token
▼
┌─────────────────────┐
│ FastAPI Backend │
│ localhost:8000 │
│ • Authentication │
│ • CRUD Operations │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ MongoDB │
│ localhost:27017 │
│ • Persistent Data │
└─────────────────────┘
- Frontend (React) runs on GitHub Pages
- Backend (Python/FastAPI) runs on your server
- Database (MongoDB) stores the data
- Authentication uses JWT tokens for security
- CORS allows GitHub Pages to access your backend
Three users are created automatically:
| Password | Role | Can Do | |
|---|---|---|---|
| client@example.com | demo123 | Client | Create and view own SOWs |
| admin@xebia.com | demo123 | Admin | View all SOWs, manage users |
| approver@xebia.com | demo123 | Approver | Review and approve SOWs |
-
Heroku: One-click deploy
heroku create sowgen-api git push heroku main
-
Railway: Simple deployment
railway init railway up
-
DigitalOcean: VPS deployment
- Create droplet
- Install Python + MongoDB
- Run backend
-
Docker: Any container platform
docker build -t sowgen-backend . docker run -p 8000:8000 sowgen-backend
Update .github/workflows/deploy-github-pages.yml:
- name: Build with Vite
env:
GITHUB_PAGES: 'true'
VITE_API_URL: 'https://your-backend-url.com'
VITE_USE_BACKEND: 'true'
run: npm run buildCheck Python version:
python3 --version # Need 3.9 or higherCheck MongoDB connection:
# Test connection
mongosh mongodb://localhost:27017View backend logs:
# If using start-dev.sh
cat backend.log
# If using docker-compose
docker-compose logs backendCheck CORS settings:
In backend/.env, ensure:
ALLOWED_ORIGINS=http://localhost:5000
Verify API URL:
In .env.local:
VITE_API_URL=http://localhost:8000
Check backend is running:
curl http://localhost:8000/healthVerify backend mode is enabled:
In .env.local:
VITE_USE_BACKEND=true
Check browser console for errors:
Open DevTools → Console → Look for API errors
Verify MongoDB is running:
docker-compose ps # If using docker
# or
mongosh # If using local MongoDBCheck SECRET_KEY is set:
# In backend/.env
SECRET_KEY=your-secret-keyClear browser storage:
// In browser console
localStorage.clear()
sessionStorage.clear()Try login again:
Visit http://localhost:5000 and login with demo credentials
- Use Docker for development - It's the easiest way to get started
- Check API docs - http://localhost:8000/docs is interactive
- Monitor logs -
docker-compose logs -fshows real-time logs - Use .env files - Never commit secrets to git
- Test locally first - Before deploying to production
-
Check Documentation
- Start with this guide
- Read QUICKSTART.md
- Check backend/README.md
-
Verify Setup
- Run
backend/test_backend.py - Check http://localhost:8000/docs
- Test with demo users
- Run
-
Common Issues
- MongoDB not running
- Port already in use (8000 or 5000)
- CORS configuration
- Environment variables not set
-
Debug Tools
- Backend logs:
docker-compose logs backend - Frontend logs: Browser console
- API testing: http://localhost:8000/docs
- Database: MongoDB Compass
- Backend logs:
Once you have it running locally:
- ✅ Test all features (login, create SOW, etc.)
- 📝 Read the full integration guide
- 🚀 Deploy backend to your preferred platform
- 🌐 Configure GitHub Actions for production
- 🎊 Your data will persist on GitHub Pages!
Need more help? Check the comprehensive guides:
- MongoDB Backend Integration Guide - Complete setup
- Backend README - API documentation
- Docker Guide - Container deployment
- Implementation Summary - Technical details
Built with ❤️ for Xebia | Empowering Digital Excellence