Runs on the clinic's own machine
All AI inference runs locally through Ollama. Medical histories and owner contact details never leave the premises, and there's no per-question cost or API key to manage.
A case study of the system behind the product: how a single backend enforces five access modes, how the assistant decides where each question goes, the three forecasting models and their error bars, the data model, testing, and what broke along the way.
VetCare One was built for Pro Pet Animal Hospital, a single-site veterinary clinic in Sri Lanka, to replace paper files and spreadsheets with one system covering the clinical and commercial side of the practice.
It was then extended during an eight-week AI Launchpad programme with two additions: a retrieval-augmented AI assistant grounded in the clinic's own data, and a native iOS app that gives pet owners and prospective clients their own self-service access.
Every AI feature is positioned the same way: decision support for a qualified veterinarian, never a replacement for one.
Pick who is asking and what they ask. The answer changes, and so does the route the question takes through the system. That route is decided by the server from the login, never by the app.
Signed in as
Ask
These are scripted replays that follow the system's real routing and role rules. Pet names, counts and figures are illustrative, not captured output. The row below is captured output.
Captured from the live system against the clinic's demo database, with the assistant answering on the local model — nothing here is a mock-up.
Clinic staff
AI assistant
Pet owners & guests








The native SwiftUI app gives owners the same portal, calling the same backend under the same access rules.




Demo data only. Web screens captured at 1440 px; iOS screens from the iPhone simulator.
Front desk, clinical, billing, inventory, analytics and administration — each screen from the running system. Click any screen to enlarge it. Contact details are blurred.
Access is decided by the server from your login, and enforced again inside the database query — never trusted to the app or the AI model.
| Capability | Guest | Pet owner | Receptionist | Vet | Admin |
|---|---|---|---|---|---|
| General pet-care answers & clinic FAQs | Yes | Yes | Yes | Yes | Yes |
| Own pets, appointments and balance | No | Own only | Yes | Yes | Yes |
| Book, reschedule & register by chat | No | No | Yes | Yes | Yes |
| Billing — invoices & payments | No | Own balance | Yes | View only | Yes |
| Clinical drafts & diagnosis detail | No | No | No | Yes | Yes |
| Pet health & outbreak risk | No | No | No | Yes | Yes |
| Register staff members | No | No | No | No | Yes |
Summary of role boundaries across the app and the assistant.
Most "AI-powered" tools hand the question to a language model and hope. VetCare One routes each question to the part of the system that can answer it reliably, and uses the model only where language is the actual job.
All AI inference runs locally through Ollama. Medical histories and owner contact details never leave the premises, and there's no per-question cost or API key to manage.
"How many appointments today?" is answered with a real database query. A language model only ever sees a small sample of records, so it's never asked to total them up.
A patient history summary fetches every relevant record by SQL and hands the complete set to the model — so a "full history" is never a partial one presented as complete.
The assistant proposes bookings, registrations and reminders; a person confirms them. Generated clinical notes are drafts, and no email goes out without review.
The model turns free text into structured fields. Every pet, owner, vet and date is then resolved by database lookup — and when a name is ambiguous, it asks rather than picks.
Forecasts and risk scores are labelled as estimates. The guest assistant never names a medicine. Every answer points back to a qualified veterinarian's judgement.
Each model trains on the clinic's demo database: seeded data from January 2024 to September 2026, not real patient records. The figures below come from the latest training run in September 2026. Where the numbers are weak, this section says so.
Random Forest · K-Means · Prophet
Limits. The model is about twice as good as guessing, but nowhere near diagnostic grade. Three categories (neoplastic, genetic, nutritional) have fewer than 16 examples each. Its output is a starting point for an examination, never a diagnosis.
Prophet · Random Forest
Limits. Revenue is recorded on only about 40% of days, so a single day's prediction is close to noise. The error on a month is about 38% of an average month. The app's forecast band is ±60%, the historical month-to-month variation, and it is shown on screen rather than hidden. Read the direction, not the exact figure.
Gradient Boosting
Limits. Most items have little recorded usage so far. The training target is itself a projection (average daily use × 30, adjusted for trend) rather than observed next-month consumption, so for now the model smooths a heuristic instead of learning from real outcomes.
This is the model's own output on the demo data. The monthly totals and the ±60% band follow the same aggregation as the app's Sales Forecasting screen. Drag to change the horizon, and hover for values.
| Month | Actual (Rs) | Forecast (Rs) | Band (Rs) |
|---|
September 2026 is a partial month: the data ends on 12 September. The March 2026 spike is in the source data.
The pet health predictor is not trained. It computes four scores live from rules and from breed predisposition tables compiled from veterinary literature, so it works from day one. The trade-off is that it doesn't learn from the clinic's own outcomes. These are the calculations as the code runs them.
Uses only this pet's own history. The more often a category has recurred, the higher the 12-month risk, scaled linearly to other horizons.
A breed baseline (species baseline if the breed isn't listed) scaled by an age multiplier. It returns per-type risk and screening suggestions.
Compares the last eight weeks of cases with the eight before, then projects forward with dampened growth.
An R₀-style estimate over the last 12 months. It weighs how contagious the caseload is, how many transmission routes appear, and how many species are affected.
Cancer and tumour risk
Suggested screening
Recurrence risk for that category
Runs the same tables and formulas as pet_health_predictor.py, in your browser. This is decision support for a vet, not a diagnosis.
Most questions never reach vector search. A question passes through a fixed chain of handlers, and the first one that can answer it reliably takes it. Search only gets whatever is left.
Outbreak risk, disease trend, revenue forecast and reorder questions from admins and vets go straight to the trained model. Receptionists get a clear "not for your role". For guests and owners, the same words ("what should I do in an outbreak?") are ordinary pet-care questions, so they fall through.
Book, reschedule, cancel, remind, register. The model extracts slots as JSON, and every pet, owner, vet and date is then resolved by SQL. The handler proposes an action; nothing is written until a person confirms it.
History summaries, consultation notes, aftercare and pre-visit briefings. Every relevant row is fetched by SQL, because a "full history" built from a top-5 sample is a partial history.
Recurrence, cancer and pandemic risk computed live by the risk engine above, never from retrieved text.
Claims a question only when it contains a trigger word (chart, graph, plot, visualise), so "what's our revenue?" stays a sentence. It runs just before the exact-query handler because the two share nouns.
Counts, lists, clinic hours and an owner's own balance, all answered by deterministic SQL. The language model never totals anything.
The question is embedded and matched against the five nearest chunks by cosine distance, with role and owner filters applied inside the SQL. The local model then writes an answer grounded in those chunks.
Medical records, disease cases, lab-report metadata, vaccinations, public FAQs and internal staff FAQs. Each record becomes one chunk, so one citation points to one record. Chunks are embedded locally with nomic-embed-text (768 dimensions), and the demo database holds 702 of them.
Chunk format · medical record (example values)
Kept in sync, not rebuilt. Saving a record re-embeds just that record. Deleting one deletes its chunk; there's no foreign key to cascade, so a missed hook would leave the assistant citing deleted data. Renaming a pet re-embeds all of its chunks, because the name is part of the text.
Citations are data, not prose. The retrieved chunks come back with the answer and appear as source chips. The model is told not to write "(Source 1)" inline. Guest search has a relevance cut-off, so a question no FAQ matches doesn't show five loosely related FAQs as if they were its sources.
The role and owner ID come from the verified login. The client never sends them, so it has nothing to tamper with. The filters below are part of the retrieval SQL itself.
| Caller | Chunks the search can see |
|---|---|
| Guest | Public FAQs only: no pet, no owner, no staff FAQs |
| Pet owner | Chunks carrying their own customer ID, plus public FAQs |
| Receptionist | Clinic-wide, excluding medical records, disease cases and lab reports |
| Vet, admin | Clinic-wide, including internal staff FAQs |
Everything runs on a 16 GB machine through Ollama. Text (qwen3:8b) and vision (qwen3.5:9b) are deliberately separate models. Both can't stay in memory at once, so Ollama swaps in whichever one a request needs, and the first request after a switch waits for the swap. Every call shares one 8,192-token context window: a pet-owner question alone measures about 3,600 tokens before the answer starts.
The web and iOS apps never touch the database or the AI directly. Every request passes through the backend, which establishes who is asking before any question is read.
The backend verifies the login and attaches role and owner ID itself. The app can't claim more access than it has.
The question goes to the handler that can answer it: an action, a clinical tool, a live risk model, an exact SQL query, or search.
Only then is the local model used — to phrase the answer, cite sources, or draft text for a person to review.
The core schema has 17 PostgreSQL tables. Migrations add the pgvector store and a few AI tables. The diagram shows the tables that hold the clinic's records.
Hover over or tab to a table to see what it links to.
Staff accounts (users) are referenced from nearly every table: as the vet on appointments and records, and in the created-by and updated-by audit fields. Those lines are left out to keep the diagram readable.
Self-service booking follows constants defined in a single file, which both the booking endpoint and the availability endpoint read, so they can't drift apart. The slot picker below applies the same rules against your clock.
Slot occupancy is simulated. The day, hours and lead-time checks mirror appointmentRules.js.
The code's pure logic is covered by unit tests. The parts that need a live database and a local model are covered by written manual procedures, which are run before every demo.
| Suite | Covers | Tests |
|---|---|---|
| Booking rules | Open days, closing-time fit, slot spacing, 48-hour lead time | 13 |
| Auth utilities | Hashing, token tampering, a customer token can never pass staff auth | 10 |
| Role checks | Every role against every guard | 8 |
| Chat UI | Source-citation labels and the FAQ-grounding check | 10 |
| Model client | Currency normalisation and stray-token stripping | 9 |
| Answer clean-up | Removing imperial-unit asides without touching metric text | 6 |
| Total | Node test runner, Vitest, pytest | 56 |
Plain RAG answered "how many pets are named Max?" from five retrieved chunks, with a confident, well-formatted, wrong number. An invented drug name looks odd; a wrong count doesn't.
Fix: aggregate questions go to SQL. The model is also told to decline any count it would have to compute from a sample.
Unscoped search on a common name returned several pets' records blended into one story.
Fix: names are resolved by database lookup. When more than one pet matches, the assistant asks which one, with each option labelled by its owner. With no server session, the half-finished request travels back and forth through the client.
Ollama's default 4,096-token window was smaller than several prompts. It dropped the front of the context (the system prompt first) and still reported a clean finish, so answers just stopped mid-thought.
Fix: one fixed 8,192-token window for every call. A value of 16,384 crashed the machine by running out of memory. Overruns are now detected from token counts and logged.
A single model for both text and photos, or keeping two warm at once, doesn't fit the clinic's hardware.
Fix: separate text and vision models that Ollama swaps on demand. The only cost is a one-off delay when switching between them.
However the prompt was worded, the local model kept adding "(65 lbs)" after metric weights.
Fix: when a small model reliably breaks a rule, enforce the rule in code. A tested regular expression now strips those asides.
Vector chunks have no foreign key to the records they came from, so deleting a medical record left its chunk in search results.
Fix: every create, update and delete path now calls the matching re-embed or delete hook. Renaming a pet re-embeds all of its chunks.
Repository created for Pro Pet Animal Hospital's management system.
React client, Express API and the PostgreSQL schema laid down.
Presented on a demo dataset in mid-February. The Flask ML service and first disease model followed within days.
Sales and inventory models trained. The pet health risk engine was added.
Requirements written, the iOS app started and the RAG assistant built. It was completed for receptionists, vets and admins by the end of the month.
Unit tests, charts in chat, the AI daily briefing, and AI Visual Care for pet owners.
Briefing caching, and this site.
React 19
Vite
React Router
Recharts
Node.js
Express 5
PostgreSQL
JWT auth
Python · Flask
scikit-learn
Prophet
Pandas
Ollama (local)
qwen3:8b · text
qwen3.5:9b · vision
pgvector, 768-dim
Swift
SwiftUI
iOS native
Deferred work is a matter of timing. The boundaries on the right are permanent and don't depend on any release.
Closes gaps the assistant already runs into.
Larger steps beyond the first release.
Boundaries by design.
The live demo runs VetCare One for Pro Pet Animal Hospital with one-click logins for every role. Fictional data, reset nightly.