Skip to content

Fastify (Legacy)

Neemias' original backend was built with Fastify + PostgreSQL, running on a Debian server with deploy via Docker Compose. This architecture was removed in version v0.22.0 and fully replaced by the current stack: Cloudflare Workers + D1 (SQLite).

Migration History

The decision to abandon Fastify/PostgreSQL was driven by three main factors: the operational cost of maintaining a dedicated server, the complexity of managing PostgreSQL schema migrations in environments with intermittent connectivity, and the desire to align the backend with the serverless architecture already adopted on the frontend (Cloudflare Pages). The full migration is documented in two architectural decisions:

  • ADR-0008: Established the original PostgreSQL schema — students, users, attendance events, immutable event log, audit log, and idempotency ledger. This structure served as the baseline for the D1 conversion.
  • ADR-0009: Defined the original deploy model — a Debian host with Docker Compose services (app, db, auth) on a private bridge network, accessible via LAN/Tailscale.

When the migration to Workers was completed, the backend/ workspace was removed from the monorepo. Today, the legacy backend documentation remains only as a historical reference in the docs/archive/backend/ directory. All business logic — PBKDF2 authentication, JWT, entity CRUD, offline sync, idempotency, and rate limiting — was reimplemented in the worker.

What Changed

AspectFastify (Legacy)Workers (Current)
RuntimeNode.js + FastifyCloudflare Workers (WinterCG)
DatabasePostgreSQLD1 (SQLite)
DeployDocker Compose on Debianwrangler deploy serverless
AuthenticationJWT + pgcryptoJWT HS256 (jose) + PBKDF2 manual
SchemaPostgreSQL migrationsD1 migrations (migrations/)
SyncSynchronous RESTOffline-first with Dexie queue + POST /sync/event

The migration preserved API contract compatibility — the /api/v1 prefix, request/response formats, and error envelope remain identical. Clients that used the Fastify API continue to work with the Worker without changes.

⚠️ Section under expansion.


Source: ADR-0008 + ADR-0009 + Changelog v0.22.0

Distributed under MIT License.