How tonyzorin/cyprus-bus works
Main Components
• Data Ingestion and Management:
• update_db.js – main script for full updates, SQL backup generation, and data import.
• parseGTFS.js – processes GTFS files.
• database.js – contains connection and helper functions for database operations.
• gtfs-realtime.proto – defines protocols for real-time bus tracking data.
• Web Backend:
• backend.js – likely acts as the API server providing endpoints for data access.
• docs/openapi.yaml – provides API specifications (useful for designing API interactions).
• directions/generate.js – handles generation of route/direction data.
• Web Frontend:
• frontend.js – logic for client-side interactions.
• Files in the public directory (HTML, CSS, JavaScript, images & assets) – make up the user interface.
• Database Layer:
• Containerization and Deployment:
• Dockerfile and docker-compose.yml – indicate that the system is containerized and can be deployed using Docker.
Relationships and Interactions
• Data Update Flow:
• The update_db.js script is triggered (with various command-line options). It downloads GTFS data, utilizes parseGTFS.js to transform and validate the data, and then uses database.js to update or import data into the database.
• Backend API Flow:
• Frontend Interaction:
• The frontend components (frontend.js within public and index.html) provide user interaction. They make API calls to backend.js to retrieve real-time bus information, stop locations, route details, etc.
• Directions and Mapping:
• The directions/generate.js module should be shown as a special component that interfaces with the GTFS data—it might be used by either the backend to generate routes or by the frontend to display interactive mapping.
• Deployment Architecture:
• Container layer (Dockerfile/docker-compose.yml) which encapsulates the whole application. Indicate that the backend, frontend, and potentially the database are deployed in separate containers or services.
Architectural Patterns and Technologies
• Separation of Concerns:
• Distinct modules for updating data (ETL), serving APIs, and handling the frontend.
• Full-Stack Application Elements:
• Clear division between the frontend (static public assets served to users) and the backend API (Node.js likely, given the use of JavaScript files like backend.js).
• Use of Containerization:
• Docker and docker-compose files indicate that the system has been containerized, so note inter-container communication if multiple services (backend, database, etc.) are depicted.
• Data Flow Based on GTFS (batch and real-time data from gtfs-realtime.proto) which might be used for real-time bus updates.