Health data is everywhere.
Your smartwatch knows how many steps you took.
Your phone knows roughly how much you slept.
Your medical provider knows your laboratory results.
Your pharmacy knows what medication you collected.
Your fitness application knows your workouts.
Your nutrition application knows what you ate.
Your blood-pressure monitor knows your readings.
Your doctor has notes.
Your hospital has records.
Your insurance provider has claims.
And somehow, the person all of this data is actually about — you — often has the least convenient view of it.
This is a software architecture problem.
Not merely a healthcare problem.
We have built hundreds of specialized systems that know individual pieces of a person's health story, but we have not always built equally good systems for assembling those pieces into a coherent timeline.
That is where a Personal Health Data Aggregation Engine becomes interesting.
The idea is simple:
Build an engine capable of collecting personal health information from multiple sources, normalizing it, resolving identities, detecting conflicts, constructing timelines, and producing a unified health data model.
But the implementation is not simple.
Health data is messy.
Different systems use different units.
Different providers use different terminology.
Different devices measure the same thing differently.
Some data arrives continuously.
Some arrives once a year.
Some data is precise.
Some data is estimated.
Some information is structured.
Some information exists inside PDFs, documents, images, or clinical notes.
And some data can be wrong.
The interesting engineering challenge is therefore not simply:
"How do I store health data?"
It is:
"How do I construct a trustworthy representation of a person's health from fragmented and heterogeneous data?"
That is a much more interesting system.
1. The Problem
Imagine someone has the following data:
Apple Health
├── Steps
├── Heart rate
├── Sleep
└── Weight
Fitness tracker
├── Workouts
├── Calories
└── Heart rate
Hospital
├── Diagnoses
├── Laboratory results
├── Procedures
└── Clinical notes
Pharmacy
├── Medication
└── Prescription history
Blood pressure device
├── Systolic
└── Diastolic
Nutrition application
├── Meals
└── Calories
Now suppose we want one timeline.
Something like:
2026-09-01
08:00 Blood pressure: 128/82
09:00 Walk: 4,200 steps
13:00 Meal recorded
18:00 Workout
23:00 Sleep begins
2026-09-02
08:00 Weight: 72.4 kg
10:30 Laboratory result
14:00 Medication recorded
This looks straightforward.
It isn't.
The engine has to answer questions such as:
- Are two measurements actually about the same person?
- Are two measurements duplicates?
- Which source should be trusted?
- Are kilograms and pounds being mixed?
- Are timestamps using different time zones?
- Is a heart-rate reading instantaneous or averaged?
- Is a medication prescription the same thing as medication consumption?
- Is a diagnosis current or historical?
- Is an abnormal laboratory value actually abnormal under the relevant reference range?
- Did two systems record the same event independently?
- How should missing information be represented?
This is where data engineering meets healthcare.
2. The Architecture
A useful high-level architecture might look like this:
┌───────────────────────┐
│ Data Sources │
├───────────────────────┤
│ Wearables │
│ Medical Records │
│ Lab Systems │
│ Pharmacy │
│ Fitness Apps │
│ Manual Input │
│ Documents │
└───────────┬───────────┘
│
▼
┌───────────────────────┐
│ Ingestion Layer │
└───────────┬───────────┘
│
▼
┌───────────────────────┐
│ Validation Layer │
└───────────┬───────────┘
│
▼
┌───────────────────────┐
│ Normalization Engine │
└───────────┬───────────┘
│
▼
┌───────────────────────┐
│ Identity Resolution │
└───────────┬───────────┘
│
▼
┌───────────────────────┐
│ Deduplication Engine │
└───────────┬───────────┘
│
▼
┌───────────────────────┐
│ Health Event Store │
└───────────┬───────────┘
│
┌──────────┴──────────┐
▼ ▼
┌─────────────────┐ ┌──────────────────┐
│ Timeline Engine │ │ Analytics Engine │
└─────────────────┘ └──────────────────┘
│ │
└──────────┬──────────┘
▼
┌───────────────────────┐
│ Personal Health View │
└───────────────────────┘
The important part is that the system should not immediately trust incoming data.
Raw data and canonical data should be separate.
That distinction becomes extremely important.
3. The Raw Data Layer
The first rule of the system should be:
Never destroy the original information.
Suppose an external device sends:
{
"value": 154,
"unit": "lb",
"timestamp": "2026-09-20T07:30:00Z"
}
We might normalize that into:
{
"value": 69.8532,
"unit": "kg"
}
But we should still preserve the original record.
Why?
Because normalization logic can change.
Our conversion could contain a bug.
A source could later clarify its semantics.
A user could dispute the transformed value.
Therefore:
RAW DATA
↓
IMMUTABLE
↓
NORMALIZATION
↓
CANONICAL DATA
The raw layer becomes an audit trail.
A database model might look like:
CREATE TABLE raw_events (
id UUID PRIMARY KEY,
source_id UUID NOT NULL,
received_at TIMESTAMP NOT NULL,
event_type VARCHAR(100),
payload JSONB NOT NULL,
checksum VARCHAR(128),
created_at TIMESTAMP NOT NULL
);
The checksum can help detect duplicate payloads.
4. The Canonical Health Model
The next challenge is creating a universal internal representation.
Instead of letting every source define our database, we create a canonical model.
For example:
{
"event_id": "evt_123",
"person_id": "person_001",
"type": "body_weight",
"occurred_at": "2026-09-20T07:30:00Z",
"value": 69.85,
"unit": "kg",
"source": "wearable",
"confidence": 0.94
}
Now different sources can converge into the same model.
For example:
lb
kg
stones
can all become:
kg
Likewise:
bpm
beats/minute
heart_rate
can converge into:
heart_rate
This gives downstream systems a stable interface.
5. Measurements Need Semantics
One of the easiest mistakes is treating all health data as simple numbers.
Consider:
120
What is it?
It could be:
120 mmHg
120 bpm
120 mg/dL
120 kg
120 steps/min
The number itself is almost meaningless without context.
Therefore, health measurements need metadata.
A useful structure is:
{
"concept": "blood_glucose",
"value": 120,
"unit": "mg/dL",
"measurement_context": "fasting",
"occurred_at": "...",
"source": "...",
"method": "device"
}
The engine should model:
WHAT
VALUE
UNIT
WHEN
WHERE
HOW
SOURCE
CONTEXT
CONFIDENCE
This is the difference between storing numbers and storing information.
6. Time Is Surprisingly Difficult
Healthcare systems are temporal systems.
And time is messy.
Imagine:
Device A:
2026-09-20 08:00 UTC
Device B:
2026-09-20 10:00 CAT
Those might represent the same moment.
We therefore normalize timestamps internally to UTC.
But we should also preserve:
original_timestamp
original_timezone
normalized_timestamp
Why?
Because local context matters.
Suppose someone traveled from Zambia to Europe.
Their sleep data suddenly appears to shift.
Without timezone information, the engine could interpret the data incorrectly.
Time should therefore be treated as first-class data.
7. Identity Resolution
Now comes one of the hardest problems.
Different systems may identify the same person differently.
One system might have:
user_id = 92831
Another:
patient_id = P-441
Another:
account_id = 7F82
The aggregation engine needs a concept of identity mapping.
Person
│
┌───────────┼───────────┐
▼ ▼ ▼
Patient User Device
P-441 92831 DEV-992
The internal system should not assume that external identifiers are globally meaningful.
Instead:
CREATE TABLE identity_links (
id UUID PRIMARY KEY,
person_id UUID NOT NULL,
source_id UUID NOT NULL,
external_identifier VARCHAR(255) NOT NULL,
verified BOOLEAN DEFAULT FALSE
);
This allows the aggregation engine to maintain its own identity graph.
8. Deduplication
Suppose a hospital exports:
Blood pressure: 120/80
09:30
And a connected device independently reports:
Blood pressure: 120/80
09:30
Are these two events?
Maybe.
Maybe not.
A naïve system might simply compare every field.
A smarter system considers:
person
measurement type
timestamp
value
unit
source
device
context
A similarity function could be:
similarity =
timestamp_similarity
+ measurement_similarity
+ value_similarity
+ source_relationship
Then:
similarity > threshold
could trigger a duplicate candidate.
But I would avoid automatically deleting records.
Instead:
RAW EVENTS
↓
DUPLICATE CANDIDATES
↓
CLUSTERING
↓
CANONICAL EVENT
The system can preserve provenance.
9. Provenance Is Everything
If the engine says:
Weight: 69.8 kg
the user should be able to ask:
Where did this come from?
The answer should be something like:
Source:
Smart Scale
Original:
154 lb
Converted:
69.8532 kg
Recorded:
07:30
Imported:
07:31
Transformation:
lb → kg
This is provenance.
Every canonical value should be traceable back to its origin.
That makes debugging possible.
It also makes the system more trustworthy.
10. Confidence Should Be Explicit
Not every piece of information deserves equal confidence.
Consider:
Manual entry
Wearable sensor
Clinical laboratory
OCR from scanned document
Imported PDF
User estimate
These have different characteristics.
We can therefore attach confidence metadata.
For example:
{
"value": 72.4,
"unit": "kg",
"confidence": {
"score": 0.91,
"reason": "device_measurement"
}
}
But this score should not pretend to be medical certainty.
It is a data-quality signal.
That distinction matters.
The engine is saying:
"How reliable is this data as an imported record?"
It is not saying:
"How medically important is this result?"
Those are different questions.
11. Handling Documents
The system becomes much more interesting when we accept documents.
A user might upload:
blood-test.pdf
hospital-report.pdf
prescription.jpg
medical-record.pdf
Now we need a document processing pipeline.
Document
↓
File Validation
↓
Text Extraction
↓
OCR
↓
Entity Extraction
↓
Medical Concept Mapping
↓
Human Review
↓
Canonical Events
For example:
"Weight: 72 kg"
could become:
{
"type": "body_weight",
"value": 72,
"unit": "kg"
}
But extraction should not silently convert uncertain text into trusted facts.
Instead, extracted information can carry:
extraction_confidence
source_location
document_id
page
text_span
That allows the user to inspect the original evidence.
12. The Event Store
At the heart of the system, I would use an event-oriented model.
Something like:
CREATE TABLE health_events (
id UUID PRIMARY KEY,
person_id UUID NOT NULL,
event_type VARCHAR(100) NOT NULL,
occurred_at TIMESTAMP NOT NULL,
recorded_at TIMESTAMP,
payload JSONB NOT NULL,
source_id UUID,
confidence NUMERIC,
created_at TIMESTAMP NOT NULL
);
Why JSONB?
Because health events are heterogeneous.
A heart-rate event looks different from:
medication
lab_result
workout
sleep_session
vaccination
diagnosis
weight
blood_pressure
However, this does not mean everything should become an unstructured JSON blob.
Important searchable properties should remain structured.
For example:
person_id
event_type
occurred_at
source_id
can remain indexed columns.
The flexible details can live in the payload.
13. The Timeline Engine
Once events are normalized, we can construct a timeline.
09:00
│
├── Heart rate
├── Steps
│
10:00
│
├── Medication
│
12:30
│
├── Meal
│
17:00
│
├── Workout
│
23:00
└── Sleep
The timeline engine becomes a powerful abstraction.
Instead of asking:
"Which application contains my data?"
the user asks:
"What happened to my health over time?"
That is a fundamentally better interface.
14. Correlation
Once data is unified, we can begin detecting relationships.
For example:
sleep
↓
activity
↓
heart rate
↓
workout
The system could calculate correlations such as:
sleep duration vs workout frequency
or:
sleep duration vs resting heart rate
But there is an important engineering rule:
Correlation is not causation.
The platform should describe statistical relationships without pretending that they establish medical causality.
For example:
"When sleep duration was lower, recorded activity was also lower."
is fundamentally different from:
"Poor sleep caused reduced activity."
The first is an observation.
The second is a causal claim.
A responsible system must know the difference.
15. The Analytics Layer
We can build a separate analytics engine on top of the canonical event store.
For example:
Daily metrics
Weekly trends
Monthly summaries
Measurement variability
Activity distributions
Sleep patterns
Medication schedules
Lab trajectories
A simple aggregation query might look like:
SELECT
DATE(occurred_at) AS day,
AVG((payload->>'value')::numeric) AS average_value
FROM health_events
WHERE event_type = 'heart_rate'
GROUP BY DATE(occurred_at)
ORDER BY day;
This gives us a basic daily view.
But the architecture can go much further.
16. Streaming Data
Wearables can generate huge numbers of events.
Imagine:
1 heart-rate event
every few seconds
The engine could eventually receive:
thousands
or millions
of events
That suggests an event-streaming architecture.
Device
↓
API Gateway
↓
Message Queue
↓
Stream Processor
↓
Normalization
↓
Event Store
Technologies such as:
Kafka
Redpanda
RabbitMQ
NATS
Redis Streams
could be used depending on requirements.
For a small personal project, however, I would not start there.
Start with:
PostgreSQL
+
background workers
+
REST API
Then introduce streaming when actual workloads justify it.
Architecture should solve real problems, not imaginary scale.
17. Conflict Resolution
Suppose we have:
Source A:
Weight = 72.0 kg
Source B:
Weight = 72.6 kg
Source C:
Weight = 72.2 kg
What should the engine display?
There is no universal answer.
The system could preserve all observations:
72.0
72.6
72.2
and then select a preferred observation based on configurable source precedence.
For example:
verified clinical measurement
↓
validated medical device
↓
consumer wearable
↓
manual entry
↓
estimated value
But precedence should be transparent.
Instead of hiding conflicts, the system could say:
3 measurements recorded within 10 minutes.
72.0 kg
72.2 kg
72.6 kg
Transparency can be more valuable than false precision.
18. Privacy Must Be Architectural
Health data is extremely sensitive.
Therefore privacy should not be added after the database is built.
It should influence the architecture from the beginning.
A strong design might include:
Encryption at rest
Encryption in transit
Strict authentication
Fine-grained authorization
Audit logs
Data minimization
Access controls
Key rotation
Secure backups
Data deletion
Export functionality
The database should not simply contain:
users
health_data
and call it security.
Access boundaries matter.
19. Encryption
Sensitive payloads can be encrypted at the application or field level where appropriate.
For example:
database
↓
encrypted health payload
Keys should not be stored alongside the encrypted data.
A simplified architecture:
Application
│
▼
Key Management System
│
▼
Encryption Layer
│
▼
Database
The database becomes a storage system rather than the sole guardian of the data.
20. Audit Logging
Every important access should potentially generate an audit event.
For example:
{
"actor": "user_123",
"action": "READ",
"resource": "health_event_789",
"timestamp": "...",
"ip": "...",
"result": "allowed"
}
For a system handling sensitive information, auditability is not just an enterprise feature.
It is part of the architecture.
21. Data Deletion Is Harder Than It Looks
Suppose a user says:
Delete my health data.
The system might have:
Primary database
Analytics database
Search index
Object storage
Cache
Backups
Logs
Derived datasets
Deleting one database row does not necessarily delete everything.
Therefore we need a data lifecycle architecture.
Created
↓
Processed
↓
Stored
↓
Derived
↓
Archived
↓
Deleted
Deletion workflows need to understand dependencies.
If an event is deleted, derived records based exclusively on that event may also need deletion or recomputation.
22. API Design
The API could expose resources like:
GET /api/v1/health/events
GET /api/v1/health/timeline
GET /api/v1/health/measurements
GET /api/v1/health/sources
POST /api/v1/health/import
DELETE /api/v1/health/events/{id}
A timeline query might look like:
GET /api/v1/health/timeline?from=2026-09-01&to=2026-09-20
Response:
{
"events": [
{
"type": "weight",
"value": 72.4,
"unit": "kg",
"occurred_at": "2026-09-20T07:30:00Z"
}
]
}
The API should expose provenance rather than hiding it.
23. Building the System Incrementally
I would not attempt to build the entire platform at once.
Version 1:
Manual data entry
+
PostgreSQL
+
REST API
+
Timeline
Version 2:
CSV imports
+
JSON imports
+
Unit normalization
Version 3:
Wearable integrations
+
device sources
Version 4:
Document ingestion
+
OCR
Version 5:
Deduplication
+
identity resolution
Version 6:
Analytics
+
trend detection
Version 7:
Event streaming
+
large-scale ingestion
This progression keeps the architecture understandable.
24. A Possible Technology Stack
For a serious implementation, I might choose:
Backend:
Python / Django / FastAPI
Database:
PostgreSQL
Cache:
Redis
Queue:
Celery / Redis
or
NATS / Kafka
Object Storage:
S3-compatible storage
Search:
OpenSearch
Analytics:
Python / Pandas / Polars
ML:
PyTorch
Frontend:
React / TypeScript
Mobile:
React Native
But the stack is not the important part.
The architecture is.
You could build the same conceptual system using:
Rust
Go
Node.js
Java
.NET
PHP
The difficult part is designing the data model correctly.
25. A Better Internal Architecture
I would separate the system into bounded components:
┌──────────────────┐
│ API Gateway │
└────────┬─────────┘
│
┌───────────────────┼───────────────────┐
▼ ▼ ▼
┌─────────────┐ ┌──────────────┐ ┌──────────────┐
│ Ingestion │ │ Identity │ │ Access │
│ Service │ │ Service │ │ Service │
└──────┬──────┘ └──────┬───────┘ └──────┬───────┘
│ │ │
└───────────────────┼───────────────────┘
▼
┌─────────────────┐
│ Health Event │
│ Store │
└────────┬────────┘
│
┌─────────────┼─────────────┐
▼ ▼ ▼
Timeline Analytics Search
This creates clear boundaries.
The ingestion service should not become the analytics service.
The analytics engine should not own authentication.
The timeline engine should not know how a wearable API works.
Separation creates flexibility.
26. The Interesting Part: Personal Health Graph
Eventually, we can move beyond a simple timeline.
We can construct a graph.
Person
│
├── Measurement
│ └── Device
│
├── Medication
│
├── Laboratory Result
│
├── Activity
│
├── Sleep Session
│
└── Clinical Encounter
Then relationships become explicit.
For example:
Medication
│
└── prescribed_during
│
▼
Clinical Encounter
Or:
Lab Result
│
└── measured_at
│
▼
Laboratory
The graph becomes a semantic layer over the event store.
27. AI Can Sit on Top of the System
This is where things get interesting.
Once the data is normalized, an AI assistant could answer questions such as:
"Show me my weight trend."
"What measurements did I record last month?"
"Summarize my recent health records."
"Find duplicate measurements."
"Show laboratory results over time."
But AI should not become the source of truth.
The architecture should look like:
Health Data
↓
Canonical Data Model
↓
Query Engine
↓
Evidence Retrieval
↓
AI
not:
AI
↓
Guess what happened
The AI should retrieve structured evidence and explain it.
Every answer should ideally be traceable to underlying records.
28. Retrieval-Augmented Health Intelligence
For documents and clinical notes, we could build a retrieval layer.
Medical documents
↓
Chunking
↓
Embeddings
↓
Vector database
↓
Semantic retrieval
↓
AI assistant
But structured measurements should remain structured.
Do not put:
weight = 72.4 kg
into a vector database and call the problem solved.
Use the right storage mechanism for the right data.
Structured facts → relational database
Documents → object storage
Semantic text → vector index
Events → event store
Hybrid architecture wins.
29. The Real Engineering Challenge
The hardest part of this system is not building a dashboard.
It is creating a trustworthy data pipeline.
The dashboard is the easy part.
The hard questions are:
Where did this data come from?
Was it transformed?
Was it duplicated?
Was the identity verified?
What unit was used?
What timezone was used?
When was it measured?
When was it imported?
What changed?
Who accessed it?
Can we reproduce the transformation?
Those questions define the quality of the system.
30. A Minimal Prototype
A surprisingly powerful prototype could be built with only:
FastAPI
PostgreSQL
Redis
React
Start with three event types:
weight
heart_rate
blood_pressure
Then implement:
POST /events
GET /events
GET /timeline
Example:
POST /events
{
"type": "weight",
"value": 72.4,
"unit": "kg",
"occurred_at": "2026-09-20T07:30:00Z"
}
The backend validates it.
Then:
raw event
↓
validation
↓
normalization
↓
canonical event
↓
database
The frontend displays:
September 20
07:30
Weight
72.4 kg
That tiny system is already the beginning of a personal health data platform.
31. What Makes the Project Advanced?
Because it combines several difficult areas of software engineering:
Distributed data ingestion
Data normalization
Event processing
Identity resolution
Deduplication
Temporal databases
Document processing
Search
Analytics
Privacy
Encryption
AI
Data provenance
It is not simply a CRUD application.
It is a data infrastructure project.
And that makes it especially interesting.
32. The Bigger Idea
The long-term vision is not another fitness dashboard.
It is a personal data infrastructure layer.
Imagine a world where a person owns a unified representation of their own health information.
Not:
App A knows this.
App B knows that.
Hospital C knows something else.
But:
PERSONAL HEALTH DATA
│
┌────────────────┼────────────────┐
▼ ▼ ▼
Wearables Providers Devices
│ │ │
└────────────────┼────────────────┘
▼
Aggregation Engine
│
┌──────────┼──────────┐
▼ ▼ ▼
Timeline Analytics Search
│ │ │
└──────────┼──────────┘
▼
Personal Interface
The user becomes the center of the architecture.
That is the interesting shift.
Conclusion
Building a Personal Health Data Aggregation Engine is fundamentally a problem of turning fragmented information into a coherent personal data model.
The challenge begins with ingestion.
Then comes normalization.
Then identity.
Then deduplication.
Then provenance.
Then timelines.
Then analytics.
Then privacy.
Then intelligence.
The deeper lesson is that health data is not simply a collection of numbers.
It is a collection of observations made by different systems, at different times, using different methods, with different levels of confidence.
A good aggregation engine respects that complexity.
It does not blindly merge everything.
It preserves the original data.
It records transformations.
It exposes provenance.
It represents uncertainty.
It separates observations from interpretations.
And it gives the person a coherent view of information that was previously scattered across dozens of systems.
That architecture can eventually become much bigger than a dashboard.
It can become a personal data operating system.
And that is the part I find most interesting about projects like this.
The future of software is not always about creating another application.
Sometimes it is about building the infrastructure that allows many applications to finally understand the same person.
The real product is not the dashboard.
The real product is the data layer underneath it.