-
-
Overview
-
Overview - Branch Overview
-
Overview Service Tier
-
Overview - Location
-
Overview - Library Network Explorer
-
Branch Insights - Branch Information
-
Branch Insights - Activity & Forecast
-
Branch Insights - Branch Explorer
-
Branch Insights - Ask a question
-
Branch Insights - Branch Programs
-
Branch Comparisons - Annual Metrics
-
Branch Comparisons - Branch Information
-
Branch Comparisons - Branch Explorer
Inspiration
Toronto Public Library (TPL) is more than a collection of buildings. Its branches are community spaces that provide access to books, technology, educational programs, public workstations, cultural activities and other services. It has a rich history dating back to 1884. However, understanding the library network as a whole can be difficult when information is distributed across separate datasets. Branch information, annual circulation, visits, workstation usage, card registrations, programs and neighbourhood information each describe a different part of the network. Looking at these records independently makes it harder to understand the connections between them. I wanted to build a tool that could help people start asking more meaningful questions. This is where LibraryTO comes in. It leverages Toronto Public Library (TPL) open data to understand key trends and metrics impacting the Library Network.
What it does
It brings together branch information, annual performance measures, geography, reported services, programs and graph relationships in one interface.
The application has four primary sections:
- Overview: Provides a network-wide view of annual activity, service tiers, branch rankings, geographic distribution and the underlying graph.
- Branch Insights: Allows users to investigate an individual branch, including its information, annual activity, forecasts, connections and programs.
- Branch Comparisons: Allows users to compare multiple branches across annual performance measures, branch information, reported services and geographic context.
- Programs & Events: Helps users discover library programs using practical filters such as interest, audience, language, program type, branch, date, time and registration availability.
A connected question-and-answer experience is also available from the Overview and individual Branch Insights sections. Users can ask questions about branches, services, facilities, activity and relationships, with answers grounded in the available library information and graph context.
Tech Stack
Backend
- Python 3.12
- FastAPI for application routing and API endpoints
- Relate through the
relate-dbPython package for graph storage and queries
Frontend
- HTML and Jinja2 templates
- Vanilla JavaScript
- CSS
- Plotly for interactive charts
- Leaflet for geographic maps
Data The application uses seven supplied CSV datasets:
tpl-branch-general-information.csvtpl-circulation-annual-by-branch.csvtpl-visits-annual-by-branch.csvtpl-workstation-usage-annual-by-branch.csvtpl-card-registrations-annual-by-branch.csvtpl-events-feed.csvtpl-Neighbourhoods.csv
The datasets are transformed into a connected graph rather than being treated as unrelated files at query time.
Graph construction and application workflow
The graph is built using a dedicated Python graph-building script. The resulting Relate database is stored as a persistent .rl file.
The application then queries that graph directly for graph-powered functionality. It does not substitute a JSON export or an in-memory mock graph for the persistent database.
The general workflow is:
- Read and normalize the supplied CSV records.
- Identify entities such as branches, annual observations, events, neighbourhoods, wards, services and facilities.
- Create graph nodes representing those entities.
- Create relationships connecting the entities.
- Persist the graph in the Relate database.
- Query the graph to support connected-context exploration, graph inspection and question answering.
- Combine graph-derived information with analytical calculations and visualizations in the application.
Design
- WCAG Compliant
- Font Size Toggle
- Light and Dark mode
How it uses Relate
It uses a persistent Relate database stored in: data/tpl_library_graph.rl designed as a Single File
The application connects to this database directly through the relate-db Python package.
The graph is opened in read-only mode by the application when it is queried.
A persistent single-file database provides a practical way to package, distribute, inspect and reproduce the graph.
It also gives the project a concrete graph artifact that can be examined independently of the web interface.
This is particularly important for demonstrating the actual use of Relate. The graph is not simply generated temporarily when the application starts, nor is it replaced by a mock graph or a JSON representation.
The .rl database is included as a project artifact and can be inspected using the Relate CLI.
The single-file approach also keeps the project architecture straightforward: the graph builder creates the database, and the application queries that persistent store.
What the graph models The graph models the relationships between the main entities in the Toronto Public Library datasets.
Nodes include:
- Branch general information
- Annual circulation records
- Annual visit records
- Annual workstation usage records
- Annual card registration records
- Events
- Neighbourhoods
- Wards
- Reported library services
- Library facilities
- Geographic records
Relationships include:
HAS_CIRCULATION_RECORDHAS_VISITS_RECORDHAS_WORKSTATION_RECORDHAS_REGISTRATION_RECORDHOSTS_EVENTIN_NEIGHBOURHOODIN_WARDOFFERS_SERVICEHAS_FACILITYHAS_GEOGRAPHY_RECORD
These relationships allow the application to traverse from a branch to its activity, geography, services and programs.
They also allow the application to identify connections between branches through shared neighbourhoods, wards and reported services.
How Relate is used in the application
Relate supports several parts of LibraryTO:
- Connected-context Q&A: Questions can be answered using graph relationships, rather than relying only on isolated branch attributes.
- Branch Explorer: The application traverses shared neighbourhood and ward relationships to identify connected physical branches and their reported services.
- Branch Comparisons: Selected branches can be explored through their shared and distinct graph connections.
- Graph Insights: The application derives network-level insights from graph connectivity.
- Graph inspection: Users can inspect node types, relationship types, counts and individual records through Library Network Explorer.
The graph therefore supports both the analytical experience and direct inspection of the underlying data model.
An important distinction is that service reach and connectivity represent recorded relationships in the supplied data. They should not be interpreted as direct measurements of service quality, community demand or social outcomes.
Key Features
1. Overview
The Overview section provides a network-wide perspective of Toronto Public Library.
It is designed to answer broad questions about activity, service distribution, branch performance and the structure of the library network.
It contains five subsections.
A. Annual Activity
This section provides an overview of the four main annual activity measures:
- Annual circulation
- Annual visitation
- Annual workstation usage
- Annual card registrations
Users can examine how these measures change across the available reporting years.
The charts help identify:
- Changes in reported library activity over time
- Differences in the scale of activity across measures
- Periods where activity increased or decreased
- The broader pattern of library usage across the network
The purpose is to give users a starting point for understanding the network before investigating individual branches.
B. Service Tiers
Libraries do not all operate in the same way or provide services at the same scale.
The Service Tiers section compares annual activity across the library types or service tiers represented in the source data.
It presents trends for circulation, visits, workstation usage and card registrations across the available service tiers.
This helps users explore:
- How reported activity differs across library types
- Whether activity patterns are consistent across tiers
- How the scale of activity changes over time
- Whether different library types demonstrate different usage patterns
The comparisons provide context rather than assuming that every branch should have the same activity levels.
C. Branch Overview
Branch Overview provides a more detailed comparison of individual physical branches.
It includes four metric views:
- Annual Circulation
- Annual Visitation
- Annual Workstation Usage
- Annual Card Registrations
Users can select a reporting year or choose All Years.
When All Years is selected, the application aggregates each branch's reported values across all available reporting years for the selected metric. The same aggregated totals are used consistently in the rankings and the branch-area comparison.
Each metric view includes:
Top 10 Branches
Identifies the ten branches with the highest reported values for the selected measure and reporting period.
Bottom 10 Branches
Identifies the ten branches with the lowest reported values for the selected measure and reporting period.
Branch Area Comparison
A scatter plot compares the selected activity measure against branch floor area.
This allows users to explore the relationship between the physical size of a branch and its reported activity.
The chart distinguishes branches by service tier and displays the number of reporting years contributing to an aggregated result.
Together, these views make it possible to investigate differences in branch activity without assuming that larger buildings necessarily have higher usage.
D. Location
The Location section provides a geographic view of Toronto Public Library's physical branches.
Users can explore branch locations on an interactive map and change the displayed metric and reporting year.
The map supports:
- Geographic exploration of branch distribution
- Identification of nearby library locations
- Comparison of branch activity across geographic areas
- Inspection of individual branch details through map markers
Selecting a branch marker displays available information such as its address, library type, present site year, workstations, floor area, reported services, telephone number and website.
The map provides a spatial perspective that complements the numerical analysis.
E. Library Network Explorer
Library Network Explorer is where the underlying Relate graph becomes directly inspectable.
It is designed to make the graph more than an invisible backend component. Users and judges can examine the actual graph structure and its stored records.
It contains three important areas:
Graph Insights
Presents graph-derived network insights, including:
- The most connected physical branches
- The most connected neighbourhoods
- The most connected wards
- Services with the widest recorded reach
These insights help demonstrate how entities are connected across the library network.
Browse Nodes
Provides a record-level inspection interface.
Users can browse graph records and examine their stored properties. This makes it possible to inspect the entities represented in the graph rather than relying exclusively on charts or precomputed summaries.
Graph Structure
Provides an overview of the graph's structure, including:
- Node labels and counts
- Relationship types
- Relationship counts
This helps users understand what the graph contains and how its entities are connected.
The Library Network Explorer is particularly important for demonstrating the use of Relate. It provides a way to inspect the actual graph model and understand how the application uses connected data.
2. Branch Insights
Branch Insights allows users to investigate an individual Toronto Public Library branch.
Users select a location using the Find a branch search field. Once selected, the application loads the branch profile and its associated information.
There are five subsections.
A. Branch Information
This section provides a detailed profile of the selected branch.
Available information includes:
- Branch name and code
- Address
- Postal code
- Type of library
- Present site year
- Service tier
- Floor area
- Workstation capacity
- Telephone number
- Operating hours
- Public parking
- Neighbourhood
- Ward
- Reported services
- Website
This brings together information that would otherwise require consulting separate records.
It also gives users geographic and service context for the selected location.
B. Activity & Forecast
This section presents the selected branch's annual activity history across the four measures:
- Circulation
- Visits
- Workstation usage
- Card registrations
Historical observations are displayed alongside forecasts where a forecast is available.
The charts distinguish reported historical values from forecast values. The application also displays the first forecast period's estimated value and explains when a forecast is unavailable.
This helps users examine a branch's historical activity and consider its potential future direction.
Forecasts should be interpreted as estimates based on available historical information, not as confirmed future results.
C. Branch Explorer
Branch Explorer uses the graph to reveal how the selected branch is connected to the wider library network.
It explores relationships through shared geographic areas and reported services.
For example, users can identify other physical branches connected to the selected branch through:
- The same neighbourhood
- The same municipal ward
The explorer also surfaces the reported services associated with connected branches.
This provides a more meaningful view of the network than simply listing the nearest locations. It helps users understand how branches relate through both geography and service availability.
D. Ask A Question
The question-and-answer feature allows users to ask questions about the selected branch.
Questions are scoped to the branch selected in Branch Insights.
Users can ask about information such as:
- Branch details
- Reported services and facilities
- Annual activity
- Geographic context
- Connections to other branches
Answers are presented with a summary and supporting highlights where available.
The graph provides connected context for questions that involve relationships between branches, services and geographic entities.
This makes the application more accessible to users who want to explore information using natural-language questions rather than navigating every chart and table.
E. Programs
The Programs subsection displays upcoming programs associated with the selected branch, using the supplied events information.
Users can explore available program details, including dates, times, audiences, languages, program types and registration information where supplied.
Where available, users can follow links to program details or registration.
This connects the branch profile to the activities taking place at that location.
3. Branch Comparisons
Branch Comparisons allows users to examine differences and similarities between multiple library branches.
Users can search the branch directory, select between two and five branches, and view the comparison results.
The section contains three subsections.
A. Annual Metrics
Users can compare the selected branches across four annual measures:
- Annual Circulation
- Annual Visitation
- Annual Workstation Usage
- Annual Card Registrations
Each metric is presented as a time-series comparison.
This allows users to:
- Compare reported activity between branches
- Examine differences over time
- Identify similar or contrasting trends
- See how the selected branches perform across different measures
The section also provides the underlying annual values in a table, making it easier to inspect the figures behind the charts.
B. Branch Information
This section places the selected branches side by side.
It compares:
- Branch name and code
- Library type
- Present site year
- Address
- Postal code
- Floor area
- Workstations
- Telephone number
- Website
It also includes a reported-services comparison.
The services table shows whether each selected branch has a particular service recorded in the source information.
A map displays the selected branch locations, allowing users to consider the geographic context of the comparison.
This is useful because activity figures alone do not explain why two branches may differ. Location, size, library type and reported services provide additional context.
C. Branch Explorer
The comparison-level Branch Explorer extends the graph functionality to multiple selected branches.
It allows users to examine shared and branch-specific connections across the selected locations.
This helps identify:
- Geographic areas shared by selected branches
- Relationships that are common to multiple branches
- Services that appear across the selected branches
- Differences in their connected service and geographic context
Rather than comparing only numerical performance, this section explores how the selected branches relate to each other through the graph.
4. Programs & Events
Programs & Events is designed to help Toronto residents discover library activities.
Instead of requiring users to browse a general event listing, the section provides filters to narrow the results based on their interests and circumstances.
Users can search using:
- Interest: Search program information using a topic or keyword, such as coding, reading or music.
- Audience: Filter programs by their intended audience.
- Language: Find programs associated with a particular language.
- Program type: Narrow results by the supplied event category.
- Branch: Find programs at a particular library location.
- Date: Search for programs on a specific date.
- Start time: Filter by the desired start time.
- End time: Filter by the desired end time.
- Registration: Narrow results to programs with open registration where the source provides that status.
The results display the program title, date and time, location, audience, language, description, program type and registration status where supplied.
Where available, users can open the program details or follow the registration link.
The goal is to make library programs easier to discover and help residents find activities that match their interests, schedules and locations.
App Usefulness
LibraryTO makes it easier to explore the library network from both an individual and city-wide perspective.
For Toronto residents
- Find library locations and explore their geographic distribution.
- Examine branch details, including hours, parking, services and facilities where recorded.
- Discover programs based on interests, language, audience, location and schedule.
- Explore relationships between branches in the same neighbourhood or ward.
- Understand the different types of services reported across locations.
For library staff and administrators
- Compare annual activity across physical branches.
- Examine differences in circulation, visits, workstation usage and card registrations.
- Explore activity in relation to branch size and service tier.
- Identify branches with similar geographic or service relationships.
- Review the network's recorded service distribution.
For municipal analysts and community organizations
- Explore how public library locations relate to neighbourhoods and wards.
- Investigate the geographic distribution of reported services.
- Compare branch characteristics and annual activity.
- Use connected data to develop more informed questions about public-service access and local infrastructure.
By making these relationships accessible, LibraryTO provides a more complete way to explore Toronto Public Library.
It is intended to support exploration and informed decision-making, not to replace official library information or establish conclusions about community needs that the supplied datasets cannot support.
Challenges I ran into
1. Designing meaningful graph relationships
Creating nodes was only part of the challenge. The more important work was determining which relationships would provide useful context.
For example, connecting a branch to its annual circulation record is relatively straightforward. Creating useful paths between branches through shared wards, neighbourhoods and services required a more deliberate graph design.
The objective was to make the graph useful for answering real questions rather than simply converting CSV rows into nodes.
2. Handling incomplete and historical data
The supplied datasets have different reporting periods. For example, the annual circulation, visits and card-registration snapshots end in 2024, while workstation usage ends in 2023.
Not every measure is necessarily available for every branch and year.
I needed to ensure that the application distinguishes missing information from a reported zero, avoids inventing observations and presents forecasts separately from historical values.
I also needed to make All Years calculations consistent so that branch rankings and branch-area comparisons use the same aggregated values.
3. Making graph functionality understandable
A graph database can be difficult to appreciate when its use is hidden behind the application.
I wanted users to see how Relate contributes to the product.
This led to the Library Network Explorer, with Graph Insights, Browse Nodes and Graph Structure. It makes the graph inspectable and demonstrates the underlying entities and relationships rather than asking users to take the graph implementation on trust.
4. Balancing analytical depth with usability
LibraryTO contains several different types of functionality: dashboards, maps, tables, forecasts, branch profiles, graph exploration, comparisons and event discovery.
The challenge was to organize these features so users could move between a network-wide question and a specific branch without making the interface unnecessarily complicated.
I focused on giving each primary section a distinct purpose while keeping the underlying data and navigation consistent.
Next Steps for LibraryTO
There are several areas where it could be extended.
1. More advanced geographic analysis
The existing map and graph relationships provide a starting point for deeper geographic exploration.
Future work could include:
- More detailed neighbourhood-level service coverage
- Geographic gaps in recorded service availability
- Better exploration of relationships between wards, neighbourhoods and library locations
2. More sophisticated branch comparisons
Branch Comparisons could be extended to include additional context, such as:
- More detailed service-profile comparisons
- Similar-branch identification
- Peer groups based on library type, size or geography
- More flexible comparisons across reporting periods
3. Improved forecasting and analytical context
The current Activity & Forecast section provides forecasts where available.
Future iterations could improve forecast evaluation, expose uncertainty more clearly and allow users to compare projected values against subsequently reported results.
4. More capable graph-powered questions
The current Q&A experience supports questions about branches, services, facilities, activity and relationships.
Future work could expand this into more advanced multi-step questions, including:
- Finding branches that share multiple services and geographic relationships
- Identifying service gaps within a selected ward
- Comparing the connected service profiles of several branches
- Exploring how a particular service is distributed across Toronto
- Combining geographic and annual activity context in one answer
5. More useful program discovery Programs & Events could be expanded with additional discovery features, such as saved interests, recurring program preferences and more flexible date ranges, subject to the availability and quality of source data.
The longer-term vision The longer-term vision is to develop LibraryTO into a connected civic intelligence platform that demonstrates how public-sector datasets can be transformed into useful, explainable relationships.
