How colachiang/youbike-opendata-explorer works
Project Type and Purpose
• This is a full-stack mobile navigation app for YouBike users.
• Frontend: App Inventor mobile app (.aia)
• Backend: Python Flask server serving real-time station status and ARIMA-based forecasts
• Data: YouBike open API, weather open data, geoJSON for Taipei map
File Structure
Top-level files and directories:
• ubike_data_crawler.py – Ingests YouBike station data
• C-B0024-001.json, weather.ipynb, 天氣資料概述.docx – Weather data ingestion and exploration
• _ubike_static (1).ipynb – Exploratory data analysis for YouBike data
• forcast.py – Implements ARIMA forecasting model
• geojson_Taipei.json – GeoJSON used for mapping station locations
• test.py – Unit or integration tests
• requirements.txt – Python dependencies
• README.md – Project overview and usage
Configuration:
• .gitignore – Ignores IPython outputs, data files, envs
• ngrok used to expose local Flask endpoints
Key Architectural Components
a. Data Ingestion Layer
– YouBike Data Crawler (ubike_data_crawler.py)
– Weather Data Fetcher (via C-B0024-001.json or direct API)
– Data stored temporarily (CSV/JSON or lightweight DB)
b. Data Processing & Model
– Preprocessing notebooks (_ubike_static.ipynb, weather.ipynb)
– Forecast script (forcast.py) training or generating ARIMA predictions
c. Backend API
– Flask app exposing REST endpoints:
• /stations/status – real-time availability
• /stations/predict – ARIMA forecast for given station ID
– Runs locally, exposed via ngrok for external access
d. Frontend (App Inventor)
– Mobile app imported from Youbike_navigate.aia
– UI screens: Map view, station list, status detail, navigation
– Calls Flask endpoints over HTTP
e. External Services
– YouBike Open API (real-time data)
– Weather Open Data API
– Map tiles or Google Maps for navigation
– ngrok tunnel for HTTP forwarding
Relationships and Interactions
• App Inventor front end ← HTTP/HTTPS → Flask backend
• Flask backend ← internal calls to crawler & forecast modules → Data files or in-memory data
• Crawler ↔ YouBike API
• Weather fetcher ↔ Weather API
• Forecast module consumes historical data + weather features → returns predictions
• GeoJSON used by frontend or backend to render station locations on map
Architectural Patterns & Design Principles
• Layered architecture: Ingestion → Processing/Business Logic → API layer → Client
• Separation of concerns:
– Crawler modules isolated from Flask routes
– Forecast logic decoupled (forcast.py)
– Notebooks used for EDA, not part of runtime path
• Stateless REST API: each request returns fresh status or forecast
• Extensibility: You could swap ARIMA for another model without touching Flask app