xtransit 0.1.0a1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. xtransit-0.1.0a1/.gitignore +227 -0
  2. xtransit-0.1.0a1/LICENSE.txt +9 -0
  3. xtransit-0.1.0a1/PKG-INFO +226 -0
  4. xtransit-0.1.0a1/README.md +192 -0
  5. xtransit-0.1.0a1/docs/operations.md +329 -0
  6. xtransit-0.1.0a1/pyproject.toml +84 -0
  7. xtransit-0.1.0a1/src/xtransit/__init__.py +1 -0
  8. xtransit-0.1.0a1/src/xtransit/__main__.py +3 -0
  9. xtransit-0.1.0a1/src/xtransit/collect.py +447 -0
  10. xtransit-0.1.0a1/src/xtransit/config.py +15 -0
  11. xtransit-0.1.0a1/src/xtransit/core/__init__.py +0 -0
  12. xtransit-0.1.0a1/src/xtransit/core/service.py +18 -0
  13. xtransit-0.1.0a1/src/xtransit/database.py +88 -0
  14. xtransit-0.1.0a1/src/xtransit/ingestion/001_initial.sql +114 -0
  15. xtransit-0.1.0a1/src/xtransit/ingestion/__init__.py +1 -0
  16. xtransit-0.1.0a1/src/xtransit/ingestion/cli.py +241 -0
  17. xtransit-0.1.0a1/src/xtransit/ingestion/parsers.py +301 -0
  18. xtransit-0.1.0a1/src/xtransit/ingestion/poller.py +232 -0
  19. xtransit-0.1.0a1/src/xtransit/ingestion/spool.py +94 -0
  20. xtransit-0.1.0a1/src/xtransit/ingestion/store.py +629 -0
  21. xtransit-0.1.0a1/src/xtransit/services/__init__.py +0 -0
  22. xtransit-0.1.0a1/src/xtransit/services/docker.py +227 -0
  23. xtransit-0.1.0a1/src/xtransit/services/kafka.py +106 -0
  24. xtransit-0.1.0a1/src/xtransit/services/postgres.py +168 -0
  25. xtransit-0.1.0a1/src/xtransit/web/__init__.py +1 -0
  26. xtransit-0.1.0a1/src/xtransit/web/app.py +149 -0
  27. xtransit-0.1.0a1/src/xtransit/web/data.py +510 -0
  28. xtransit-0.1.0a1/src/xtransit/web/static/app.css +1415 -0
  29. xtransit-0.1.0a1/src/xtransit/web/static/app.js +979 -0
  30. xtransit-0.1.0a1/src/xtransit/web/static/index.html +262 -0
  31. xtransit-0.1.0a1/src/xtransit/web/static/networks.mjs +92 -0
  32. xtransit-0.1.0a1/src/xtransit/web/static/vendor/LICENSE +26 -0
  33. xtransit-0.1.0a1/src/xtransit/web/static/vendor/images/layers-2x.png +0 -0
  34. xtransit-0.1.0a1/src/xtransit/web/static/vendor/images/layers.png +0 -0
  35. xtransit-0.1.0a1/src/xtransit/web/static/vendor/images/marker-icon-2x.png +0 -0
  36. xtransit-0.1.0a1/src/xtransit/web/static/vendor/images/marker-icon.png +0 -0
  37. xtransit-0.1.0a1/src/xtransit/web/static/vendor/images/marker-shadow.png +0 -0
  38. xtransit-0.1.0a1/src/xtransit/web/static/vendor/leaflet.css +661 -0
  39. xtransit-0.1.0a1/src/xtransit/web/static/vendor/leaflet.js +6 -0
  40. xtransit-0.1.0a1/tests/__init__.py +3 -0
  41. xtransit-0.1.0a1/tests/test_collect.py +172 -0
  42. xtransit-0.1.0a1/tests/test_ingestion.py +251 -0
  43. xtransit-0.1.0a1/tests/test_ingestion_integration.py +218 -0
  44. xtransit-0.1.0a1/tests/test_postgres.py +118 -0
  45. xtransit-0.1.0a1/tests/test_postgres_integration.py +51 -0
  46. xtransit-0.1.0a1/tests/test_web.py +231 -0
  47. xtransit-0.1.0a1/tests/web_networks.test.mjs +243 -0
  48. xtransit-0.1.0a1/uv.lock +1290 -0
@@ -0,0 +1,227 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ *.lcov
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ # Pipfile.lock
97
+
98
+ # UV
99
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # uv.lock
103
+
104
+ # poetry
105
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
106
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
107
+ # commonly ignored for libraries.
108
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
109
+ # poetry.lock
110
+ # poetry.toml
111
+
112
+ # pdm
113
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
115
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
116
+ # pdm.lock
117
+ # pdm.toml
118
+ .pdm-python
119
+ .pdm-build/
120
+
121
+ # pixi
122
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
123
+ # pixi.lock
124
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
125
+ # in the .venv directory. It is recommended not to include this directory in version control.
126
+ .pixi/*
127
+ !.pixi/config.toml
128
+
129
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
130
+ __pypackages__/
131
+
132
+ # Celery stuff
133
+ celerybeat-schedule*
134
+ celerybeat.pid
135
+
136
+ # Redis
137
+ *.rdb
138
+ *.aof
139
+ *.pid
140
+
141
+ # RabbitMQ
142
+ mnesia/
143
+ rabbitmq/
144
+ rabbitmq-data/
145
+
146
+ # ActiveMQ
147
+ activemq-data/
148
+
149
+ # SageMath parsed files
150
+ *.sage.py
151
+
152
+ # Environments
153
+ .env
154
+ .envrc
155
+ .venv
156
+ env/
157
+ venv/
158
+ ENV/
159
+ env.bak/
160
+ venv.bak/
161
+
162
+ # Spyder project settings
163
+ .spyderproject
164
+ .spyproject
165
+
166
+ # Rope project settings
167
+ .ropeproject
168
+
169
+ # mkdocs documentation
170
+ /site
171
+
172
+ # mypy
173
+ .mypy_cache/
174
+ .dmypy.json
175
+ dmypy.json
176
+
177
+ # Pyre type checker
178
+ .pyre/
179
+
180
+ # pytype static type analyzer
181
+ .pytype/
182
+
183
+ # Cython debug symbols
184
+ cython_debug/
185
+
186
+ # PyCharm
187
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
188
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
189
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
190
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
191
+ # .idea/
192
+
193
+ # Abstra
194
+ # Abstra is an AI-powered process automation framework.
195
+ # Ignore directories containing user credentials, local state, and settings.
196
+ # Learn more at https://abstra.io/docs
197
+ .abstra/
198
+
199
+ # Visual Studio Code
200
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore that
201
+ # can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
202
+ # and can be added to the global gitignore or merged into this file. However, if you prefer, you
203
+ # could uncomment the following to ignore the entire vscode folder
204
+ # .vscode/
205
+ # Temporary file for partial code execution
206
+ tempCodeRunnerFile.py
207
+
208
+ # Ruff stuff:
209
+ .ruff_cache/
210
+
211
+ # PyPI configuration file
212
+ .pypirc
213
+
214
+ # Marimo
215
+ marimo/_static/
216
+ marimo/_lsp/
217
+ __marimo__/
218
+
219
+ # Streamlit
220
+ .streamlit/secrets.toml
221
+
222
+ # Transit downloads, captured payloads, and local runtime state
223
+ /data/
224
+ .env.*
225
+ !.env.example
226
+ .DS_Store
227
+ /data/
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026-present Yasas Senarath <12231659+ysenarath@users.noreply.github.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,226 @@
1
+ Metadata-Version: 2.4
2
+ Name: xtransit
3
+ Version: 0.1.0a1
4
+ Summary: Collect GTFS transit feeds, retain their history in PostgreSQL, and explore routes and vehicles on a map.
5
+ Project-URL: Documentation, https://github.com/ysenarath/xtransit#readme
6
+ Project-URL: Issues, https://github.com/ysenarath/xtransit/issues
7
+ Project-URL: Source, https://github.com/ysenarath/xtransit
8
+ Author-email: Yasas Senarath <12231659+ysenarath@users.noreply.github.com>
9
+ License-Expression: MIT AND BSD-2-Clause
10
+ License-File: LICENSE.txt
11
+ License-File: src/xtransit/web/static/vendor/LICENSE
12
+ Keywords: gtfs,gtfs-realtime,maps,postgresql,transit,transportation
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: Implementation :: CPython
20
+ Requires-Python: >=3.9
21
+ Requires-Dist: asyncpg<1,>=0.30.0
22
+ Requires-Dist: docker>=7.2.0
23
+ Requires-Dist: httpx<1,>=0.27
24
+ Requires-Dist: kafka-python>=3.0.11
25
+ Requires-Dist: psycopg2-binary>=2.9.12
26
+ Requires-Dist: pydantic>=2.13.5
27
+ Requires-Dist: sqlalchemy[asyncio]>=2.0.52
28
+ Provides-Extra: data
29
+ Requires-Dist: gtfs-realtime-bindings<3,>=1.0.0; extra == 'data'
30
+ Provides-Extra: web
31
+ Requires-Dist: fastapi<1,>=0.115; extra == 'web'
32
+ Requires-Dist: uvicorn<1,>=0.30; extra == 'web'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # xtransit
36
+
37
+ Collect public transit data, keep its history, and explore it on a map.
38
+
39
+ xtransit brings together **GTFS schedules** (routes, stops, and timetables) and
40
+ **GTFS Realtime feeds** (vehicle positions, arrival updates, and alerts). It finds
41
+ feeds in the MobilityDatabase catalog, saves them to PostgreSQL, and provides a
42
+ small web app for viewing routes and following vehicles across multiple networks.
43
+
44
+ This is an early alpha. It is useful for local exploration and building a transit
45
+ dataset; commands and database schemas may change between releases.
46
+
47
+ ## What you can do
48
+
49
+ - Download public schedules and realtime snapshots for selected networks or the U.S.
50
+ - Keep collecting arrivals and vehicle positions, with recovery after interrupted imports.
51
+ - View routes, stops, current vehicle positions, and recorded trails on a map.
52
+ - Select several networks at once, including networks that overlap the visible map.
53
+ - Query the collected history with SQL or Python.
54
+
55
+ ## Get started
56
+
57
+ You need **Python 3.9+**, **curl**, and a running **Docker** daemon or a
58
+ **Podman Docker-compatible socket**. PostgreSQL runs in a container that xtransit
59
+ creates and reuses. The download-only commands do not need a database.
60
+
61
+ Install the first alpha in a virtual environment:
62
+
63
+ ```sh
64
+ python3 -m venv .venv
65
+ source .venv/bin/activate
66
+ python -m pip install "xtransit[data,web]==0.1.0a1"
67
+ ```
68
+
69
+ The commands here use a macOS/Linux shell. Run the following steps from the same
70
+ directory; downloads and capture files are saved under `data/` there.
71
+
72
+ ### 1. Download a small network
73
+
74
+ Start with Arlington Transit in Virginia. This downloads its schedule, arrival
75
+ updates, and vehicle positions:
76
+
77
+ ```sh
78
+ xtransit --feed-id mdb-485 --feed-id mdb-1372 --feed-id mdb-1790
79
+ ```
80
+
81
+ These are catalog feed IDs, not route numbers. To find other feeds, run
82
+ `xtransit --catalog-only` and browse `data/us/catalog.csv`.
83
+
84
+ ### 2. Start the database and import the downloads
85
+
86
+ ```sh
87
+ xtransit-db
88
+ xtransit-ingest import-files
89
+ ```
90
+
91
+ The database command creates or reuses a local PostgreSQL instance and checks the
92
+ connection. Importing the same files again is safe.
93
+
94
+ ### 3. Open the map and keep collecting
95
+
96
+ ```sh
97
+ xtransit-web --poll-feed mdb-1790 --poll-feed mdb-1372
98
+ ```
99
+
100
+ Open **http://127.0.0.1:8000**. Leave the terminal running to keep collecting new
101
+ positions and arrival updates. Press **Ctrl+C** to stop the web app and its pollers;
102
+ the database and collected history remain available.
103
+
104
+ The app polls these feeds every 30 seconds and refreshes the map every 15 seconds.
105
+ Vehicles appear when the agency is publishing positions; an empty map can mean
106
+ there is no current service. Check `xtransit-ingest status` if imports failed.
107
+
108
+ ## Explore the map
109
+
110
+ Open **Your networks** to search for and select multiple networks. Click a route
111
+ to see its path, or a vehicle to view its latest observation and a 1-, 6-, or
112
+ 24-hour trail. **Network stops** adds stops from the selected networks.
113
+
114
+ To select networks geographically, pan or zoom and click **Select networks in
115
+ view**. A network only needs to overlap the map; it does not need to fit entirely
116
+ inside it. **In map area only** filters the network picker as you move the map.
117
+ Coverage comes from catalog bounding boxes, so a match does not guarantee a route
118
+ passes through every part of the visible area.
119
+
120
+ **Fresh only** shows positions observed within the past 90 seconds. Older
121
+ positions appear in amber. Trails contain the observations you have collected;
122
+ they do not reconstruct trips from before collection began.
123
+
124
+ The API documentation is available at **http://127.0.0.1:8000/docs**.
125
+
126
+ ## Common commands
127
+
128
+ | Task | Command |
129
+ | --- | --- |
130
+ | List available U.S. feeds | `xtransit --catalog-only` |
131
+ | Download one schedule | `xtransit --kind schedule --feed-id mdb-485` |
132
+ | Refresh that schedule | `xtransit --kind schedule --feed-id mdb-485 --refresh` |
133
+ | Import saved downloads | `xtransit-ingest import-files` |
134
+ | Check imports and errors | `xtransit-ingest status` |
135
+ | Recover pending captures | `xtransit-ingest replay` |
136
+ | Open the map without polling | `xtransit-web` |
137
+
138
+ To keep collecting separately from the web app:
139
+
140
+ ```sh
141
+ xtransit-ingest poll --feed-id mdb-1372 --feed-id mdb-1790 --cycles 0
142
+ ```
143
+
144
+ Without `--cycles 0`, polling runs once. Use `--help` on the collector, importer,
145
+ or web command for more options.
146
+
147
+ ## Collect more networks
148
+
149
+ Repeat `--feed-id` to add feeds. Include a network's schedule and its corresponding
150
+ realtime feeds so the map can connect vehicle observations to routes.
151
+
152
+ For a nationwide collection, the following downloads public feeds, imports them,
153
+ and then continuously polls the available realtime feeds:
154
+
155
+ ```sh
156
+ xtransit
157
+ xtransit-ingest import-files
158
+ xtransit-ingest --workers 8 poll --cycles 0
159
+ ```
160
+
161
+ **Start small if you are trying the project for the first time.** Nationwide
162
+ schedules can occupy tens of gigabytes after import, and realtime history keeps
163
+ growing. This version retains history and capture files indefinitely; it does
164
+ not automatically archive or delete old data.
165
+
166
+ ## Data coverage and reliability
167
+
168
+ xtransit uses the public [MobilityDatabase catalog](https://mobilitydatabase.org/faq).
169
+ U.S. collection covers active catalog entries marked `US`, not every transit
170
+ operator. Feeds requiring agency credentials are reported rather than fetched;
171
+ public schedule mirrors may still be available.
172
+
173
+ Realtime means the **latest observation the agency published and we successfully
174
+ collected**. It is not a continuous GPS stream. Agency delays, outages, and the
175
+ polling interval all affect freshness.
176
+
177
+ The importer saves captured responses before processing them, deduplicates repeated
178
+ data, and updates the current snapshot only after an import succeeds. Failed
179
+ imports can be replayed; invalid feeds are retained for inspection. Polling cannot
180
+ recover observations that an agency replaced between requests. Back up the database
181
+ and capture files if you need to protect against disk loss.
182
+
183
+ ## Where the data lives
184
+
185
+ | Location | Contents |
186
+ | --- | --- |
187
+ | `data/us/` | Feed catalog, downloaded schedules, snapshots, and run reports |
188
+ | `data/ingest-spool/` | Durable captures used to recover interrupted imports |
189
+ | `~/.xtransit/postgres.json` | Local database settings and generated credentials |
190
+ | `~/.xtransit/postgresql/` | Persistent PostgreSQL data |
191
+
192
+ Set `XT_HOME` before starting xtransit to change the database storage location.
193
+ The default database port is `127.0.0.1:55432`.
194
+
195
+ See the [operations guide](https://github.com/ysenarath/xtransit/blob/main/docs/operations.md)
196
+ for SQL examples, database configuration, polling behavior, and recovery details.
197
+
198
+ ## Development
199
+
200
+ ```sh
201
+ git clone https://github.com/ysenarath/xtransit.git
202
+ cd xtransit
203
+ uv sync --extra data --extra web
204
+ uv run --extra data --extra web python -m unittest discover -s tests -v
205
+ node --test tests/web_networks.test.mjs
206
+ ```
207
+
208
+ Node.js 18+ is needed only for the frontend tests. To run the database integration
209
+ tests too, start Docker or Podman and use:
210
+
211
+ ```sh
212
+ XTRANSIT_TEST_DATABASE=1 uv run --extra data --extra web python -m unittest discover -s tests -v
213
+ ```
214
+
215
+ Bug reports and contributions are welcome through
216
+ [GitHub issues](https://github.com/ysenarath/xtransit/issues).
217
+
218
+ ## License and attribution
219
+
220
+ xtransit's code is [MIT licensed](https://github.com/ysenarath/xtransit/blob/main/LICENSE.txt).
221
+ Bundled Leaflet assets retain their BSD 2-Clause license. Transit feeds keep their
222
+ providers' own licenses; see the catalog for each feed's terms.
223
+
224
+ Map tiles come from OpenStreetMap and need an internet connection. Follow the
225
+ [OpenStreetMap tile usage policy](https://operations.osmfoundation.org/policies/tiles/)
226
+ when deploying a public viewer.
@@ -0,0 +1,192 @@
1
+ # xtransit
2
+
3
+ Collect public transit data, keep its history, and explore it on a map.
4
+
5
+ xtransit brings together **GTFS schedules** (routes, stops, and timetables) and
6
+ **GTFS Realtime feeds** (vehicle positions, arrival updates, and alerts). It finds
7
+ feeds in the MobilityDatabase catalog, saves them to PostgreSQL, and provides a
8
+ small web app for viewing routes and following vehicles across multiple networks.
9
+
10
+ This is an early alpha. It is useful for local exploration and building a transit
11
+ dataset; commands and database schemas may change between releases.
12
+
13
+ ## What you can do
14
+
15
+ - Download public schedules and realtime snapshots for selected networks or the U.S.
16
+ - Keep collecting arrivals and vehicle positions, with recovery after interrupted imports.
17
+ - View routes, stops, current vehicle positions, and recorded trails on a map.
18
+ - Select several networks at once, including networks that overlap the visible map.
19
+ - Query the collected history with SQL or Python.
20
+
21
+ ## Get started
22
+
23
+ You need **Python 3.9+**, **curl**, and a running **Docker** daemon or a
24
+ **Podman Docker-compatible socket**. PostgreSQL runs in a container that xtransit
25
+ creates and reuses. The download-only commands do not need a database.
26
+
27
+ Install the first alpha in a virtual environment:
28
+
29
+ ```sh
30
+ python3 -m venv .venv
31
+ source .venv/bin/activate
32
+ python -m pip install "xtransit[data,web]==0.1.0a1"
33
+ ```
34
+
35
+ The commands here use a macOS/Linux shell. Run the following steps from the same
36
+ directory; downloads and capture files are saved under `data/` there.
37
+
38
+ ### 1. Download a small network
39
+
40
+ Start with Arlington Transit in Virginia. This downloads its schedule, arrival
41
+ updates, and vehicle positions:
42
+
43
+ ```sh
44
+ xtransit --feed-id mdb-485 --feed-id mdb-1372 --feed-id mdb-1790
45
+ ```
46
+
47
+ These are catalog feed IDs, not route numbers. To find other feeds, run
48
+ `xtransit --catalog-only` and browse `data/us/catalog.csv`.
49
+
50
+ ### 2. Start the database and import the downloads
51
+
52
+ ```sh
53
+ xtransit-db
54
+ xtransit-ingest import-files
55
+ ```
56
+
57
+ The database command creates or reuses a local PostgreSQL instance and checks the
58
+ connection. Importing the same files again is safe.
59
+
60
+ ### 3. Open the map and keep collecting
61
+
62
+ ```sh
63
+ xtransit-web --poll-feed mdb-1790 --poll-feed mdb-1372
64
+ ```
65
+
66
+ Open **http://127.0.0.1:8000**. Leave the terminal running to keep collecting new
67
+ positions and arrival updates. Press **Ctrl+C** to stop the web app and its pollers;
68
+ the database and collected history remain available.
69
+
70
+ The app polls these feeds every 30 seconds and refreshes the map every 15 seconds.
71
+ Vehicles appear when the agency is publishing positions; an empty map can mean
72
+ there is no current service. Check `xtransit-ingest status` if imports failed.
73
+
74
+ ## Explore the map
75
+
76
+ Open **Your networks** to search for and select multiple networks. Click a route
77
+ to see its path, or a vehicle to view its latest observation and a 1-, 6-, or
78
+ 24-hour trail. **Network stops** adds stops from the selected networks.
79
+
80
+ To select networks geographically, pan or zoom and click **Select networks in
81
+ view**. A network only needs to overlap the map; it does not need to fit entirely
82
+ inside it. **In map area only** filters the network picker as you move the map.
83
+ Coverage comes from catalog bounding boxes, so a match does not guarantee a route
84
+ passes through every part of the visible area.
85
+
86
+ **Fresh only** shows positions observed within the past 90 seconds. Older
87
+ positions appear in amber. Trails contain the observations you have collected;
88
+ they do not reconstruct trips from before collection began.
89
+
90
+ The API documentation is available at **http://127.0.0.1:8000/docs**.
91
+
92
+ ## Common commands
93
+
94
+ | Task | Command |
95
+ | --- | --- |
96
+ | List available U.S. feeds | `xtransit --catalog-only` |
97
+ | Download one schedule | `xtransit --kind schedule --feed-id mdb-485` |
98
+ | Refresh that schedule | `xtransit --kind schedule --feed-id mdb-485 --refresh` |
99
+ | Import saved downloads | `xtransit-ingest import-files` |
100
+ | Check imports and errors | `xtransit-ingest status` |
101
+ | Recover pending captures | `xtransit-ingest replay` |
102
+ | Open the map without polling | `xtransit-web` |
103
+
104
+ To keep collecting separately from the web app:
105
+
106
+ ```sh
107
+ xtransit-ingest poll --feed-id mdb-1372 --feed-id mdb-1790 --cycles 0
108
+ ```
109
+
110
+ Without `--cycles 0`, polling runs once. Use `--help` on the collector, importer,
111
+ or web command for more options.
112
+
113
+ ## Collect more networks
114
+
115
+ Repeat `--feed-id` to add feeds. Include a network's schedule and its corresponding
116
+ realtime feeds so the map can connect vehicle observations to routes.
117
+
118
+ For a nationwide collection, the following downloads public feeds, imports them,
119
+ and then continuously polls the available realtime feeds:
120
+
121
+ ```sh
122
+ xtransit
123
+ xtransit-ingest import-files
124
+ xtransit-ingest --workers 8 poll --cycles 0
125
+ ```
126
+
127
+ **Start small if you are trying the project for the first time.** Nationwide
128
+ schedules can occupy tens of gigabytes after import, and realtime history keeps
129
+ growing. This version retains history and capture files indefinitely; it does
130
+ not automatically archive or delete old data.
131
+
132
+ ## Data coverage and reliability
133
+
134
+ xtransit uses the public [MobilityDatabase catalog](https://mobilitydatabase.org/faq).
135
+ U.S. collection covers active catalog entries marked `US`, not every transit
136
+ operator. Feeds requiring agency credentials are reported rather than fetched;
137
+ public schedule mirrors may still be available.
138
+
139
+ Realtime means the **latest observation the agency published and we successfully
140
+ collected**. It is not a continuous GPS stream. Agency delays, outages, and the
141
+ polling interval all affect freshness.
142
+
143
+ The importer saves captured responses before processing them, deduplicates repeated
144
+ data, and updates the current snapshot only after an import succeeds. Failed
145
+ imports can be replayed; invalid feeds are retained for inspection. Polling cannot
146
+ recover observations that an agency replaced between requests. Back up the database
147
+ and capture files if you need to protect against disk loss.
148
+
149
+ ## Where the data lives
150
+
151
+ | Location | Contents |
152
+ | --- | --- |
153
+ | `data/us/` | Feed catalog, downloaded schedules, snapshots, and run reports |
154
+ | `data/ingest-spool/` | Durable captures used to recover interrupted imports |
155
+ | `~/.xtransit/postgres.json` | Local database settings and generated credentials |
156
+ | `~/.xtransit/postgresql/` | Persistent PostgreSQL data |
157
+
158
+ Set `XT_HOME` before starting xtransit to change the database storage location.
159
+ The default database port is `127.0.0.1:55432`.
160
+
161
+ See the [operations guide](https://github.com/ysenarath/xtransit/blob/main/docs/operations.md)
162
+ for SQL examples, database configuration, polling behavior, and recovery details.
163
+
164
+ ## Development
165
+
166
+ ```sh
167
+ git clone https://github.com/ysenarath/xtransit.git
168
+ cd xtransit
169
+ uv sync --extra data --extra web
170
+ uv run --extra data --extra web python -m unittest discover -s tests -v
171
+ node --test tests/web_networks.test.mjs
172
+ ```
173
+
174
+ Node.js 18+ is needed only for the frontend tests. To run the database integration
175
+ tests too, start Docker or Podman and use:
176
+
177
+ ```sh
178
+ XTRANSIT_TEST_DATABASE=1 uv run --extra data --extra web python -m unittest discover -s tests -v
179
+ ```
180
+
181
+ Bug reports and contributions are welcome through
182
+ [GitHub issues](https://github.com/ysenarath/xtransit/issues).
183
+
184
+ ## License and attribution
185
+
186
+ xtransit's code is [MIT licensed](https://github.com/ysenarath/xtransit/blob/main/LICENSE.txt).
187
+ Bundled Leaflet assets retain their BSD 2-Clause license. Transit feeds keep their
188
+ providers' own licenses; see the catalog for each feed's terms.
189
+
190
+ Map tiles come from OpenStreetMap and need an internet connection. Follow the
191
+ [OpenStreetMap tile usage policy](https://operations.osmfoundation.org/policies/tiles/)
192
+ when deploying a public viewer.