ARDHOLT
Wrayfield Service Platform

A service platform, request to paid.

A working multi-role web app for a multi-site maintenance business: customer portal, dispatch board, engineers’ phones, invoicing, card payments, calendar and accounting integrations, an audit trail and reports.

Price for a platform on this scale: ask for a quote, fixed in a written scope before work starts. Get a quote → · Ask us for one like it

Open the working platform Logins for all five roles are on the sign-in screen

Built by Genco Doganay at Ardholt. Wrayfield Facilities is the multi-site maintenance business it is shown running: five customer organisations, 46 sites, 21 people in five roles, eight weeks of jobs, visits, invoices and payments.

The Wrayfield Service Platform: the dispatch board on a laptop and an engineer’s job on a phone.

1 · Five roles, five working screens

Each person gets the screens they need and nothing else. Permissions are enforced in the service layer, so a screen that forgets to hide a button still cannot do what its role may not.

01 · Customer

The one who asks

Raises a request for any of their sites, approves a quote when the job is over their limit, confirms finished work and pays the invoice.

  • Raise a request against a site and an asset, with the urgency that sets the clock: attend within 4 hours to a planned date.
  • A “Waiting for you” list of quotes to approve and work to confirm; invoices with card payment.
02 · Dispatcher

The one who books

Sees every new request with its clock running, triages it, prices a quote when the job is over the customer’s limit, and puts the right engineer in a slot.

  • A queue ordered by how close each request is to missing its attend-by time; a day board with every engineer’s visits on a time line.
  • The board refuses an engineer without the job’s trade, and a slot already taken.
03 · Engineer

The one on site

Works from a phone: today’s visits, set off, arrive, add parts, hold for parts, log time, write up the job and take the customer’s signature.

  • Set off tells the customer; arrival starts a timer; parts are added from the catalogue at their price on the day.
  • Completing needs the time logged and what was done written down, and can carry the customer’s drawn signature.
04 · Billing and ledger

The one who invoices

Issues invoices from confirmed work, records payments, and checks the accounting ledger against the platform to the penny.

  • Ready to invoice: confirmed work priced from the rate card, one click each, with aged debt by band.
  • The ledger page reads the trial balance from the accounting system’s own API, not the platform’s tables, and reconciles the two.
05 · Integrations and audit

The one who watches

Runs the platform: health of the four integrations, the event log, dead letters and their replay, the audit trail, users, rates and service levels.

  • Four integrations with health, retries, queue depth and response time, and outage switches to show a provider failing and recovering.
  • The audit trail: who changed what and when, written by database triggers, append-only; users, rates and service levels.
A paid job: its progress line from requested to paid, the request, the approved quote and the visit details.
A paid job, start to finish. Request, approved quote, visit and history.
The reports screen: jobs completed, attended and fixed within SLA, first-time fix, and weekly charts of jobs and invoicing.
Reports. Jobs completed, attendance and fix within SLA, first-time fix, and invoicing by week.

Want one like it? →

2 · The integrations, shown working

Card payments, email, calendar and accounting each run as their own provider. Three things worth seeing happen.

The ledger goes down, nothing is lost or posted twice

The accounting ledger is switched off on the integrations screen and an invoice is issued anyway. Its ledger entry waits in the outbox, retries with backoff, and posts when the ledger returns. The ledger holds one invoice, not two.

A webhook delivered twice, one payment

A card gateway delivers each payment event at least once. A switch on the integrations screen makes this one deliver every payment webhook twice. The receiver records one payment: the payment row is keyed by the gateway’s event id, and the second delivery is logged as a duplicate.

A forged webhook, or one signed with the wrong secret, is rejected before anything is recorded; a declined test card leaves the invoice unpaid.

Handled by the receiver and its signature check, described under How it is built.

What the customer actually received

Every customer-facing change sends a templated email through the mail service: request received, booked, on the way, completed, invoice, receipt. The Sent mail screen reads the messages back from the mail service’s own API, not from the platform’s tables, so what it shows is what the provider holds.

The sent-mail screen: customer messages listed on the left and one opened as the customer received it, an invoice with a Pay now button.

3 · The scope, agreed first

The shape of every job we take on: the scope is written and priced before work starts, with the checks that decide whether it is done. This is the scope this platform is built against.

What is delivered
  1. A multi-role web app with five roles (customer, dispatcher, engineer, finance, admin), sign-in, and permissions enforced in the service layer.
  2. The job workflow: 15 states and 18 moves, the SLA clocks by priority, the quote rule for jobs over the customer’s limit, the trade-skill and completion rules, automatic confirmation after 48 hours.
  3. Pricing and invoicing from the rate card (labour in quarter hours, parts at cost plus markup, call-out, VAT in whole pence), and card payments by payment intent with signed webhooks.
  4. Four integrations behind one HTTP-shaped transport: card gateway, mail, calendar with an ICS feed for each engineer, and accounting; with the outbox, retries, dead letters and replay, and the event log.
  5. The audit trail, written by database triggers on every audited table, and the reports: attendance and fix within SLA, first-time fix, engineer time.
  6. The working platform, so the scope can be checked on screen.
Not included
  • Connection to your own accounts at the card gateway, mail service, calendar and accounting package: scoped and priced with your brief. The transport is the one place that changes.
  • Hosting on your servers: the same schema and service layer move to a server database as part of the build.
  • Domains, and import of data from an existing system: scoped with your brief.
Acceptance checks
Agreed now, and checked with you before hand-over.
Timing
The platform as shown: designed and built as one build, from written scope to hand-over.

4 · How it is built

The whole system in one picture

Five roles work in one app. Every screen calls one service layer that holds the job workflow and the role checks. Every change lands in SQLite in one transaction with the messages it causes and the audit rows it earns. A worker delivers those messages to the card gateway, mail service, calendar and accounting ledger through one HTTP-shaped transport; signed webhooks come back.

Drag sideways to see the whole diagram

Architecture of the platformScreens call a service layer that holds the workflow table and role checks; it writes to SQLite with audit triggers; an outbox worker sends HTTP-shaped requests through a transport to a card gateway, mail service, calendar and accounting ledger; signed webhooks come back to a receiver.In the browserThe provider sideScreens: five roles, one appsrc/ui/screens/Customer portalcustomer.tsxDispatch boarddispatch.tsxEngineer's phoneengineer.tsxBilling and reportsfinance.tsxreports.tsxIntegrations, auditadmin.tsxService layersrc/domain/services.tsWorkflow table: 15 states, 18 movesRole and scope checks on every callPricing: rate card, quarter hours, VAT in penceworkflow.ts · auth.ts · pricing.tsWebhook receiversrc/platform.ts · src/integrations/hmac.tsVerifies the HMAC-SHA256 signatureRefuses anything outside the 5-minute windowOne payment per gateway event idSQLite in the browsersrc/db/db.ts · sql.js (WebAssembly)Integer pence, ISO UTC timesAudit triggers, append-onlySaved to IndexedDB after every commitdb/audit.ts · db/schema.sqlOutbox workersrc/integrations/outbox.tsBackoff with full jitter, Retry-After honouredDead-letters after 10 attempts; replay keeps its keyWrites every request and response to the event logactions.ts · emails.tsHTTP-shaped transportsrc/integrations/transport.tsRequests are built as for the real provider. Swapping this one function for fetch() points the app at live services.Card gatewaysrc/integrations/providers.tspayment intents · signed webhookssigned webhook back to the receiverMail servicesrc/integrations/providers.tstemplated customer messagesCalendarsrc/integrations/providers.tsan event per visit · ICS feedsAccounting ledgersrc/integrations/providers.tscontacts · invoices · paymentscallschange, outbox row and audit row in one transactionrecordspollssendrequests out
Every box is a real module, with its file under it. The dashed red line is the gateway’s signed webhook coming back to the receiver; everything else goes out through the outbox.

Rules live in one place

The workflow is a table: every state, every allowed move, the role that owns it and the rule it must pass. The buttons on the screens are drawn from it and the service layer refuses any move not in it, so the two cannot drift apart.

src/domain/workflow.ts

A message is never lost or sent twice

The outbox row commits with the change that caused it. Delivery backs off with jitter, honours Retry-After, stops on errors that cannot succeed, and dead-letters after ten attempts. Every request carries an idempotency key.

src/integrations/outbox.ts

One line to go live

The transport is the only place the app meets the outside. Each provider here is a local service behind it that answers with the same paths, headers and responses as the real one. Pointing the app at the real service is a change to that single function.

src/integrations/transport.ts
The job workflow: 15 states and 18 moves

A job moves from a customer’s request to a paid invoice along the line below. Each numbered arrow is one row of the transition table, owned by one role, with the rules it must pass. Above the main line is the quote route, taken when a job’s estimate is over the customer’s not-to-exceed limit for a single job (the NTE).

Drag sideways to see the whole diagram

The job workflow: 15 states, 18 movesState machine drawn from the platform's transition table. Each numbered arrow is one move; the numbered list beside the diagram names the role that makes it and the rule it must pass.RequestedrequestedTriagedtriagedScheduledscheduledEn routeen_routeOn siteon_siteCompletedcompletedVerifiedverifiedInvoicedinvoicedPaidpaidQuote requiredquote_requiredQuote sentquote_sentQuote approvedquote_approvedQuote declinedquote_declinedOn holdon_holdCancelledcancelled1234566789101211131415161817The quote routeRed ring: the move has a rule to pass, or belongs to the assigned engineer aloneDashed: cancel, from any of the seven states before work starts
Drawn from the transition table, not by hand: the states, the arrows and the numbers are the rows of TRANSITIONS in src/domain/workflow.ts.
The data model, and the rules the database enforces

The diagram is drawn from schema.sql, table by table, with the key columns of each and what makes them worth reading. The six tables that belong to a job meet one trunk into jobs, and the one from invoices back to a job runs along the top. Every key is also named on its column; those to users and trades, which almost every table has, are named rather than drawn.

Drag sideways to see the whole diagram

The data modelEntity-relationship diagram drawn from the platform schema: people and places, the job and its history, money, integrations, audit; the provider side's nine tables apart.People and placesAuditSettings and secretsThe job and its historyMoneyIntegrationsusersPKidFKorg_id→ organisationsemailuniquerolepassword_hashactive+ 4 more columnsengineer_skillsPKuser_id→ usersPKtrade→ tradestradesPKcodenamerate_cardsPKtrade→ tradeshourly_pencepencecallout_pencepenceooh_multiplier_bpaudit_logPKidatUTCactor_identityentity_idactionchangessession_actorPKonlyactor_idatUTCorganisationsPKidnamekindnte_pencepencepayment_terms_daysaccounting_contact+ 2 more columnssitesPKidFKorg_id→ organisationscodeuniquepostcoderegion+ 4 more columnsassetsPKidFKsite_id→ sitesFKtrade→ tradestaguniquelabel+ 3 more columnssla_policiesPKpriorityattend_hoursfix_hours+ 1 more columnsettingsPKkeyvaluesecretsPKnamevaluejobsPKidrefuniqueFKsite_id→ sitesFKasset_id→ assetsFKtrade→ tradesFKpriority→ sla_policiestitlestate15 statesFKraised_by→ usersraised_atUTCattend_byUTCfix_byUTCestimate_pencepenceFKengineer_id→ usersscheduled_startUTCcompleted_atUTCFKverified_by→ usersversionoptimistic lock+ 7 more columnsquotesPKidnumberuniqueFKjob_id→ jobsnet_pencepencegross_pencepencestatussent_atUTCdecided_atUTCFKdecided_by→ users+ 2 more columnssignoffsPKjob_id→ jobssigned_namesignature_svg+ 1 more columnjob_transitionsPKidFKjob_id→ jobsfrom_stateto_stateFKactor_id→ usersatUTC+ 1 more columnjob_notesPKidFKjob_id→ jobsFKauthor_id→ usersvisibilitybody+ 1 more columnlabour_linesPKidFKjob_id→ jobsFKengineer_id→ usersstarted_atUTCminutesout_of_hours+ 1 more columnpart_linesPKidFKjob_id→ jobsFKsku→ partsqtyunit_cost_pencepenceunit_price_pencepencepartsPKskunameFKtrade→ tradesunit_cost_pencepencemarkup_bpinvoicesPKidnumberuniqueFKjob_id→ jobsFKorg_id→ organisationsnet_pencepencevat_pencepencegross_pencepencestatusaccounting_ref+ 4 more columnsinvoice_linesPKidFKinvoice_id→ invoiceskindqtynet_pencepence+ 2 more columnspaymentsPKidFKinvoice_id→ invoicesamount_pencepencegateway_refunique+ 3 more columnsoutboxPKididempotency_keyuniquestatusattempts+ 7 more columnsintegration_eventsPKidadapterFKoutbox_id→ outboxhttp_statusoutcome+ 7 more columnsThe provider side: local services that answer like the card gateway, mail service, calendar and ledgerThe app never reads or writes these nine tables. It reaches them only through the HTTP-shaped transport, as it would reach the real providers.ext_gateway_intentsPKidamountcurrencystatusinvoice+ 3 more columnsext_gateway_eventsPKidtypeintentcreateddeliveriesext_idempotencyPKproviderPKkeyresponseext_mail_messagesPKidatto_addrsubjecthtml+ 1 more columnext_calendar_eventsPKuidcalendarstartendsummary+ 4 more columnsext_ledger_contactsPKidnameemailext_ledger_invoicesPKidnumbercontactdatedue+ 5 more columnsext_ledger_paymentsPKidinvoiceamountdatereferenceext_ledger_journalPKiddatesourceaccountdebit+ 2 more columnsThe only way inEvery request out and everywebhook in passes throughtransport.ts
The provider side, drawn apart: 9 tables belonging to the local services that answer like the card gateway, mail service, calendar and accounting ledger. The app never reads them; it reaches the providers only through the transport, exactly as it would reach real ones.
  • Integer penceEvery amount is stored as whole pence; VAT is worked out in whole pence; a quote or invoice cannot save unless net plus VAT equals gross.*_pence · CHECK (gross = net + vat)
  • ISO UTC timesEvery time is stored as ISO-8601 text in UTC, so a deadline compares and sorts as text and means one thing everywhere.raised_at · attend_by · fix_by
  • Optimistic concurrencyA job carries a version. A change made from an out-of-date copy is refused instead of overwriting someone else’s.jobs.version
  • Transactional outboxA state change and the messages it causes commit together: nothing is sent for a change that rolled back, nothing is lost for one that committed.outbox · idempotency_key UNIQUE
  • Append-only audit logTriggers are built from each audited table’s own column list, so a new column is audited without anyone remembering to. The database refuses updates and deletes to the log.audit_log · audited tables
  • One payment per eventA payment row is keyed by the gateway’s event id, so a webhook delivered twice cannot pay twice.payments.gateway_ref UNIQUE
  • Rules in the schemaThe job’s state is a closed list, a visit cannot end before it starts, a booked job must have an engineer: the database says no even if a screen forgets to.CHECK constraints
Every call to a provider, on the record

Every call is on the record

Open any row in the event log and the request that left and the response that came back are there: method, path, headers, idempotency key, body, status and time taken.

This one is the card gateway’s signed webhook arriving. The receiver checks the HMAC-SHA256 signature and its timestamp before it records anything, and answers with a 200.

The integrations screen with one event-log row opened: a signed card-gateway webhook arriving, its request with the HMAC signature and the response.
The stack and how to run it

How the platform is built, what it weighs and how to run it.

84 kBapplication script

Gzip. Records-building worker 47 kB, SQLite WebAssembly 337 kB, CSS 6 kB, two fonts 69 kB.

8weeks of jobs, visits, invoices and payments

Produced by running them through the platform’s own workflow.

Stack and how to run it

Front end
Preact and TypeScript, built with Vite. Inter and JetBrains Mono served from the app itself.
Data
SQLite 3 in the browser through sql.js (WebAssembly), saved to IndexedDB after every commit.
Sign-in
PBKDF2-SHA256 password hashes; sessions per tab.
Hand-off note
What you receive: the source and the commands to run it.

The companion piece

The same business, automated: see the automation system that runs its tools.

Want one like it?

Send us what you have and what it needs to do. A written scope and fixed price follow. Nothing starts until you agree.

[email protected]

You deal with us directly, from the first reply to hand-over.

Get a quote → · See all the work