How arafat-yasin-2413/health-sync works
1. Application shape
HealthSync is a Next.js App Router application built as a multi-portal healthcare front end. The top-level routes are split into Home, Admin, Doctor, and Patient views, with the patient flow appearing to be the primary product path.
2. Primary user journey
The main flow is: user lands on the home page, chooses a portal card, enters the patient area, uploads a medical document, and gets structured clinical data extracted from that document. The architecture is optimized around this document-to-data conversion workflow.
3. Route and page boundaries
Route entry points live under src/app/:
- / for the main landing page
- /admin
- /doctor
- /patient
This indicates a route-level separation of concerns rather than a single monolithic screen with conditional rendering.
4. AI extraction boundary
The AI integration is isolated in src/app/actions/ai.ts, which strongly suggests a server action boundary between UI and model invocation. That boundary is important: client components handle upload and interaction, while the server action handles AI processing and likely keeps the Gemini interaction out of the browser-facing component tree.
5. Document processing flow
The repository includes utilities for file-to-base64 conversion and file size formatting, which implies uploaded PDFs/images are converted into a transport-friendly format before extraction. This points to a document ingestion pipeline centered on binary file handling rather than database records.
6. Client-side state and persistence
src/utils/storageEngine.ts and the README’s emphasis on localStorage indicate that the app uses browser persistence to retain patient sessions, timelines, and extracted results across refreshes. There does not appear to be a backend database or API layer in this repo; the system is primarily client-state-driven with AI computation as the main external service.
7. UI composition
The UI is built from reusable component layers:
- src/components/home for portal selection cards
- src/components/nav for shared navigation
- src/components/patientPortal for patient-specific UI such as headers and loading skeletons
- src/components/shared for common branding like the logo
- src/components/ui for a Shadcn-style design system
This makes the app modular by screen and by primitive.
8. Visual and layout shell
src/app/layout.tsx, src/app/globals.css, and the Tailwind/Shadcn setup define a global layout shell with consistent styling and responsive constraints. The README calls out a unified max-width layout, so the diagram should show a single shared presentation layer wrapping all portals.
9. Data model layer
src/types/medical.ts likely defines the structured output schema for extracted clinical data such as doctor names, vitals, summaries, and medicine arrays. This type layer is the contract between AI output, storage, and UI rendering.
10. Mock/demo support
src/utils/mockData.ts suggests the app can render with sample clinical data, likely to support demo states or fallback behavior when no document has been processed yet. This is useful to show in the architecture as a non-production data source alongside real AI extraction.
11. External dependency
The only clear external service is Google Gemini via @google/genai, with the README explicitly mentioning multimodal models like gemini-1.5-flash and gemini-2.5-flash. In the architecture, Gemini is the core external intelligence layer that transforms uploaded documents into structured medical records.
12. Overall system boundary
In diagram terms, this repo is a front-end-first system: browser UI, local persistence, and server actions for AI calls, with no visible custom backend, auth service, or database layer in the tree. The main system boundary is between the Next.js client/server app and the Gemini API.
Main entry points: page.tsx Patient · layout.tsx App shell · ai.ts AI action · PortalNav.tsx Portal nav
Components 17
App Router
Route entry points and shared shell
- App shell · Global layout and styling wrapper for all portals
src/app/layout.tsx - Home · Landing page that routes users into portal flows
src/app/page.tsx - Admin · Admin portal entry screen
src/app/admin/page.tsx - Doctor · Doctor portal entry screen
src/app/doctor/page.tsx - Patient · Primary patient workflow for document upload and extraction
src/app/patient/page.tsx - AI action · Server-side boundary that invokes model extraction
src/app/actions/ai.ts
UI Components
Reusable screen and design-system components
- Portal cards · Home screen cards for choosing Admin, Doctor, or Patient portals
src/components/home - Portal nav · Shared navigation across portal views
src/components/nav/PortalNav.tsx - Patient UI · Patient-specific header and loading states
src/components/patientPortal - Logo · Shared branding used across the app shell and nav
src/components/shared/Logo.tsx - UI kit · Reusable shadcn-style primitives for forms, dialogs, cards, and tabs
src/components/ui
Data Layer
Local state, types, and document helpers
- Storage engine · Browser persistence for sessions, timelines, and extracted results
src/utils/storageEngine.ts - Mock data · Sample clinical records for fallback or demo states
src/utils/mockData.ts - File utils · Base64 conversion and file-size formatting for uploads
src/utils/convertFileToBase64.ts - Medical types · Structured output contract for extracted clinical data
src/types/medical.ts - App utils · Common utility helpers used across components
src/lib/utils.ts
External Service
AI model boundary
- Gemini API · External multimodal model used for document-to-data extraction
Connections 23
- App shell → Home: wraps · Provides the shared layout and styling shell
- App shell → Admin: wraps · Provides the shared layout and styling shell
- App shell → Doctor: wraps · Provides the shared layout and styling shell
- App shell → Patient: wraps · Provides the shared layout and styling shell
- Home → Portal cards: renders · Home page is composed of portal selection cards
- Home → Logo: brands · Landing page uses shared branding
- Admin → Portal nav: uses · Portal page shares navigation chrome
- Doctor → Portal nav: uses · Portal page shares navigation chrome
- Patient → Portal nav: uses · Patient portal shares navigation chrome
- Patient → Patient UI: composes · Patient route is built from portal-specific UI pieces
- Patient UI → UI kit: builds on · Patient UI uses reusable primitives
- Portal cards → UI kit: builds on · Portal cards use common UI primitives
- Portal nav → Logo: includes · Navigation includes shared branding
- Patient → File utils: prepares uploads · Patient flow converts and formats uploaded files
- Patient → Storage engine: persists · Patient flow stores state and extracted results in the browser
- Patient → Mock data: falls back to · Demo or empty states can be populated from sample records
- Patient → Medical types: structures · UI consumes the extracted medical record contract
- AI action → Gemini API: calls · Server action invokes the external AI model
- AI action → Medical types: returns · Model output is shaped into the medical data schema
- Patient → AI action: submits to · Upload workflow triggers server-side extraction
- File utils → AI action: feeds · Prepared file payload is passed into the extraction boundary
- Storage engine → Medical types: stores · Persisted records follow the structured medical schema
- App utils → UI kit: supports · Shared helpers assist UI primitive composition