Thanks for your interest in contributing! This guide will help you get started with development and frontend integration.
- Be kind and respectful. Follow our Code of Conduct.
- Open an issue first for major changes to discuss the approach.
- Add tests for any bug fix or new feature.
- Keep PRs focused and small when possible.
# Install Python dependencies
pip install -r requirements.txt
# Start the API server
python start_api.py
# Test the API
python test_api.py
# View API documentation
# Visit http://localhost:8000/docscd frontend
# Install dependencies
npm install
# Start development server
npm run dev
# Run tests
npm run test:run
# Run tests with coverage
npm run test:coveragepip install -r requirements.txt
# Run the complete ML pipeline
python main.py
# Run with specific models
python main.py --models XGB,RF
# Add tests under tests/ if contributing Python codeThe frontend uses the API client in frontend/src/lib/api.ts for backend communication:
import { predictTravelTime } from "@/lib/api";
const prediction = await predictTravelTime({
from: {
id: "start",
name: "Start Location",
lat: 40.767937,
lon: -73.982155,
},
to: {
id: "end",
name: "End Location",
lat: 40.748817,
lon: -73.985428,
},
startTime: "2016-01-01T17:00:00",
city: "new_york",
});
console.log(`Predicted duration: ${prediction.minutes} minutes`);try {
const prediction = await predictTravelTime(tripData);
setPrediction(prediction);
} catch (error) {
console.error("Prediction failed:", error);
setError(error.message);
}import { getModelStatus } from "@/lib/api";
const status = await getModelStatus();
console.log(`API Status: ${status.status}`);- URL:
POST /predict - Body: Trip data with from/to locations, startTime, city
- Response: Duration in minutes, confidence, distance
- URL:
GET /health - Response: API health status
- URL:
GET /status - Response: Detailed API status and model information
Create frontend/.env.local for local development:
# API Configuration
VITE_API_URL=http://localhost:8000
# Development Settings
VITE_DEV_MODE=true- Create a feature branch from
main:feature/<short-description>fix/<short-description>
- Use conventional-style commit messages when possible (e.g.,
feat: add vitest setup).
- Framework: Vitest + React Testing Library
- Location:
frontend/src/test/* - Commands:
npm run test:run- Run tests oncenpm run test:coverage- Run with coverage
- Framework: Python requests + pytest
- Location:
test_api.py - Command:
python test_api.py
# Test all endpoints
python test_api.py
# Test specific endpoint
python -c "
import requests
response = requests.get('http://localhost:8000/health')
print('Status:', response.status_code)
print('Response:', response.json())
"- Use Prettier defaults (Vite + React)
- Keep code idiomatic and typed
- Follow React best practices
- Follow PEP 8 Python style guide
- Use type hints where possible
- Document functions with docstrings
- Fill in the PR template
- Link related issues
- Describe the change, screenshots if UI
- Checklist must pass: tests, CI, and review comments
- Tests pass (
npm run test:runandpython test_api.py) - Code follows style guidelines
- Documentation updated if needed
- No console errors in frontend
- API endpoints tested manually
# Clone and setup
git clone <your-repo-url>
cd GoPredict
# Backend setup
pip install -r requirements.txt
python start_api.py # Keep running in terminal 1
# Frontend setup (new terminal)
cd frontend
npm install
npm run dev # Keep running in terminal 2- Create feature branch:
git checkout -b feature/your-feature - Make changes to frontend or backend
- Test your changes:
- Frontend: Check browser console, run tests
- Backend: Test API endpoints
- Commit with descriptive message
- Push and create PR
# Test frontend-backend connection
python -c "
import requests
data = {
'from': {'lat': 40.767937, 'lon': -73.982155},
'to': {'lat': 40.748817, 'lon': -73.985428},
'startTime': '2016-01-01T17:00:00',
'city': 'new_york'
}
response = requests.post('http://localhost:8000/predict', json=data)
print('Status:', response.status_code)
print('Response:', response.json())
"- Maintainers use GitHub Releases and tags
- Version numbers follow semantic versioning
- Changelog updated for each release
- Ensure API server is running:
python start_api.py - Check API URL in frontend:
VITE_API_URL=http://localhost:8000 - Verify CORS settings in
api/main.py
- Check if server is running:
curl http://localhost:8000/health - Verify dependencies:
pip install -r requirements.txt - Check Python path and imports
- Clear node_modules:
rm -rf node_modules && npm install - Check Node.js version compatibility
- Verify all dependencies installed
- Open a Discussion or an Issue on GitHub
- Check existing issues for similar problems
- Review API documentation at
http://localhost:8000/docs