A sophisticated full-stack platform for real-time crowd monitoring, intelligent forecasting, and comprehensive analytics for transit operators.
π Overview β’ β¨ Features β’ ποΈ Architecture β’ π Quick Start β’ π API Documentation β’ π€ Contributing β’ π License
Crowd Prediction is an advanced transit analytics platform that revolutionizes crowd management through intelligent data collection and predictive modeling. The system empowers transit operators with real-time insights, enabling data-driven decisions to optimize service quality and passenger experience.
Built with cutting-edge technologies and modern architectural patterns, this platform seamlessly integrates real-time reporting, machine learning predictions, and comprehensive analytics into a cohesive, scalable solution.
- Live Crowd Reporting - Instant crowd level submissions from mobile and web interfaces
- Dynamic Updates - Real-time data synchronization across all connected clients
- Live Dashboards - Interactive visualizations updating in real-time
- Machine Learning Models - Advanced algorithms for accurate crowd forecasting
- Short-term Predictions - 15-60 minute crowd level predictions
- Historical Analysis - Trend analysis and pattern recognition
- Interactive Dashboards - Comprehensive analytics with drill-down capabilities
- Heat Maps - Visual crowd density representations
- Trend Analysis - Historical data analysis with actionable insights
- Custom Reports - Configurable reporting for different stakeholder needs
- JWT Authentication - Secure token-based user authentication
- Role-based Access - Granular permissions for different user types
- Data Encryption - End-to-end data protection
- API Security - Comprehensive security measures for all endpoints
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Frontend β β Backend β β Database β
β (React) βββββΊβ (FastAPI) βββββΊβ (MongoDB) β
β β β β β β
β β’ Single Page β β β’ REST API β β β’ Document β
β Application β β β’ Async I/O β β Database β
β β’ Real-time UI β β β’ ML Pipeline β β β’ Flexible β
β β’ Responsive β β β’ Caching β β Schema β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- Framework: FastAPI (High-performance async web framework)
- Language: Python 3.7+
- Database: MongoDB (NoSQL for flexible data models)
- ORM: Motor (Async MongoDB driver)
- Web Server: Uvicorn (ASGI server)
- Real-time: WebSockets (for live updates)
- Data Validation: Pydantic
- Task Queue: Celery with Redis (for background tasks)
- Data Processing: Pandas, NumPy
- Authentication: JWT with OAuth2
- ML Framework: Scikit-learn, TensorFlow (for predictions)
- Caching: Redis (for improved performance)
- API Documentation: OpenAPI/Swagger
- Framework: React 18+ (Modern component-based UI)
- Build Tool: Create React App
- Styling: CSS3 with CSS Modules
- State Management: React Context API
- Charts: Chart.js, D3.js (for data visualization)
- Real-time: WebSocket integration
- Version Control: Git with GitFlow workflow
- Containerization: Docker & Docker Compose
- CI/CD: GitHub Actions
- Code Quality: Pre-commit hooks, ESLint, Black
- Testing: Pytest, Jest, React Testing Library
git clone https://github.com/Surajit09636/Crowd_prediction.git
cd Crowd_prediction# Navigate to backend directory
cd Backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Configure environment variables
cp .env.example .env
# Edit .env with your MongoDB connection string and credentials
# Initialize database with sample data
python init_db.py
# Start development server
python server.py
# Or alternatively: uvicorn app.main:app --reload --host 0.0.0.0 --port 8000# Navigate to frontend directory (new terminal)
cd Frontend
# Install dependencies
npm install
# Start development server
npm start
# Frontend will be available at http://localhost:3000- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
| Endpoint | Method | Description | Authentication |
|---|---|---|---|
/api/auth/login |
POST | User authentication | β |
/api/auth/register |
POST | User registration | β |
/api/stations |
GET | Retrieve all stations | β |
/api/stations/{id} |
GET | Get station details | β |
/api/crowd-reports |
POST | Submit crowd report | β |
/api/predictions/{station_id} |
GET | Get predictions | β |
/api/analytics/stations |
GET | Analytics data | β |
The API uses JWT (JSON Web Tokens) for authentication:
# Login to get token
curl -X POST "http://localhost:8000/api/auth/login" \
-H "Content-Type: application/json" \
-d '{"username": "your_username", "password": "your_password"}'
# Use token in subsequent requests
curl -X GET "http://localhost:8000/api/stations" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"cd Backend
pytest tests/ -v --cov=app --cov-report=htmlcd Frontend
npm test -- --coverage --watchAll=false# Run both frontend and backend tests
./scripts/test-all.shWe welcome contributions from the community! Here's how you can help:
- Fork the repository
- Clone your fork locally
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes
- Test thoroughly
- Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow PEP 8 for Python code
- Use ESLint configuration for JavaScript
- Write comprehensive tests for new features
- Update documentation for API changes
- Use conventional commit messages
- Use the GitHub issue tracker
- Include detailed reproduction steps
- Add appropriate labels (bug, enhancement, documentation)
- Be respectful and constructive
Crowd_prediction/
βββ Backend/ # Python FastAPI backend
β βββ app/ # Main application package
β β βββ api/ # API route handlers
β β βββ models/ # Database models
β β βββ schemas/ # Pydantic schemas
β β βββ services/ # Business logic
β β βββ utils/ # Utility functions
β βββ tests/ # Backend tests
β βββ requirements.txt # Python dependencies
βββ Frontend/ # React frontend
β βββ src/ # Source code
β β βββ components/ # React components
β β βββ services/ # API services
β β βββ utils/ # Utility functions
β βββ public/ # Static assets
β βββ package.json # Node dependencies
βββ docs/ # Documentation
βββ API.md # API documentation
βββ ARCHITECTURE.md # Architecture guide
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2024 Crowd Prediction Team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- FastAPI - High-performance web framework
- React - User interface library
- MongoDB - NoSQL document database
- Chart.js - Data visualization
- JWT - Authentication standard
This project draws inspiration from modern transit systems and smart city initiatives worldwide, aiming to contribute to more efficient and passenger-friendly public transportation.
β Star this repo β’ π Report issues β’ π Documentation