$ show afairgiant/MediKeep
MediKeep is a full-stack personal health record (PHR) application built with FastAPI (Python) and React (Mantine UI). It allows users to manage comprehensive medical data including medications, conditions, allergies, immunizations, lab results, vitals, procedures, treatments, symptoms, injuries, encounters, family history, insurance, pharmacies, and practitioners. The system supports multi-user with patient sharing via invitations, SSO authentication (Google, GitHub, OIDC), custom PDF report generation with trend charts, document management integrations (Paperless-ngx, Papra), backup/restore, and internationalization (13 languages). The architecture follows a modular pattern with CRUD base classes, a service layer, domain events, and extensive testing (pytest, Vitest). Deployment is via Docker Compose with PostgreSQL. The codebase demonstrates strong engineering practices with clean abstractions, reusable components, and comprehensive test coverage, though some areas show signs of ongoing migration (JS to TS, adapter components) and debug artifacts remain.
The LLM identified 5 files worth highlighting for reuse:
Implements an asynchronous event bus with publish/subscribe pattern, allowing decoupled communication between components. Supports error isolation per subscriber, singleton registry, and typed event classes. Can be extracted as a standalone library for any Python async application.
Resolves the real client IP address from request headers, respecting trusted proxy IPs and configurable trust levels. Handles X-Forwarded-For, X-Real-IP, and Forwarded headers with proper validation. Self-contained utility that can be reused in any FastAPI/Starlette application for rate-limiting, audit logging, or geo-location.
Provides a secure outbound HTTP session with URL pinning (prevents SSRF by resolving hostnames and pinning IPs), custom DNS resolver, and hop-by-hop header stripping. Designed for integrations with external services (Paperless, Papra) where security is critical. Can be extracted as a standalone aiohttp middleware or session factory.
A comprehensive error handling system for React applications, consisting of error boundary components, configurable severity/domain mappings, regex-based error parsers, and a queue for batched notifications. Includes pre-built mappings for auth, network, validation, and sharing errors. Can be extracted as a library for any React project needing structured error management.
Validates that a redirect URL is safe (same-origin or allowed path) to prevent open redirect vulnerabilities. Handles protocol-relative URLs, encoded characters, and path traversal attempts. Simple, self-contained utility that can be reused in any TypeScript/JavaScript project.