assettrackhq/routly
About
Open-source, self-hosted fleet management and GPS vehicle tracking platform: live map, trip detection, fuel analytics, geofencing, driver behaviour scoring and event alerting. Flespi, Traccar and generic webhook telemetry. TypeScript, Fastify, React, Postgres, ClickHouse.
Web & App DevelopmentMeasured star growth
- in 24h
- Collecting history
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalRoutly
Open-source, self-hosted fleet management and GPS vehicle tracking.
Live map, trip detection, fuel analytics, geofencing, driver behaviour scoring and event alerting — running on your own servers, against your own trackers.
Live demo · Quick start · Deployment · API & SDK · Changelog
Live demo
demo.routly.app — the whole app against a seeded fleet of 28 assets in Warsaw, four of them trailers. Nothing to install and nothing to sign up for: the demo build answers its own API in the browser, so there is no backend behind it and nothing you click reaches a server.

What it does
| Track | Live map with clustering and traffic, trip detection and a per-vehicle logbook, playback of any track, geofences with enter and exit events. |
| Analyse | Fuel consumption, refuels and suspected thefts on a board each viewer arranges; driver behaviour scoring; a KPI overview and a report builder that schedules its output by email. |
| Operate | Vehicles, trailers and other unpowered assets, drivers and assignments, maintenance plans and due dates, alert rules with per-channel delivery. |
| Integrate | A documented REST API with a generated OpenAPI contract and a typed SDK, API keys, outbound webhooks, and commands sent back to the gateway. |
| Run | Docker Compose for the whole stack, one-tag releases whose images carry an SBOM and build provenance, checksummed backups with a restore drill in CI, an optional Grafana/Loki/Prometheus profile. |
Three ingestion paths ship:
| Provider | What it is | Why you would pick it |
|---|---|---|
| Flespi | Hosted gateway, 1,400+ GPS device models | Fastest route to production |
| Traccar | Self-hosted protocol gateway, 200+ protocols | No raw device traffic leaves your network |
| Generic HTTP | Any JSON webhook | A tracker or gateway of your own |
Authentication is self-hosted too — Better Auth, email and password, invite-only, with optional OIDC single sign-on. No SaaS account, no per-vehicle fee, no vendor lock-in on the device side.
Quick start
# 1. Clone and configure
git clone https://github.com/assettrackhq/routly.git routly
cd routly
cp deploy/.env.example deploy/.env # set the passwords and secrets before step 2
# 2. Start the full stack (frontend, backend, Postgres, Redis, nginx)
make -C deploy up
# or: docker compose -f deploy/docker-compose.yml up -d
# 3. Install the reference event types (the backend applies the schema when it starts)
docker compose -f deploy/docker-compose.yml exec backend npx tsx prisma/seed-reference.ts
# 4. Create the first admin (sign-up is invite-only)
docker compose -f deploy/docker-compose.yml exec \
-e [email protected] \
-e ADMIN_PASSWORD='a-strong-password' \
-e ADMIN_ORG_SLUG=your-fleet \
backend npx tsx scripts/create-admin.ts
# 5. Open the app and sign in
open http://localhost
Run every command from the repository root. The
Quickstart is the full version of
these steps: which variables in deploy/.env to change, health checks, the other
create-admin options, a first telemetry probe and how to reset.
Telemetry goes into Postgres by default, so the default stack is two datastores.
For ClickHouse instead, set TELEMETRY_BACKEND=clickhouse and start its profile:
docker compose -f deploy/docker-compose.yml --profile clickhouse up -d.
Development mode (run apps from source)
# 1. Start databases only
make -C deploy dev
# 2. Install dependencies (pnpm — required)
pnpm install
# 3. Configure the backend (it and the Prisma CLI read apps/backend/.env),
# then apply the schema and install the reference event types
cp apps/backend/.env.example apps/backend/.env
pnpm --filter @routly/backend exec prisma migrate deploy
pnpm --filter @routly/backend db:seed:reference
# 4. Run apps locally (in separate terminals)
cd apps/backend && pnpm dev # http://localhost:3001 (API)
cd apps/frontend && pnpm dev # http://localhost:3000 (web app, proxies /api to :3001)
Authentication is Better Auth (email + password, invite-only; OIDC single sign-on is optional and off until an issuer is configured). Create the first admin with
pnpm --filter @routly/backend ops:create-admin(sameADMIN_*variables as step 4 of the quick start; Local development has the rest of the from-source setup). To run without auth during local development, setVITE_DISABLE_AUTH=1(frontend) andSKIP_AUTH=true(backend) — both are hard-gated to non-production and ignored whenNODE_ENV=production.
Mobile app
An Expo (React Native) client for the same API, sharing the @routly/shared contract
with the backend and the web app. Same accounts, same invite-only sign-in.
cd apps/mobile
cp .env.example .env # EXPO_PUBLIC_API_URL — the backend this build talks to
pnpm start # Expo dev server; press i, a or w
pnpm demo # the seeded fleet, with no backend behind it
Setup, screens, architecture and the design rules are under
the docs site (source in apps/docs/docs/mobile/). A device build needs Xcode or Android Studio;
pnpm start alone does not. The web target Expo also builds is for looking at
screens quickly, not a third client: MapLibre is native-only, so the fleet map
falls back to the vehicle list there.
Admin console
A third client, apps/admin/, for whoever runs the platform rather than a fleet: the
organisations on the installation, the partners whose gateways feed it, data
retention, the audit trail and service health. It is a static bundle built from the
same component library as the web app and served beside it, and it is gated to
SUPER_ADMIN. deploy/README.md covers shipping it.
Architecture
┌─────────────────────────────────────────────────────┐
│ Nginx :80 │
│ (reverse proxy) │
└──────────────┬─────────────────────┬────────────────┘
│ │
┌───────▼───────┐ ┌───────▼───────┐
│ Frontend │ │ Backend │
│ Vite + React │ │ Fastify │
│ :3000 │ │ :3001 │
└───────────────┘ └───────┬───────┘
│
┌───────────────────────────┼───────────────────────────┐
│ │ │
┌─────▼─────┐ ┌───────▼───────┐ ┌───────▼───────┐
│ PostgreSQL│ │ ClickHouse │ │ Redis │
│ :5432 │ │ :8123 │ │ :6379 │
│ (metadata │ │ (telemetry, │ │ (state, cache│
│ + events) │ │ optional) │ │ locks) │
└───────────┘ └───────────────┘ └───────────────┘
Telemetry flows in through a provider webhook (Flespi, Traccar, or generic HTTP) →
normalizer → telemetry store, while fleet metadata, trips, and events live in
PostgreSQL. The telemetry store is chosen with TELEMETRY_BACKEND: postgres
(compose default, two datastores) or clickhouse (columnar, for high-volume
ingest or long retention). deploy/docker-compose.prod.yml runs ClickHouse. The normalizer
and the three providers are in apps/backend/src/services/telemetry-providers, and
docs/deployment.md covers running either store in production.
Project structure
routly/
├── apps/
│ ├── frontend/ # Vite + React 19 + TanStack Router/Query web app
│ ├── admin/ # The admin console, a second Vite app (SUPER_ADMIN only)
│ ├── backend/ # Fastify 5 + Prisma 7 (Postgres) + ClickHouse + Redis
│ ├── mobile/ # Expo (React Native) app for iOS and Android
│ └── docs/ # The documentation site (Docusaurus)
├── packages/
│ ├── shared/ # Shared types & Zod schemas (@routly/shared)
│ ├── ui/ tokens/ # Component library and design tokens
│ ├── auth/ # The Better Auth client every web surface uses
│ ├── sdk/ # Typed API client and the committed contract (Apache-2.0)
│ ├── mocks/ # Seeded demo fleet, for the demo build
│ └── config/ # Shared TypeScript config and Biome plugins (@routly/config)
├── deploy/
│ ├── docker/ # nginx, Postgres and ClickHouse init, observability
│ ├── docker-compose.yml # Local full stack
│ ├── docker-compose.dev.yml # Databases only (local dev)
│ ├── docker-compose.prod.yml # Production
│ ├── .env.example # What compose reads, as deploy/.env
│ └── Makefile # make -C deploy <target>
├── docs/ # Deployment guide, runbooks, specs
└── scripts/ # Repository checks, backup and restore
Make commands
make -C deploy … |
Description |
|---|---|
help |
List every target |
up / down |
Start or stop all services |
restart / ps |
Restart the stack, or show what is running |
dev |
Start databases only (for local dev) |
logs |
View all logs (logs-backend, logs-frontend for one) |
build |
Build Docker images |
clean / prune |
Remove containers, images, volumes |
db-shell |
Open PostgreSQL shell (db-clickhouse, db-redis for the others) |
db-reset |
Stop the stack and delete every volume — all data is gone |
backup |
Back up the databases to ./backups |
restore |
Restore from an archive: make -C deploy restore FILE=… |
health |
Check services health |
prod-build / prod-pull / prod-up |
The same three steps against docker-compose.prod.yml |
Environment variables
Copy deploy/.env.example to deploy/.env and configure. Key variables:
| Variable | Required | Description |
|---|---|---|
BETTER_AUTH_SECRET |
Yes (prod) | Secret for Better Auth sessions (openssl rand -hex 32) |
BETTER_AUTH_URL / CORS_ORIGIN |
Yes (prod) | The public origin of the deployment, e.g. https://fms.example.com. docker-compose.yml defaults both to http://localhost; docker-compose.prod.yml refuses to start without them |
SECRETS_MASTER_KEY |
For partner tokens | Encrypts gateway credentials stored by the admin console; without it that one request is refused with a 503 and nothing else is affected |
TELEMETRY_BACKEND |
No | postgres or clickhouse. Compose sets postgres; a backend started without the variable uses clickhouse |
FLESPI_TOKEN |
For Flespi | Flespi API token, used by the device-sync scripts |
FLESPI_WEBHOOK_SECRET |
For Flespi | HMAC/shared secret for webhook verification |
TRACCAR_WEBHOOK_SECRET |
For Traccar | Shared secret for the Traccar webhook |
POSTGRES_* / REDIS_PASSWORD |
Yes | Database credentials |
CLICKHOUSE_* |
With ClickHouse | Telemetry store credentials |
SMTP_* |
No | Turns on notification email and scheduled report delivery |
OIDC_ISSUER / OIDC_CLIENT_ID / OIDC_CLIENT_SECRET |
No | Single sign-on against your identity provider; off unless set |
TRACCAR_URL / TRACCAR_API_TOKEN |
For commands | Lets Routly send commands back to a Traccar gateway |
ENABLE_API_DOCS |
No | Set true to serve Swagger UI in production |
See deploy/.env.example and each app's .env.example for the full list with inline docs.
Tech stack
- Frontend: Vite 8, React 19, TanStack Router/Query, Tailwind CSS 4, MapLibre GL 6
- Backend: Fastify 5, Prisma 7, Zod 4, pino
- Mobile: Expo 57, React Native 0.86, expo-router, NativeWind, MapLibre Native
- Auth: Better Auth (self-hosted email + password, invite-only, optional OIDC SSO)
- Databases: PostgreSQL 16 (metadata, and telemetry by default), ClickHouse 24 (telemetry at scale), Redis 7 (state, cache)
- Language: TypeScript 6 (strict), Node.js 26, pnpm 9.15
- Infrastructure: Docker, Nginx, GitHub Actions, Let's Encrypt SSL
API documentation and SDK
The OpenAPI spec is not hand-written: the backend generates it from its route schemas
and serves it at /docs/json. Set ENABLE_API_DOCS=true to get Swagger UI at /docs
alongside it. docs/deployment.md covers running this in production.
packages/sdk/openapi.json is that same document, committed — so you
can read the API, generate a client for any language, or diff two versions without
running anything. packages/sdk is the TypeScript client generated
from it: every path, parameter and response type comes from the server's own schemas,
so a route that changes shape is a type error rather than a surprise in production.
It is Apache-2.0 while the platform is AGPL-3.0, because a client library has to be
safe to link into whatever you already run.
pnpm contract # rewrite packages/sdk/openapi.json and src/schema.ts (no databases needed)
CI regenerates both and fails on a difference, so the published contract cannot drift from the server.
Testing
# Run all tests (turbo, across the workspace)
pnpm test
# Run specific package tests
pnpm --filter @routly/backend test
pnpm --filter @routly/frontend test
pnpm --filter @routly/mobile test
# Backend integration tests (needs the dev databases up)
RUN_INTEGRATION_TESTS=true pnpm --filter @routly/backend test:integration
The rest of what CI runs, which is worth running before a pull request:
pnpm lint # biome
pnpm type-check
pnpm check:toolchain # one Node and one pnpm across .nvmrc, engines and both Dockerfiles
pnpm check:licenses # fails on a dependency this project cannot ship
Backups
scripts/backup.sh writes one checksummed archive — the Postgres dump, the raw
telemetry if you ask for it, and a manifest — and scripts/restore.sh puts it back.
The Infrastructure workflow (.github/workflows/infra.yml, run by hand) restores from a
real archive, so the pair cannot rot apart unnoticed. There is
a systemd timer in scripts/systemd/ for running it nightly.
docs/deployment.md has the whole of it, including what is
deliberately not in the archive.
Releases
The current release is v0.2.0.
Every package in the workspace carries one version and they go out together, so a
release is one tag — git checkout v0.2.0 for that state, main for the newest.
CHANGELOG.md says what changed and calls out anything a running
install has to do about it.
Before 1.0.0 a minor version may change an interface.
Every tag publishes container images to GHCR — …-backend, …-frontend and
…-nginx, for linux/amd64 and linux/arm64, each carrying an SBOM and a build
provenance attestation. docs/deployment.md has how to run and how to
verify them.
Contributing
See the contributing guide for setup and coding rules, CONTRIBUTING.md for the DCO sign-off, and CODE_OF_CONDUCT.md for how we expect people to treat each other. Please open an issue or discussion before large changes.
Found a vulnerability? SECURITY.md says where to send it — not to the issue tracker.
License
Routly is dual-licensed:
- GNU AGPL v3.0 — free to use, including commercially. If you modify Routly and let others use it over a network, AGPL §13 requires you to offer them your modified source. Self-hosting an unmodified Routly for your own fleet triggers nothing.
- Commercial license — for reselling, white-labelling, hosting it as a service for customers, or embedding it in closed-source software. Adds warranty, indemnity, and an SLA. Contact [email protected].
Contributions are accepted under the DCO plus a relicensing grant — see CONTRIBUTING.md.
Explore related projects
Loading…