← Vuorokone

Vuorokone's architecture: the demo today, the real app next

Vuorokone plans cleaning visits for Kotova Oy and covers sick cleaners' visits the same day. The demo runs entirely on one computer. The real app keeps the same code and database rules, and moves them online with real email, push alerts and backups.

1 codebasefor the demo and the real app
1 source of truthPostgreSQL holds every rule
0 €running cost, on free tiers
Running today

Demo app: everything on one computer

Your computer · nothing is online You test accounts Tests unit · database · browser Browser localhost:5174 office and phone layouts Vite dev server source code, hot reload Docker · local Supabase Gateway :55321 Auth email link · password REST API runs as the signed-in user Sign-in function phone · passkeys · QR Storage API profile photos PostgreSQL :55322 same rules as real sample data: 20 cleaners 16 customers test accounts Photo storage 22 sample photos Mailpit :55324 catches every email Google · X not connected pg_cron nightly jobs serves app API calls sign-in emails files drive
The demo is the real code, run locally. The browser loads the app from the Vite dev server and calls a local copy of Supabase in Docker. Blue arrows are the calls that reach PostgreSQL directly; the sign-in function and Storage API also check access there. The database can be reset to the same sample data at any time.
Planned

Real app: online for Kotova's teams

Kotova staff office · cleaners Own domain DNS · HTTPS Static host + CDN built app files cached near users Web app desktop for the office installed on phones offline day view push alerts Browser push service planned Hosted Supabase · EU region API gateway · one HTTPS entry Auth email link · password Google · X switched on REST API runs as the signed-in user Storage API photos, 1-hour links Edge functions sign-in push sender · planned Transactional email free tier, SMTP · planned PostgreSQL row-level security assignment rules visits · hours · outbox change log GDPR export, erase Kotova's real data Object storage private photos pg_cron visits · clean-up retention · planned Encrypted backups nightly, EU · planned 1 look up 2 load 3 run 4 emails alerts runs jobs built planned reaches the database
The same app and database rules, moved online. Solid boxes are built and only need deploying; dashed amber parts are planned in the project roadmap. Customer notices from the outbox are still sent by the office from its own phone or email, because paid SMS is left out of version 1.0.

What changes from the demo to the real app

The code and the database rules stay the same. What changes is where each part runs, whose data is in it, and the services around it.

PartDemo todayReal app
UsersTest accounts that share one development passwordKotova staff, each invited by email; nobody else can make an account
Addresslocalhost:5174Its own domain over HTTPS
Serving the appVite dev server with hot reloadBuilt files on a static host with a CDN
BackendSupabase in Docker on the laptopHosted Supabase Free, in an EU region
DataSample data: 20 cleaners, 16 customers, 22 photos; reset at any timeKotova's customers and schedule, brought in by CSV import
EmailMailpit catches every email; nothing leaves the computerA free transactional email service as custom SMTP
Google and XButtons onlySwitched on in Supabase Auth
Sign-in functionLocal edge runtimeDeployed, accepting passkeys and QR codes only from the app's own addresses
AlertsScreens refresh every 30–60 secondsWeb push for offers, published changes and sick reports, with email as fallback
OfflineNeeds the connectionThe cleaner's day view works offline
BackupsNone neededNightly, encrypted, EU-hosted (place still to choose)
PrivacyNot needed for sample dataPrivacy notice, GDPR export and erase, retention clean-up
Cost0 €0 €, on free tiers with no card on file

Amber text marks what is planned in the roadmap but not built yet.

The reference model, explained

The assignment's picture shows a typical web system built to be scalable, reliable and efficient. A request travels from left to right, and slow work is moved aside so the user never waits for it.

1Users

People using the system through a browser or app. Everything else exists to answer them quickly and correctly.

2DNS

The internet's phone book: turns a name such as app.example.com into the servers' address, and can send users to the nearest region.

3Load balancer

One front door that spreads requests over many servers, skips servers that are down, and lets servers be added without users noticing.

4Web servers

Handle HTTP: serve pages and files, handle HTTPS, and pass the real work on. Kept stateless so any copy can answer any request.

5Application servers

The business logic: check who you are, apply the rules, read and write data. Also stateless, so they scale by adding copies.

6Database

The lasting record of truth. Usually the hardest part to scale, so the cache and background work protect it.

7Cache

A fast in-memory store, such as Redis, for answers read often. Cuts database load and response time; must be refreshed when data changes.

8Message queue

A to-do list between services. The app server drops a job in and replies at once; the job waits safely until a worker takes it.

9Worker services

Background processes that take jobs from the queue, such as emails, reports or image processing, and can update the cache when done.

10Object storage

Cheap, lasting storage for files such as photos, for example S3. Files stay out of the database and are served by link.

How the real app maps onto the model

Vuorokone uses a managed backend, Supabase, instead of running its own servers. Most boxes from the model are still there, but some are merged, because one company with about 20 cleaners does not need ten separate services.

ModelIn VuorokoneWhy this way
UsersOffice staff on the desktop layout; cleaners on the phone layout. One codebase picks the layout by role.Cleaners need today and this week; the office needs the planning board.
DNSThe app's domain points to the static host; the API has its own Supabase address.The two halves can move or scale on their own.
Load balancerThe Supabase API gateway: one HTTPS entry that checks the API key and routes /auth, /rest, /functions and /storage.Run by the platform; no servers to manage.
Web serversA static host with a CDN serving the built React app. No server rendering.Static files are cheap, fast and fit a free plan.
Application serversThe REST API (PostgREST) with database functions, plus edge functions for sign-in and, later, push.Rules live next to the data, so no client can skip them.
DatabasePostgreSQL with row-level security on every table, built from 10 migrations.One source of truth; each person sees only their own company.
CacheThe browser's query cache (TanStack Query) and the CDN. Photo links are reused for 50 minutes.No Redis needed at this size; the cache sits where the reads happen.
Message queueThe customer outbox table: a published change drafts one notice per visit, and the office sends it and marks it sent.A table-backed queue cannot lose a notice and needs no extra service.
Worker servicespg_cron jobs in the database: create visits nightly at 01:15 and clear old sign-in attempts hourly.Simple scheduled work; nothing extra to deploy or watch.
Object storageA private avatars bucket: JPEG only, 1 MiB per file, opened through signed links.Photos stay out of the database, and only colleagues can see them.

Three requests, end to end

A cleaner reports sick

  1. The phone app sends the report to the REST API with the cleaner's token.
  2. PostgreSQL saves the absence; row-level security makes sure it is their own.
  3. The office's Today screen lists the visits left without a cleaner.
  4. A planner picks a replacement, ranked 0–100 by travel, familiarity and free hours.
  5. The database refuses missing skills, clashes and absences.
  6. On publish, the new cleaner's phone shows the visit and the outbox drafts a customer notice.

A cleaner changes their photo

  1. The browser crops the picture to a 512 px JPEG before anything is sent.
  2. The Storage API saves it in the person's own folder; a policy refuses any other folder.
  3. The profile points at the new file and the old file is removed.
  4. Colleagues' apps fetch fresh links for the whole team in one request.

Someone signs in

  1. Email link, password, Google or X go to Auth.
  2. A database hook refuses anyone without an invitation.
  3. Phone number, passkey and QR code go through the sign-in function, which checks them and then makes a normal session.
  4. Five wrong tries lock a phone number for 15 minutes.

Scalable, reliable, efficient, and the trade-offs

Scalable

The app is static files on a CDN, so more users cost almost nothing. The backend is stateless behind the gateway, and team-wide reads are batched into one request. The database is the limit, and can move to a larger plan.

Reliable

Rules are enforced in the database, so a bug in the app cannot give a visit to someone without the skill or with a clash. The outbox keeps every notice until it is handled. 256 database tests and 23 browser tests, run in Chromium and Firefox, cover the main paths.

Efficient

Free plans with no card on file. Live screens refresh only while they are open. Photos are shrunk in the browser before upload, so storage and transfer stay small.

Secure

Row-level security on every table, invitation-only accounts, a private photo bucket with signed links, rate-limited sign-in, and passkeys and QR codes accepted only from the app's own addresses.

Trade-off: polling

The demo refreshes on a timer: simple and enough for one office. The real app adds push alerts; with many companies, a realtime channel would cut needless requests.

Trade-off: no separate queue

The outbox table and pg_cron are enough today. Sending messages automatically, or heavy reports, would add a real queue and worker functions.

Trade-off: logic in the database

Strong guarantees and one place for the rules, but SQL is harder to change than app code. Database tests keep it safe to change.

Trade-off: one region

Fine for one company in Finland. Many customers would need read replicas, connection pooling, backups in a second place and a shared cache.

Still to decide with Kotova: whose name the hosting accounts are in, where the nightly backups live, and which email service's free tier to use.