MAT-Inspect
Role: Technical lead on a team of five. I wrote 26 of the project’s 29 ADRs.
Proof: GitHub repo. ADRs behind the Key Decisions below: 0018, 0028, 0017, 0002, 0012.
Digital pre-use inspections for cranes, trucks, and forklifts. Paper checklists out, tamper-evident records in.
Problem
A college lab had ten pieces of high-risk equipment: four overhead cranes, two trucks, an electric pallet jack, and three forklifts. Operators had to inspect each one before use, on paper. The sheets were inconsistent and often incomplete. Records went missing. A manager could not tell who had inspected what, and pulling records for an audit was slow.
Alberta safety rules, as the project reads them, require a competent person to complete the inspection and to be identified on the record. So the system had to do three things:
- Make the checklist fast enough to use in gloves, including dictating defect notes by voice.
- Lock out equipment the moment a blocking item fails.
- Keep a record that shows when it has been edited.
The sponsor also asked for an AI feature. That created the main design problem: use AI without letting it make a safety call.
Role
I was the technical lead for a team of five over a 13-week capstone. I ran the architecture and wrote most of the decision records. I used AI coding assistants (Claude) throughout. For design decisions, I reviewed AI-generated pros and cons and made the calls myself. I own those decisions.
- I built: the AI service (
services/ai), the shared auth package for Entra ID sign-in (packages/shared-auth), the Caddy gateway configuration and its ADR (0020), the docs and ADRs, the CI pipelines, and the scripts. - I led: the operator PWA and the manager dashboard. I wrote most of the code in both, and teammates contributed.
- We built together: the core API and the database.
- I designed, a teammate built: I designed how inspections are attested and delivered into the audit chain (ADRs 0007 and 0008). A teammate built the audit service. A teammate built the media service.
Architecture
Operators use a phone PWA. Managers use a dashboard. Both sit behind one front door, which is Caddy in local and staging runs and Azure Front Door in the cloud demo. Users sign in with Microsoft Entra ID. Behind the front door there are three Fastify services (core API, media, audit) and one Python FastAPI service for AI. PostgreSQL holds two databases, core and audit. The audit writer role can only insert and read.
Two choices shape the picture. The AI service has no public route and no auth of its own. The PWA reaches it only through core-api, so one auth path covers it (ADR 0019). And a failed blocking item flips equipment to out of service automatically. Return to service needs a supervisor or manager.
Key Decisions
1. The AI never passes or fails an inspection, and it is self-hosted
- Context: The safety rule says a competent human completes the inspection. We treated voice clips as biometric personal information under Alberta’s privacy law, and note text as inspection data.
- Options: A cloud model (Azure AI Foundry). A keyword rule engine. A model that blocks submission or changes the result when it spots a contradiction.
- Choice: Whisper and a small language model run by default on a single mini PC, my own, used as the team’s staging host, text only, no audio off the box. The same container ran on Azure for the synthetic-data demo. The AI is advisory. It never blocks submission and never changes the result. No raw model output is stored. Only the category the operator confirms is recorded.
- Why: Running on our own hardware removes the question of sending data to a third party. A rules engine is not the AI feature the sponsor asked for. A model that decides pass or fail breaks the safety rule. Cloud stays as an upgrade path, not the default.
- ADR: 0018
2. Suggest a defect category on fail notes, and the operator confirms it
- Context: I built an advisory check meant to flag notes that contradicted a PASS mark. Before it was wired into the app, the PWA moved all notes to failed items, so the check had nothing to read.
- Options: Bring back notes on passing items. Auto-assign a category. Use a manual dropdown only.
- Choice: The model reads a fail note and suggests one of seven failure modes, such as leak, wear, or damage. The operator confirms, changes, or dismisses it. Only the operator’s choice is stored. The model never suggests severity, because the checklist fixes that.
- Why: The item already says which part failed. The note says how it failed. That is the one thing worth a model. I measured it on the mini-PC with a 57-note test set I wrote: 41 right (71.9%), and 38 of the 45 defect notes (84.4%). I also tuned the prompt on that same set, so treat the numbers as a rough guide. It was good enough for a suggestion a human checks.
- ADR: 0028
3. Cap AI concurrency instead of autoscaling
- Context: Transcription is CPU-bound, and the whole stack ran on one mini-PC. More replicas would only fight for the same cores.
- Options: Compose replicas. Docker Swarm. Kubernetes with autoscaling. A job queue with workers.
- Choice: A CPU limit on the container, a concurrency cap of 2, and transcription that runs off the submit path. If the service is busy or down, the operator types the note.
- Why: I benchmarked it with 10-second clips. At two concurrent clips, transcription plus the original advisory check had a 95th percentile of 3.7 seconds. At four it was 6.6 seconds, past the 5-second target. Heat was never the limit. Autoscaling waits for a real orchestrator after handover.
- ADR: 0017
4. Entra ID replaces Keycloak
- Context: The original design used Keycloak. Every intended user already had an organization account in Entra ID, and there was one identity source.
- Options: Keycloak brokering to Entra ID. Keycloak with its own user store.
- Choice: Entra ID is the only identity provider. Services verify JWTs against its public keys. Roles are App Roles assigned in the Azure portal.
- Why: A broker with one upstream adds a container to run and no benefit. A second user store means a second set of passwords to keep in sync.
- ADR: 0002
5. Call the API with access tokens, not ID tokens
- Context: With one app registration, an ID token passes the API’s audience check by coincidence. It would have worked.
- Options: Send the ID token as the bearer. Request an access token for a custom API scope.
- Choice: The shared auth package requests an access token for
access_as_user. ID tokens stay in the browser session. - Why: ID tokens say who the user is. Access tokens authorize calls. Mixing them depends on configuration that can change. The ADR records this so a later engineer does not “simplify” it. A related guard (ADR 0014) crashes the API at boot if any route lacks an auth check.
- ADR: 0012
Results
- Delivered and documented. The full stack runs locally on synthetic data once you supply your own Entra app registration. It has 29 ADRs, an operations runbook, and a handover package.
- Cloud demo. We ran a live demo on Azure Container Apps on synthetic data. It was taken down after submission.
- AI measured, not assumed. Transcription plus the original advisory check measured 3.7 seconds at the 95th percentile at two concurrent 10-second clips on the mini-PC. I did not re-run that for the category model. The category model scored 71.9% on a 57-note test set I wrote, which I also used to tune the prompt.
- Checked automatically. The repo has 838 automated test cases: 759 Vitest cases across the services, apps, packages, and infra scripts, and 79 pytest cases for the AI service. I counted them by listing the tests, not by reading pass results. On every push and pull request to main, CI runs both suites, lint, type checks, and Docker image builds. A separate pipeline runs Gitleaks, Semgrep, Trivy, and an npm audit.
- Demoed to the sponsor. The project received an A.
- Not in production. No real workers used it, and it has not run on real inspection data.
- A trade-off. An inspection takes slightly longer than the paper checklist. Two things add time. Every inspection ends with a review-and-confirm step before submit. On failed items, the operator can add a note, typed or spoken, and some items also require a photo. I did not time it.