The Dublin Bus App has been built in an attempt to use real time data using the API's provided by the National Transport Authority. Using this app you can see the incoming buses for a selected stop and the buses that currently operate a route based on a direction.
DublinBusApp
├── assets/
│ ├── data/
│ │ ├── Routes.txt
│ │ ├── StopMapLocation.txt
│ │ ├── StopTimesPerTrip.txt
│ │ └── Towards.csv
│ ├── dataCleaning/
│ │ ├── 00_EndpointExploration.ipynb
│ │ ├── 01_DataCleaning.ipynb
│ │ ├── 02_Flow_01_⌚_StopTimes.ipynb
│ │ ├── 03_Flow_02_📍_BusLocator.ipynb
│ │ ├── routes.txt
│ │ ├── stop_times.txt
│ │ ├── stops.txt
│ │ └── trips.txt
│ ├── gifs/
│ │ ├── BusLocator.gif
│ │ └── StopTimes.gif
│ └── images/
│ ├── bus.png
│ ├── dublin_bus_favicon.png
│ ├── dublin_bus_logo.png
│ ├── pin_blue.png
│ ├── pin_green.png
│ ├── pin_red.png
│ └── tfi_logo.png
├── streamlit_app/
│ ├── modules/
│ │ ├── BLutils.py
│ │ ├── STutils.py
│ │ └── Styles.py
│ ├── pages/
│ │ ├── 01_⌚_StopTimes.py
│ │ └── 02_📍_BusLocator.py
│ └── 00_🚌_Info.py
├── LICENSE
├── README.md
└── requirements.txt
Plan to develop the app:
-
Understand the data provided by the APIs
-
Explore the static data provided by the NTA to complement data shown in the APIs
-
Design the logic for
StopTimes
andBusLocator
pages
- Understand the data provided by the APIs:
-
First, sign up for the National Transport Authority (NTA) to access their APIs. Use the following link to sign up: Sign up here.
-
Next, understand and visualise the data provided by the following endpoints:
-
To assist with exploring these endpoints, I have created a Jupyter Notebook (JN): 00_EndpointExploration.ipynb. Replace
os.environ.get("API_KEY")
with the variableYOUR_API_KEY
, and you're ready to proceed.
- Exploring and Preparing NTA Dublin Bus Static Data:
-
Please head over to the following link: GTFS Dublin Bus Data. This will download the file
GTFS_Dublin_Bus.zip
. After downloading, extract the files. -
We will need the following files from the extracted data:
-
routes.txt
-
stops.txt
-
stop_times.txt
-
trips.txt
- These files will be used to generate the following files required for our app:
-
Routes.txt
-
StopMapLocation.txt
-
StopTimesPerTrip.txt
-
Towards.txt
- To visualise this step, I have created a JN: 01_DataCleaning.ipynb.
- Logic Design for
StopTimes
andBusLocator
Pages:
-
After understanding the data provided by the endpoints and the static files, it is time to develop the logic for the pages.
-
StopTimes
Page: -
The user will first select a
route
, then be prompted to choose adirection
, and finally select astop
to display the buses that are due to arrive. -
For a clear understanding of this flow, refer to the JN: 02_Flow_01_⌚_StopTimes.ipynb.
-
BusLocator
Page: -
This page will show the operating buses for the selected
route
anddirection
. -
For more details on this logic, refer to the JN: 03_Flow_02_📍_BusLocator.ipynb.
- Streamlit App Creation:
- After completing the steps above, the final app can be found at: streamlit_app.
- Clone the repository:
git clone https://github.com/user/DublinBusApp.git
Hint: Replace user
with josericodata
in the URL above. I am deliberately asking you to pause here so you can support my work. If you appreciate it, please consider giving the repository a star or forking it. Your support means a lot—thank you! 😊
- Navigate to the project directory:
cd DublinBusApp
- Create a virtual environment:
python3 -m venvDublinBus
- Activate the virtual environment:
source venvDublinBus/bin/activate
- Install requirements:
pip install -r requirements.txt
- Navigate to the modules directory:
cd streamlit_app/modules
- Please locate in
BLutils.py
andSTutils.py
the following line code:
YOUR_API_KEY = st.secrets["API_KEY"]
It is crutial to replace st.secrets["API_KEY"]
with the actual API Key provided by the National Transport Authority after signing up to acces their APIs. Please use the following link to sign up: https://developer.nationaltransport.ie/signup
- Go back one directory and run the app:
cd ..
Then run
streamlit run 00_🚌_Info.py
The app will be live at http://localhost:8501
.
Planned improvements for the Dublin Bus App include:
-
Database Integration: Implementing a relational database (e.g., PostgreSQL) to better manage and query data, enabling faster performance and enhanced data relationships between routes, stops, and trips.
-
Historical Data Storage: Storing historical bus data to provide insights like delay trends, busiest stops, and more accurate arrival time predictions using machine learning.
-
Personalised Features: Adding user-specific data storage, such as favorite routes or frequently accessed stops, for a more tailored experience.
-
Advanced Reporting and Analytics: Generating detailed reports, such as route popularity or stop traffic trends, with visualisations like heatmaps or charts.
-
Enhanced Pages: Introducing new pages and features, including route performance tracking, user feedback collection, and real-time bus location improvements.
-
Scalability: Preparing the app for multi-user support by efficiently handling concurrent queries through the database.
-
The motivation behind developing this app is to gain hands-on experience in working with JSON-formatted data from real-time APIs. As a resident of Ireland, I found Dublin Bus data particularly convenient, as I am familiar with many of the routes, buses, and stops.
-
Additionally, this project helps me stay up to date with my skills while serving as a valuable addition to my portfolio, showcasing my abilities in handling and processing data effectively.
This app has been built and tested in the following environment:
-
Operating System: Ubuntu 22.04.5 LTS (Jammy)
-
Python Version: Python 3.10.12
If you find any bug, feel free to contact me by opening a pull request on GitHub or via email at maninastre@gmail.com.
This app was developed for my portfolio and demonstration purposes only. The results are not guaranteed to be error-free and should not be used for critical decision-making.