healthspan 0.1.0.dev0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,141 @@
1
+ Metadata-Version: 2.4
2
+ Name: healthspan
3
+ Version: 0.1.0.dev0
4
+ Summary: Local-first personal health data platform with MCP server for AI-assisted longitudinal analysis
5
+ Author: Matthew Zaleski
6
+ Author-email: Matthew Zaleski <neuroticgamer01@zaleski.net>
7
+ License-Expression: MIT
8
+ Requires-Python: >=3.14
9
+ Project-URL: Repository, https://github.com/NeuroticGamer99/healthspan
10
+ Project-URL: Issues, https://github.com/NeuroticGamer99/healthspan/issues
11
+ Description-Content-Type: text/markdown
12
+
13
+ # biocontext
14
+
15
+ **Your health data, analyzed on your terms.**
16
+
17
+ biocontext is a local-first personal health data platform. It aggregates lab results, continuous glucose monitoring, body composition, wearable activity, and clinical history into a single encrypted database — then exposes that data to AI-driven analysis through an open, extensible, plugin-driven architecture.
18
+
19
+ Think of it as Home Assistant for personal health data: a stable, privacy-respecting core with a hackable plugin ecosystem where the line between built-in capability and your own extensions is intentionally blurred.
20
+
21
+ ---
22
+
23
+ ## Why this exists
24
+
25
+ Personal health data is spread across labs, patient portals, wearables, CGM apps, and clinical records — each in a different format, each siloed, none talking to the others. Making sense of it requires normalizing years of data from sources that don't agree on units, biomarker names, or reference ranges.
26
+
27
+ Beyond the data problem, there's an analysis problem. Fasting insulin from Quest and fasting insulin from a hospital lab are not the same number — different immunoassay platforms produce systematically different values. Any analytical tool that doesn't track lab source alongside every result will produce misleading trends. biocontext is built around this reality.
28
+
29
+ The goal: a single longitudinal record of your health data, queryable by AI and scriptable by you, with security and privacy treated as design requirements rather than afterthoughts.
30
+
31
+ ---
32
+
33
+ ## Who it's for
34
+
35
+ **Privacy-first users** — The database is AES-256 encrypted at rest (SQLCipher) from first run. The encrypted file is safe for cloud backup; the storage provider sees ciphertext. The MCP server supports any MCP-compatible AI client, including fully local LLMs — when you use a local model, your health data never leaves your machine.
36
+
37
+ **Technical and security-aware users** — The full REST API is exposed and documented. Every interface is versioned. The plugin system gives you the same extension points used by first-party code. You can script against the API, build your own importers, add custom analysis functions, or connect external tooling — without modifying the core.
38
+
39
+ **N=1 data analysts and biohackers** — Multi-source lab normalization with canonical biomarker names. Reference range frameworks that go beyond lab flags — compare your results against longevity-optimized targets or practitioner-specific optimal ranges alongside the standard lab ranges. Longitudinal trend analysis across years of data. CGM correlation with periodic labs. Clinical event and intervention timelines as first-class overlays on every analysis.
40
+
41
+ **Home Assistant users who want the same for health** — A micro-kernel architecture where first-party functionality ships as plugins against the same interfaces available to you. Replace, extend, or fork any component. Add import adapters for new data sources. Register new MCP tools that your AI client can call. Write automation rules that react to your health events. The installed package is a distribution mechanism, not a black box.
42
+
43
+ ---
44
+
45
+ ## Architecture
46
+
47
+ biocontext is built as a set of independent processes with well-defined, versioned interfaces:
48
+
49
+ ```
50
+ GUI (PySide6) ─┐
51
+ MCP Server (fastmcp) ─┤→ Core Service (FastAPI, REST API v1) → SQLite (SQLCipher)
52
+ Import Pipeline ─┤ ↑ auth, validation, event bus
53
+ CLI + plugins ─┘
54
+ ```
55
+
56
+ - **Core Service** — the only process that owns the database. Versioned REST API. Authentication on every endpoint. Input validation at the boundary.
57
+ - **MCP Server** — exposes named tools to any MCP-compatible AI client. AI-provider agnostic.
58
+ - **GUI** — standalone PySide6 desktop client. Replaceable: it's just another API client.
59
+ - **CLI (command-line interface)** — first-class scripting layer with a directory-scanning plugin system. Drop a `.py` file into the plugins directory; new commands appear.
60
+ - **Event bus** — SSE-based by default. ZeroMQ and MQTT available as adapter plugins for more complex deployments.
61
+
62
+ Full architectural documentation is in [`specs/`](specs/), including 20+ Architecture Decision Records covering every major design choice.
63
+
64
+ ---
65
+
66
+ ## Data sources
67
+
68
+ The platform is designed around these data types, with importers planned or in progress:
69
+
70
+ | Data type | Sources | Status |
71
+ |---|---|---|
72
+ | Lab results | Quest (via primary care and Function Health), patient portals | Partially designed |
73
+ | Body composition | InBody 120, InBody 580 (via Enara Health) | Partially designed |
74
+ | Continuous glucose | Levels (CSV export), Dexcom API | Partially designed |
75
+ | Metabolic context | Levels (zone scores, glucose response) | Not yet designed |
76
+ | Activity logs | Levels (food, exercise, notes) | Not yet designed |
77
+ | Nutrition logs | Levels (detailed macros/micros) | Not yet designed |
78
+ | Wearable / activity | Fitbit (Takeout), Apple Health XML | Partially designed |
79
+ | Clinical events | Manual entry | Table defined |
80
+ | Interventions | Manual entry (with full dose history tracking) | Table defined |
81
+ | Clinical documents | Manual entry; future: patient portal export, PDF import | Not yet designed |
82
+
83
+ All data enters through a structured import pipeline: full-batch validation before any write, atomic transactions (all-or-nothing per import), dry-run mode, and explicit conflict policies (reject, skip, or upsert) — no silent data mutation.
84
+
85
+ Multi-source lab handling is a first-class design concern: every result row carries its lab source, reference ranges are stored per-row rather than per-biomarker, and canonical biomarker names normalize naming inconsistencies across labs.
86
+
87
+ Clinical documents and visit notes are a prioritized data type — clinician narrative captures reasoning, differential diagnoses, and interpretation context that structured lab values cannot express. MCP tools can surface relevant visit notes alongside lab trends, enabling an AI client to answer questions like "what did my cardiologist say about my LDL trajectory?" or "summarize all provider guidance on my insulin resistance."
88
+
89
+ ---
90
+
91
+ ## Plugin system
92
+
93
+ The plugin architecture is designed for the same kind of extensibility that made Home Assistant the dominant home automation platform.
94
+
95
+ - Drop a `.py` file or Python package into the plugins directory — no build step required. Plugins that need pip packages (pandas, numpy, etc.) declare them and the loader installs from a curated, version-locked catalog automatically.
96
+ - Plugins can register: CLI commands, MCP tools, import adapters, analysis functions, query patterns, reference range frameworks, automation rules, notification channels
97
+ - Plugins can provide services to other plugins via a namespaced service registry (`quest.parser`, `quest.api_client`, etc.)
98
+ - Built-in functionality ships as first-party plugins against the same interfaces — there is no privileged internal API
99
+ - Plugin API versioning with compatibility range declarations (`PLUGIN_API_MIN_VERSION`, `PLUGIN_API_MAX_VERSION`)
100
+
101
+ ---
102
+
103
+ ## Security model
104
+
105
+ - **Encryption at rest** — SQLCipher AES-256. Two-factor key model: a randomly generated secret key (stored in the OS keychain) combined with a user master passphrase, derived via Argon2id. A printable Recovery Kit enables cross-device recovery. Passphrase-only mode available for headless or cross-device use cases.
106
+ - **Local-first** — no cloud service required. All data stays on your machine by default.
107
+ - **AI client agnostic** — works with any MCP-compatible AI client. Use a local LLM and your health data never leaves the machine.
108
+ - **Authenticated API** — bearer token on every endpoint. Host header validation and CORS allowlist protect against DNS rebinding attacks even on localhost.
109
+ - **Plugins are trusted-user code** — they run with your privileges and are not sandboxed. Only install plugins you have read and trust.
110
+
111
+ See [`specs/security.md`](specs/security.md) for the full security requirements and threat model.
112
+
113
+ ---
114
+
115
+ ## Project status
116
+
117
+ **Early development — design phase in-progress, implementation not yet started.**
118
+
119
+ The full architecture is currently documented across 20+ ADRs covering application architecture, plugin system, event bus, job abstraction, encryption, data model, and more. Work continues on the basic architecture specifications. No installable release exists yet.
120
+
121
+ If you want to follow along or contribute, the [`specs/`](specs/) directory is the place to start. [`specs/design-rationale.md`](specs/design-rationale.md) covers the core design philosophy. [`specs/open-questions.md`](specs/open-questions.md) lists known items that need to be decided.
122
+
123
+ ---
124
+
125
+ ## Important notes
126
+
127
+ ### Not medical advice
128
+
129
+ This is a personal data organization and analysis tool. It is not a medical device or clinical decision support system. Nothing this software produces — including AI-assisted analysis — constitutes medical advice. Consult a qualified healthcare provider before making health decisions.
130
+
131
+ ### Lab data has inherent limitations
132
+
133
+ Laboratory results are not directly comparable across different platforms and assay methods. The platform tracks lab source alongside every result for this reason, and the documentation covers cross-lab variability in detail. Even so, no software can account for all sources of analytical variability. Do not treat trend analysis as clinically definitive.
134
+
135
+ ### AI analysis has limitations
136
+
137
+ AI-generated analysis can be incorrect, incomplete, or misinterpreted. When using a cloud-based AI client, your health data leaves your machine during analysis — review the privacy policy of your chosen AI client. When using a local LLM, no data leaves your machine.
138
+
139
+ ### No warranty
140
+
141
+ This software is provided as-is. See [NOTICE](NOTICE) and [LICENSE](LICENSE) for full terms.
@@ -0,0 +1,129 @@
1
+ # biocontext
2
+
3
+ **Your health data, analyzed on your terms.**
4
+
5
+ biocontext is a local-first personal health data platform. It aggregates lab results, continuous glucose monitoring, body composition, wearable activity, and clinical history into a single encrypted database — then exposes that data to AI-driven analysis through an open, extensible, plugin-driven architecture.
6
+
7
+ Think of it as Home Assistant for personal health data: a stable, privacy-respecting core with a hackable plugin ecosystem where the line between built-in capability and your own extensions is intentionally blurred.
8
+
9
+ ---
10
+
11
+ ## Why this exists
12
+
13
+ Personal health data is spread across labs, patient portals, wearables, CGM apps, and clinical records — each in a different format, each siloed, none talking to the others. Making sense of it requires normalizing years of data from sources that don't agree on units, biomarker names, or reference ranges.
14
+
15
+ Beyond the data problem, there's an analysis problem. Fasting insulin from Quest and fasting insulin from a hospital lab are not the same number — different immunoassay platforms produce systematically different values. Any analytical tool that doesn't track lab source alongside every result will produce misleading trends. biocontext is built around this reality.
16
+
17
+ The goal: a single longitudinal record of your health data, queryable by AI and scriptable by you, with security and privacy treated as design requirements rather than afterthoughts.
18
+
19
+ ---
20
+
21
+ ## Who it's for
22
+
23
+ **Privacy-first users** — The database is AES-256 encrypted at rest (SQLCipher) from first run. The encrypted file is safe for cloud backup; the storage provider sees ciphertext. The MCP server supports any MCP-compatible AI client, including fully local LLMs — when you use a local model, your health data never leaves your machine.
24
+
25
+ **Technical and security-aware users** — The full REST API is exposed and documented. Every interface is versioned. The plugin system gives you the same extension points used by first-party code. You can script against the API, build your own importers, add custom analysis functions, or connect external tooling — without modifying the core.
26
+
27
+ **N=1 data analysts and biohackers** — Multi-source lab normalization with canonical biomarker names. Reference range frameworks that go beyond lab flags — compare your results against longevity-optimized targets or practitioner-specific optimal ranges alongside the standard lab ranges. Longitudinal trend analysis across years of data. CGM correlation with periodic labs. Clinical event and intervention timelines as first-class overlays on every analysis.
28
+
29
+ **Home Assistant users who want the same for health** — A micro-kernel architecture where first-party functionality ships as plugins against the same interfaces available to you. Replace, extend, or fork any component. Add import adapters for new data sources. Register new MCP tools that your AI client can call. Write automation rules that react to your health events. The installed package is a distribution mechanism, not a black box.
30
+
31
+ ---
32
+
33
+ ## Architecture
34
+
35
+ biocontext is built as a set of independent processes with well-defined, versioned interfaces:
36
+
37
+ ```
38
+ GUI (PySide6) ─┐
39
+ MCP Server (fastmcp) ─┤→ Core Service (FastAPI, REST API v1) → SQLite (SQLCipher)
40
+ Import Pipeline ─┤ ↑ auth, validation, event bus
41
+ CLI + plugins ─┘
42
+ ```
43
+
44
+ - **Core Service** — the only process that owns the database. Versioned REST API. Authentication on every endpoint. Input validation at the boundary.
45
+ - **MCP Server** — exposes named tools to any MCP-compatible AI client. AI-provider agnostic.
46
+ - **GUI** — standalone PySide6 desktop client. Replaceable: it's just another API client.
47
+ - **CLI (command-line interface)** — first-class scripting layer with a directory-scanning plugin system. Drop a `.py` file into the plugins directory; new commands appear.
48
+ - **Event bus** — SSE-based by default. ZeroMQ and MQTT available as adapter plugins for more complex deployments.
49
+
50
+ Full architectural documentation is in [`specs/`](specs/), including 20+ Architecture Decision Records covering every major design choice.
51
+
52
+ ---
53
+
54
+ ## Data sources
55
+
56
+ The platform is designed around these data types, with importers planned or in progress:
57
+
58
+ | Data type | Sources | Status |
59
+ |---|---|---|
60
+ | Lab results | Quest (via primary care and Function Health), patient portals | Partially designed |
61
+ | Body composition | InBody 120, InBody 580 (via Enara Health) | Partially designed |
62
+ | Continuous glucose | Levels (CSV export), Dexcom API | Partially designed |
63
+ | Metabolic context | Levels (zone scores, glucose response) | Not yet designed |
64
+ | Activity logs | Levels (food, exercise, notes) | Not yet designed |
65
+ | Nutrition logs | Levels (detailed macros/micros) | Not yet designed |
66
+ | Wearable / activity | Fitbit (Takeout), Apple Health XML | Partially designed |
67
+ | Clinical events | Manual entry | Table defined |
68
+ | Interventions | Manual entry (with full dose history tracking) | Table defined |
69
+ | Clinical documents | Manual entry; future: patient portal export, PDF import | Not yet designed |
70
+
71
+ All data enters through a structured import pipeline: full-batch validation before any write, atomic transactions (all-or-nothing per import), dry-run mode, and explicit conflict policies (reject, skip, or upsert) — no silent data mutation.
72
+
73
+ Multi-source lab handling is a first-class design concern: every result row carries its lab source, reference ranges are stored per-row rather than per-biomarker, and canonical biomarker names normalize naming inconsistencies across labs.
74
+
75
+ Clinical documents and visit notes are a prioritized data type — clinician narrative captures reasoning, differential diagnoses, and interpretation context that structured lab values cannot express. MCP tools can surface relevant visit notes alongside lab trends, enabling an AI client to answer questions like "what did my cardiologist say about my LDL trajectory?" or "summarize all provider guidance on my insulin resistance."
76
+
77
+ ---
78
+
79
+ ## Plugin system
80
+
81
+ The plugin architecture is designed for the same kind of extensibility that made Home Assistant the dominant home automation platform.
82
+
83
+ - Drop a `.py` file or Python package into the plugins directory — no build step required. Plugins that need pip packages (pandas, numpy, etc.) declare them and the loader installs from a curated, version-locked catalog automatically.
84
+ - Plugins can register: CLI commands, MCP tools, import adapters, analysis functions, query patterns, reference range frameworks, automation rules, notification channels
85
+ - Plugins can provide services to other plugins via a namespaced service registry (`quest.parser`, `quest.api_client`, etc.)
86
+ - Built-in functionality ships as first-party plugins against the same interfaces — there is no privileged internal API
87
+ - Plugin API versioning with compatibility range declarations (`PLUGIN_API_MIN_VERSION`, `PLUGIN_API_MAX_VERSION`)
88
+
89
+ ---
90
+
91
+ ## Security model
92
+
93
+ - **Encryption at rest** — SQLCipher AES-256. Two-factor key model: a randomly generated secret key (stored in the OS keychain) combined with a user master passphrase, derived via Argon2id. A printable Recovery Kit enables cross-device recovery. Passphrase-only mode available for headless or cross-device use cases.
94
+ - **Local-first** — no cloud service required. All data stays on your machine by default.
95
+ - **AI client agnostic** — works with any MCP-compatible AI client. Use a local LLM and your health data never leaves the machine.
96
+ - **Authenticated API** — bearer token on every endpoint. Host header validation and CORS allowlist protect against DNS rebinding attacks even on localhost.
97
+ - **Plugins are trusted-user code** — they run with your privileges and are not sandboxed. Only install plugins you have read and trust.
98
+
99
+ See [`specs/security.md`](specs/security.md) for the full security requirements and threat model.
100
+
101
+ ---
102
+
103
+ ## Project status
104
+
105
+ **Early development — design phase in-progress, implementation not yet started.**
106
+
107
+ The full architecture is currently documented across 20+ ADRs covering application architecture, plugin system, event bus, job abstraction, encryption, data model, and more. Work continues on the basic architecture specifications. No installable release exists yet.
108
+
109
+ If you want to follow along or contribute, the [`specs/`](specs/) directory is the place to start. [`specs/design-rationale.md`](specs/design-rationale.md) covers the core design philosophy. [`specs/open-questions.md`](specs/open-questions.md) lists known items that need to be decided.
110
+
111
+ ---
112
+
113
+ ## Important notes
114
+
115
+ ### Not medical advice
116
+
117
+ This is a personal data organization and analysis tool. It is not a medical device or clinical decision support system. Nothing this software produces — including AI-assisted analysis — constitutes medical advice. Consult a qualified healthcare provider before making health decisions.
118
+
119
+ ### Lab data has inherent limitations
120
+
121
+ Laboratory results are not directly comparable across different platforms and assay methods. The platform tracks lab source alongside every result for this reason, and the documentation covers cross-lab variability in detail. Even so, no software can account for all sources of analytical variability. Do not treat trend analysis as clinically definitive.
122
+
123
+ ### AI analysis has limitations
124
+
125
+ AI-generated analysis can be incorrect, incomplete, or misinterpreted. When using a cloud-based AI client, your health data leaves your machine during analysis — review the privacy policy of your chosen AI client. When using a local LLM, no data leaves your machine.
126
+
127
+ ### No warranty
128
+
129
+ This software is provided as-is. See [NOTICE](NOTICE) and [LICENSE](LICENSE) for full terms.
@@ -0,0 +1,22 @@
1
+ [project]
2
+ name = "healthspan"
3
+ version = "0.1.0.dev0"
4
+ description = "Local-first personal health data platform with MCP server for AI-assisted longitudinal analysis"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Matthew Zaleski", email = "neuroticgamer01@zaleski.net" }
8
+ ]
9
+ requires-python = ">=3.14"
10
+ license = "MIT"
11
+ dependencies = []
12
+
13
+ [project.urls]
14
+ Repository = "https://github.com/NeuroticGamer99/healthspan"
15
+ Issues = "https://github.com/NeuroticGamer99/healthspan/issues"
16
+
17
+ [project.scripts]
18
+ healthspan = "healthspan:main"
19
+
20
+ [build-system]
21
+ requires = ["uv_build>=0.11.2,<0.12.0"]
22
+ build-backend = "uv_build"
@@ -0,0 +1,2 @@
1
+ def main() -> None:
2
+ print("Hello from healthspan!")