MGSLG Analytics Platform - Quick Start Guide
MGSLG Analytics Platform - Quick Start Guide
Section titled “MGSLG Analytics Platform - Quick Start Guide”🚀 Starting the Application
Section titled “🚀 Starting the Application”Option 1: Start Everything (Recommended)
Section titled “Option 1: Start Everything (Recommended)”cd /Users/nhla/Desktop/PROJECTS/2025/mathew-goniwe./start_dev.shThis starts both backend and frontend automatically.
Option 2: Start Manually
Section titled “Option 2: Start Manually”Terminal 1 - Backend (Python):
cd /Users/nhla/Desktop/PROJECTS/2025/mathew-goniwe/backendsource .venv/bin/activateuvicorn app.main:app --reload --host 0.0.0.0 --port 8000Terminal 2 - Frontend (Next.js):
cd /Users/nhla/Desktop/PROJECTS/2025/mathew-goniwe/frontendpnpm install # First time onlypnpm run dev🌐 Access the Application
Section titled “🌐 Access the Application”Once started, open your browser:
| Service | URL | Description |
|---|---|---|
| Frontend | http://localhost:3000 | Main dashboard |
| Backend | http://localhost:8000 | API server |
| API Docs | http://localhost:8000/docs | Interactive API documentation |
🛑 Stopping the Application
Section titled “🛑 Stopping the Application”If using start_dev.sh:
Section titled “If using start_dev.sh:”./stop_dev.shManual stop:
Section titled “Manual stop:”# Stop backendlsof -ti:8000 | xargs kill
# Stop frontendlsof -ti:3000 | xargs kill✅ Verify Everything is Working
Section titled “✅ Verify Everything is Working”1. Check Backend Health:
Section titled “1. Check Backend Health:”curl http://localhost:8000/api/healthExpected response:
{ "success": true, "data": { "status": "healthy", "version": "1.0.0" }}2. Check Database Data:
Section titled “2. Check Database Data:”curl http://localhost:8000/api/dashboard/kpisExpected response:
{ "success": true, "data": [ { "title": "Total Participants", "value": 1500, ... } ]}3. Check Frontend:
Section titled “3. Check Frontend:”- Open http://localhost:3000
- You should see the main dashboard
- KPIs should show real data (1,500 participants)
🔧 Troubleshooting
Section titled “🔧 Troubleshooting”Port Already in Use
Section titled “Port Already in Use”# Check what's using the portslsof -i :8000 -i :3000
# Kill specific portlsof -ti:8000 | xargs kill # Backendlsof -ti:3000 | xargs kill # FrontendBackend Database Connection Error
Section titled “Backend Database Connection Error”# Check if database existspsql -U nhla -d mgslg_analytics -c "SELECT COUNT(*) FROM participants;"
# If database doesn't exist, run:cd backendpython seed_database.pyFrontend Can’t Connect to Backend
Section titled “Frontend Can’t Connect to Backend”- Check backend is running:
curl http://localhost:8000/api/health - Check frontend env:
echo $NEXT_PUBLIC_API_URL(should be empty for localhost) - Restart frontend:
cd frontend && pnpm run dev
Dependencies Missing
Section titled “Dependencies Missing”Backend:
cd backendsource .venv/bin/activatepip install -r requirements.txtFrontend:
cd frontendpnpm install📊 Understanding the Stack
Section titled “📊 Understanding the Stack”Backend (FastAPI + Python)
Section titled “Backend (FastAPI + Python)”- Framework: FastAPI 0.104.1
- Database: PostgreSQL (mgslg_analytics)
- ORM: SQLAlchemy 2.0.23 (async)
- Package Manager: pip
- Virtual Environment:
.venv/
Frontend (Next.js + TypeScript)
Section titled “Frontend (Next.js + TypeScript)”- Framework: Next.js 14.0.0
- Package Manager: pnpm (NOT npm!)
- API Client: Custom fetch-based client
- State: React hooks
Database
Section titled “Database”- Type: PostgreSQL
- Name: mgslg_analytics
- Records: 1,500 participants, 3,724 enrollments
- Location: Local (localhost:5432)
📁 Project Structure
Section titled “📁 Project Structure”mathew-goniwe/├── backend/ # Python/FastAPI backend│ ├── app/│ │ ├── main.py # FastAPI application│ │ ├── api/routes/ # API endpoints│ │ ├── models/ # Database models│ │ └── core/ # Config, database│ ├── .venv/ # Python virtual environment│ ├── seed_database.py # Database seeding script│ └── requirements.txt # Python dependencies│├── frontend/ # Next.js/TypeScript frontend│ ├── src/│ │ ├── pages/ # Next.js pages│ │ ├── components/ # React components│ │ ├── hooks/ # Custom hooks│ │ └── lib/ # API client│ ├── node_modules/ # Node dependencies│ └── package.json # pnpm dependencies│├── start_dev.sh # Start all servers├── stop_dev.sh # Stop all servers├── QUICK_START.md # This file├── DEPLOYMENT_GUIDE.md # Railway deployment└── IMPLEMENTATION_SUMMARY.md # Full report🎯 Common Tasks
Section titled “🎯 Common Tasks”Reseed Database
Section titled “Reseed Database”cd backendsource .venv/bin/activatepython seed_database.pyView Backend Logs
Section titled “View Backend Logs”tail -f /tmp/mgslg-backend.logView Frontend Logs
Section titled “View Frontend Logs”tail -f /tmp/mgslg-frontend.logCheck Running Processes
Section titled “Check Running Processes”ps aux | grep -E "uvicorn|next-server"Test All API Endpoints
Section titled “Test All API Endpoints”# Health checkcurl http://localhost:8000/api/health
# Dashboard KPIscurl http://localhost:8000/api/dashboard/kpis
# Geographic datacurl http://localhost:8000/api/dashboard/geographic
# ML predictionscurl http://localhost:8000/api/ml/career-progression?limit=5
# Predictive insightscurl http://localhost:8000/api/ml/predictive-insights📚 Additional Resources
Section titled “📚 Additional Resources”- Full Documentation: See
README.md - Deployment Guide: See
DEPLOYMENT_GUIDE.md - Implementation Report: See
IMPLEMENTATION_SUMMARY.md - Local Demo Setup: See
LOCAL-DEMO-SETUP.md
💡 Tips
Section titled “💡 Tips”- Always activate the virtual environment before running Python commands
- Use pnpm, not npm for frontend dependencies
- Backend must be running before frontend can fetch data
- Database must be seeded for real data to appear
- Check logs (
/tmp/mgslg-*.log) if something doesn’t work
🎉 You’re Ready!
Section titled “🎉 You’re Ready!”The MGSLG Analytics Platform is now running locally with:
- ✅ 1,500 real participants
- ✅ Functional ML analytics
- ✅ Interactive dashboard
- ✅ Complete API documentation
Next Steps:
- Open http://localhost:3000 in your browser
- Explore the dashboard and ML analytics
- Check API docs at http://localhost:8000/docs
- Review
DEPLOYMENT_GUIDE.mdfor production deployment
Need Help?
- Check
IMPLEMENTATION_SUMMARY.mdfor detailed info - Review API docs at http://localhost:8000/docs
- Check logs in
/tmp/mgslg-*.log
Last Updated: September 30, 2025