Skip to content

Commit d9899f9

Browse files
authored
Merge pull request #63 from TaskarCenterAtUW/jeffmaki-docs
Expand README with deployment architecture and services
2 parents 5b1127e + 730d488 commit d9899f9

1 file changed

Lines changed: 73 additions & 1 deletion

File tree

README.md

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,78 @@ following contract. `CLAUDE.md` has the full rationale.
5353
* ```develop``` merge your work here; keep this up to date with the "development" environment / dev tag
5454
* ```staging``` keep this up to date with the "staging" environment / stage tag
5555
* ```production``` keep this up to date with the "production" environment / prod tag
56+
57+
## Deployment architecture
58+
59+
The deployed system is defined by [`docker-compose.az.yml`](docker-compose.az.yml). It runs the
60+
**application tier** as four containers; the **data tier** (Postgres/PostGIS) is external, managed
61+
Azure Database for PostgreSQL, not part of this compose file.
62+
63+
When deployed by `workspaces-stack` this model also holds.
64+
65+
```
66+
client (TDEI/Keycloak JWT)
67+
68+
▼ :8000
69+
┌──────────────────────────────────────┐
70+
│ workspaces-backend │ this repo — FastAPI front door.
71+
│ authn/authz + OSM reverse proxy │ Serves /api/v1/*, proxies the rest.
72+
└───┬──────────────────────────────┬────┘
73+
WS_OSM_HOST TASK_DATABASE_URL
74+
(→ osm-rails) OSM_DATABASE_URL
75+
│ │
76+
▼ │
77+
┌──────────────┐ │
78+
│ osm-rails │ OSM website (Rails); the single OSM entry point.
79+
│ :3000 │ Serves the API/UI and fronts cgimap for the
80+
└──────┬───────┘ performance-critical /api/0.6 calls.
81+
│ (internal) │
82+
▼ │
83+
┌──────────────┐ │
84+
│ osm-cgimap │ C-accelerated /api/0.6 (map, changeset bulk)
85+
│ :8000 │ │
86+
└──────────────┘ │
87+
88+
osm-rails-worker (rake jobs:work) │ background jobs
89+
│ │
90+
│ backend, rails, cgimap, worker all connect to ▼
91+
┌─────────────────────────────────────────────────────────────────┐
92+
│ data tier — Azure Postgres (external, PostGIS) │
93+
│ opensidewalks-${ENV}.postgres.database.azure.com:5432 │
94+
│ • workspaces-tasks-${ENV} TASK db (alembic_task; backend) │
95+
│ • workspaces-osm-${ENV} OSM db (alembic_osm; all four) │
96+
└─────────────────────────────────────────────────────────────────┘
97+
```
98+
99+
### Services
100+
101+
| Service | Image | Role |
102+
|---|---|---|
103+
| `workspaces-backend` | `workspaces-backend-v2:${ENV}` | This repo. The only host-exposed service (`8000:8000`). Validates the TDEI/Keycloak JWT, enforces workspace authorization, serves `/api/v1/*`, and proxies everything else to the OSM tier. Connects to **both** databases. |
104+
| `osm-rails` | `workspaces-osm-rails-v2:${ENV}` | The OpenStreetMap website (Rails) — the **single OSM entry point** the backend proxies to (`WS_OSM_HOST`). Serves the OSM API/UI and fronts cgimap for the heavy `/api/0.6` calls. Connects to the OSM db. |
105+
| `osm-cgimap` | `workspaces-osm-cgimap-v2:${ENV}` | C++ reimplementation of the performance-critical OSM `0.6` calls (map queries, changeset upload/download), sitting behind `osm-rails`. Tuned here for large imports (`CGIMAP_MAX_*`). Connects to the OSM db. |
106+
| `osm-rails-worker` | `workspaces-osm-rails-v2:${ENV}` | Background job runner (`rake jobs:work`) for the Rails app. Connects to the OSM db. |
107+
108+
### Two databases
109+
110+
The backend holds two connections, and the two alembic trees target them independently (see
111+
`CLAUDE.md` and `api/utils/migrations.py`):
112+
113+
* **TASK db** (`TASK_DATABASE_URL``workspaces-tasks-${ENV}`) — the workspaces + tasking-manager
114+
schema, built by the `alembic_task` tree. Only the backend connects here.
115+
* **OSM db** (`OSM_DATABASE_URL``workspaces-osm-${ENV}`) — OSM data plus `users` and the
116+
`tasking_*` tables, built by the `alembic_osm` tree. The backend, cgimap, rails, and the worker
117+
all connect here.
118+
119+
On startup (outside of pytest) the backend runs `alembic -n task upgrade head` and
120+
`alembic -n osm upgrade head`, applying each tree to its database.
121+
122+
### Environment templating
123+
124+
Every image tag, database name/user, and server host is parameterized by `${ENV}`
125+
(`dev` / `stage` / `prod`), and secrets are injected from the shell environment
126+
(`${WS_TASKS_DB_PASS}`, `${WS_OSM_DB_PASS}`, `${WS_OSM_SECRET_KEY_BASE}`). Branches map to these
127+
environments — see the Branch Index below.
56128

57129
## To start on your local machine for dev work
58130

@@ -106,4 +178,4 @@ connecting to existing Databases.
106178

107179
`docker compose --file docker-compose.local.yml down`
108180

109-
Backend code will be available at `http://localhost:8000`
181+
Backend code will be available at `http://localhost:8000`

0 commit comments

Comments
 (0)