How prashant-tech870/the_great_bengaluru_hack works
Project Type & Purpose
• This is a full-stack Flask-based ride-hailing application that focuses on optimizing driver allocation and passenger pickup in NYC using H3 hexagonal geospatial mapping.
• The application provides separate interfaces for drivers, passengers, administrative dashboards, and leaderboards, while utilizing a SQLite database to store driver data and performance metrics.
• It also integrates external services (like Azure Maps for visualizations) and implements algorithms for demand modeling, driver allocation, and reward computations.
File Structure
• Notice top-level files such as app.py, run.py, config.py, and supporting scripts (like create_driver_db.py, data_generator.py, etc.) that anchor the Flask application’s startup.
• The “app” directory contains clear subdirectories:
• “models”: Defines data representations and interactions (e.g., database.py, store.py, user.py).
• “routes”: Contains the Flask view functions (e.g., auth.py, main.py, store.py) that manage incoming API endpoints.
• “static” and “templates”: Hold the CSS, JavaScript, and HTML for the various interfaces.
• “socket.py” hints at real-time or bidirectional communication components.
Main Components
a. Client Interfaces:
• Main Dashboard (index.html): Shows demand visualization, time slot selection, driver notifications, and statistics.
• Driver Interface (driver_map.html): Provides route guidance, demand awareness, and performance metrics.
• Passenger Interface (passenger_map.html): Offers pickup options, walking routes, and decision support.
• Leaderboard (driver_leaderboard.html): Displays driver ranking and performance summaries.
b. Server & Backend:
• Flask Web Server (app.py, run.py) that initializes the application and configures the routing.
• API Endpoints: Represent endpoints like “/”, “/get_data”, “/send_notifications”, etc.
• Socket component for any real-time messaging if applicable.
c. Business Logic & Models:
• Models directory (database interactions, store handling, user systems) that encapsulate the logic for demand modeling, driver allocations, trust scoring, and overall business rules.
• Data generation and database initialization scripts (create_driver_db.py, data_generator.py).
d. Database:
• SQLite databases (driver_data.db, instance/app.db) that store driver metrics and performance logs.
e. External Services & Integrations:
• Azure Maps API integration for the interactive maps and hexagonal visualization.
• H3 Hexagonal mapping system for geospatial indexing which drives the demand visualization component.
Relationships and Data Flows
• Fetching map/demand data.
• Sending notifications and simulation responses.
• Processing passenger decisions.
• Interactions between the Flask routes and the business logic/models:
• Models processing (driver allocation, trust score computation) that then update the database.
• A connection from the application to the external Azure Maps/H3 services, indicating external API calls for geospatial mapping.
• Data flow from simulated scripts (data_generator.py) contributing to initializing and feeding data into the system.
Architectural Patterns & Design Principles
• MVC Pattern: The separation of concerns is visible – Flask controllers (routes), models (business logic and database interactions), and views (templates).
• API-based communication: Clearly delineate the endpoints for client-server interactions.
• Modular design: Multiple modules exist for different interfaces (driver, passenger, leaderboard) and system components.
• Emphasis on real-time interaction (via socket.py) if applicable.
Elements
• Clear labels for each main component (e.g., “Driver Interface”, “Passenger Interface”, “Flask Server”, “SQLite Database”, “Azure Maps Integration”).
• From client to server (HTTP/API calls).
• From server to database (read/write operations).
• From server to external services (API calls for geospatial functions).
• Side notes or annotations for key technical details (e.g., “H3 Hexagonal Mapping at Resolution 7”, “Real-time driver notifications”, “Trust Score Calculations”).