Monorepo Architecture
Relevant source files
The following files were used as context for generating this wiki page:
- pnpm-workspace.yaml
- replit.md
- attached_assets/Pasted-Make-a-focused-repo-cleanup-and-dependency-hygiene-pass_1774842983742.txt
- attached_assets/Pasted-Build-the-next-major-intelligence-architecture-for-Hosp_1774852812580.txt
- attached_assets/Pasted-Refactor-the-hospice-guidance-content-into-a-structured_1774841115565.txt
- attached_assets/Pasted-Make-a-focused-security-pass-on-the-Ragna-conversation-_1774838250254.txt
The Hospice Roadmap project is structured as a pnpm workspace monorepo designed for iterative development and high dependency hygiene. It consolidates a cross-platform mobile application, an intelligence-driven API server, and shared library packages into a single repository to ensure type safety and consistent domain logic across the stack.
The architecture emphasizes a clear separation between "artifacts" (shipping products like the mobile app and API) and "lib" packages (reusable logic for database schemas, API specifications, and generated clients). This structure supports a complex hospice intelligence engine that integrates real-time patient context with clinical knowledge bases.
Sources: replit.md:1-10, attached_assets/Pasted-Make-a-focused-repo-cleanup-and-dependency-hygiene-pass_1774842983742.txt:Section A
Workspace Structure
The repository is organized into distinct functional areas defined in the root configuration.
Directory Layout
| Path | Workspace Name | Purpose |
|---|---|---|
artifacts/mobile | @workspace/mobile | Expo React Native application for iOS. |
artifacts/api-server | @workspace/api-server | Express 5 API server with Hospice Intelligence Engine. |
artifacts/mockup-sandbox | @workspace/mockup-sandbox | Prototype tooling and design environment (non-shipping). |
lib/db | @workspace/db | Drizzle ORM schemas and PostgreSQL client. |
lib/api-spec | @workspace/api-spec | OpenAPI 3.1 specifications and Orval configurations. |
lib/api-client-react | @workspace/api-client-react | Generated React Query hooks and fetch clients. |
scripts | @workspace/scripts | Utility scripts for monorepo maintenance. |
Sources: replit.md:21-50, attached_assets/Pasted-Make-a-focused-repo-cleanup-and-dependency-hygiene-pass_1774842983742.txt:Section E
Core Architecture Flow
The following diagram illustrates the relationship between the shared libraries and the primary shipping artifacts.
The system uses Orval to generate the React Query hooks in lib/api-client-react from the OpenAPI 3.1 spec located in lib/api-spec.
Sources: replit.md:25-55, attached_assets/Pasted-Make-a-focused-repo-cleanup-and-dependency-hygiene-pass_1774842983742.txt:Section F
Shipping Artifacts
API Server (@workspace/api-server)
The API server acts as the central intelligence hub. It manages connections to the PostgreSQL database via Drizzle ORM and interfaces with the Anthropic Claude API for the Ragna AI companion. A key feature is the Hospice Intelligence Engine, a layered system located in src/intelligence/hospice/ that processes user requests through a deterministic retrieval and planning phase before interacting with the LLM.
Sources: replit.md:33-40, attached_assets/Pasted-Build-the-next-major-intelligence-architecture-for-Hosp_1774852812580.txt:Section J
Mobile Application (@workspace/mobile)
Built with Expo and TypeScript, the mobile application provides structured guidance, symptom tracking, and the Ragna AI interface. It utilizes AsyncStorage for local persistence of sensitive data like the "Patient Profile" and "Goals of Care," ensuring functionality in offline scenarios.
Sources: replit.md:42-65, attached_assets/Pasted-Make-a-truth-alignment-pass-across-the-current-React-Na_1774837201847.txt:Section B
Shared Data and Intelligence
Hospice Intelligence Architecture
The monorepo implements a "Layered Intelligence Engine" rather than simple prompting. This engine is composed of several specialized modules:
| Component | File Path (artifacts/api-server/src/intelligence/hospice/) | Function |
|---|---|---|
| Planner | planner.ts | Outputs a ResponsePlan including mustSay and mustAvoid constraints. |
| Catalog | catalog.ts | Structured knowledge blocks covering 13 domains (e.g., dying process, care gaps). |
| Models | diseaseModel.ts, symptomModel.ts | Mapping of specific conditions (Cancer, Dementia) to symptoms. |
| Coach | documentationCoach.ts | Scripts and guidance for advocacy and documentation. |
Sources: attached_assets/Pasted-Build-the-next-major-intelligence-architecture-for-Hosp_1774852812580.txt:Sections B, J, attached_assets/Pasted-Refactor-the-hospice-guidance-content-into-a-structured_1774841115565.txt:Section A
Security and Identity Scoping
The monorepo enforces device-level scoping for AI conversations without requiring a full account login. A persistent clientId is generated on the mobile device and sent via the x_client_id header to the API server.
Repository Maintenance
The root package.json contains workspace-wide scripts to maintain the monorepo's health and ensure dependency hygiene.
repo:mobile:typecheck: Runs type checking for the mobile package.repo:api:typecheck: Runs type checking for the API server.repo:db:push: Synchronizes the Drizzle schema with the database.repo:clean:artifacts: Removes build artifacts, caches, and coverage reports across all packages.
Summary
The Monorepo Architecture of Hospice Roadmap provides a robust foundation for a healthcare navigation platform. By leveraging pnpm workspaces and shared TypeScript libraries, the project maintains high clinical and technical standards, ensuring that intelligence logic remains consistent while allowing the mobile client to provide a premium, offline-capable user experience.