A production-ready geospatial analytics API for real-time location intelligence
- π Real-time Geofencing - Monitor entry/exit events with instant webhook notifications
- πΊοΈ Route Optimization - Multi-stop route planning with traffic integration
- π Spatial Analytics - Clustering, heatmaps, and spatial queries
- π― Location Recommendations - Intelligent POI suggestions with personalization
- π± Device Tracking - Real-time GPS tracking with trajectory storage
- π Production-Ready - JWT auth, rate limiting, monitoring, and comprehensive testing
- Docker & Docker Compose
- Python 3.9+
# Clone the repository
git clone https://github.com/yourusername/geospatial-api.git
cd geospatial-api
# Start services
docker-compose up -d
# Install dependencies
pip install -r requirements.txt
# Run database migrations
alembic upgrade head
# Start the API
uvicorn app.main:app --reloadOnce running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β FastAPI App ββββββΆβ Redis Cache ββββββΆβ PostGIS DB β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ
β Celery Workers β β Monitoring β
βββββββββββββββββββ βββββββββββββββββββ
- Backend: FastAPI, SQLAlchemy, GeoAlchemy2
- Database: PostgreSQL + PostGIS
- Cache: Redis
- Tasks: Celery
- Spatial: Shapely, NumPy, scikit-learn
- Testing: pytest, pytest-asyncio
POST /api/v1/auth/register- User registrationPOST /api/v1/auth/login- User login
POST /api/v1/geofences- Create geofenceGET /api/v1/geofences- List all geofencesPOST /api/v1/geofences/{id}/check- Check point in geofence
POST /api/v1/devices- Register devicePUT /api/v1/devices/{id}/location- Update locationGET /api/v1/devices/{id}/trajectory- Get trajectory
POST /api/v1/routes/optimize- Multi-stop optimizationGET /api/v1/routes/directions- Point-to-point routing
GET /api/v1/recommendations/nearby- Find nearby POIsPOST /api/v1/recommendations/suggest- Personalized suggestions
# Run all tests
pytest
# Run with coverage
pytest --cov=app
# Run load tests
python -m pytest tests/locustfile.pyapp/
βββ api/ # API endpoints
βββ models/ # Database models
βββ schemas/ # Pydantic schemas
βββ services/ # Business logic
βββ utils/ # Utilities & middleware
Copy .env.example to .env and configure:
DATABASE_URLREDIS_URLJWT_SECRET_KEY
- Response Time: <100ms for spatial queries
- Throughput: 10,000+ concurrent connections
- Accuracy: 99.9% geofence detection
- Uptime: 99.9% SLA
- Fork the repository
- Create a feature branch
- Run tests and ensure they pass
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.