How chxb07/mediflow-ai works
1. Overall shape
- This is a single-page React application built with Vite + TypeScript, styled with Tailwind CSS and a large shadcn/ui component set.
- Architecturally, it is a client UI that delegates persistence, identity, storage, and role enforcement to Supabase, with AI-assisted workflows routed through a separate Groq integration.
2. Primary user-facing entry points
- src/pages/Landing.tsx, Auth.tsx, Index.tsx, Dashboard.tsx, and NotFound.tsx form the top-level route targets.
- The app likely starts at a public landing experience, then moves into authentication, then into a role-aware dashboard area.
3. Role-based dashboard subsystem
- src/pages/dashboards/DoctorDashboard.tsx, LabDashboard.tsx, PatientDashboard.tsx, and PharmacistDashboard.tsx split the app by clinical role.
- This is the core domain boundary: each dashboard represents a distinct workflow surface over shared backend data, rather than a generic one-size-fits-all UI.
4. Shared UI and composition layer
- src/components/ contains the app-specific building blocks: Header, LanguageSwitcher, GlassCard, NavLink, and mode-toggle.
- src/components/ui/ is the reusable design system layer, largely made up of shadcn-style primitives such as dialogs, forms, tables, sidebars, menus, toasts, and inputs.
- This separation suggests a clean distinction between domain-specific shell components and low-level UI primitives.
5. State, responsiveness, and feedback
- src/hooks/use-mobile.tsx handles viewport-aware behavior, while src/hooks/use-toast.ts plus the toast/toaster components provide app-wide notifications.
- These are cross-cutting UI services used across pages and dashboards rather than business-specific logic.
6. Platform services and integration layer
- src/lib/supabase.ts is the database/auth/storage gateway.
- src/lib/auth.ts likely centralizes session and role checks.
- src/lib/ai-service.ts is the AI boundary, encapsulating calls to Groq-hosted Llama 3.3 for clinical analysis/summarization.
- src/lib/i18n.ts provides multilingual support, and src/lib/utils.ts holds shared helpers.
7. Backend/data model boundary
- supabase_schema.sql and supabase_setup.sql indicate that a meaningful portion of the system’s behavior lives in the database layer: schema, access control, triggers, and storage policies.
- The README notes Supabase Auth, Row Level Security, and automatic profile creation via triggers, which means authorization is enforced both in the UI and at the data layer.
8. Main data flow
- A user authenticates through Supabase.
- Their profile/role determines which dashboard is rendered.
- Dashboards read and write clinical data through Supabase-backed APIs/tables.
- Where needed, the doctor-facing flow calls ai-service.ts to generate analysis from clinical context.
- Lab/pharmacy actions feed status updates back into Supabase so other roles see updated records.
9. Storage and document workflow
- The README references a public Supabase storage bucket named medical-results.
- That implies a document/report pipeline for lab or radiology outputs, with metadata and access rules managed in Supabase and file artifacts stored separately from relational records.
10. Internationalization and theming
- The presence of LanguageSwitcher, theme-provider, and mode-toggle shows the UI is designed for language switching and dark/light theme control as first-class concerns.
- These are client-side presentation concerns layered on top of the clinical workflows, not part of the domain backend.
11. Testing and quality gates
- vitest.config.ts, src/test/*, and playwright.config.ts / playwright-fixture.ts show both unit/integration testing and browser-level end-to-end testing.
- This is important architecturally because the app combines auth, role routing, and dashboard flows that need coverage across both component and full-browser layers.
12. Deployment/runtime boundary
- vercel.json indicates a frontend deployment target on Vercel, while index.html, vite.config.ts, and main.tsx define a standard Vite SPA runtime.
- The repo does not show a custom backend server; instead, the runtime model is a static/frontend app consuming external managed services.
13. What to draw in an architecture diagram
- Show a client SPA in the center with three main internal zones: routing/pages, shared UI/system components, and service adapters.
- Connect it outward to Supabase for auth/database/storage and to Groq for AI inference.
- Add a separate database/schema/RLS boundary beneath Supabase, and a testing/deployment boundary around the app for Vitest, Playwright, and Vercel.
Main entry points: App.tsx App shell · supabase.ts Supabase client · Dashboard.tsx Dashboard · DoctorDashboard.tsx Doctor
Components 22
Client SPA
Vite React frontend with routed pages, shared UI, and cross-cutting client services.
- App shell · Top-level React application wiring routing, providers, and global composition.
src/App.tsx - Main entry · Bootstraps the SPA into the DOM.
src/main.tsx - Landing · Public marketing or introduction screen.
src/pages/Landing.tsx - Auth · Authentication screen and sign-in flow.
src/pages/Auth.tsx - Index · Primary route target and redirect/entry page.
src/pages/Index.tsx - Dashboard · Role-aware dashboard entry that selects the appropriate clinical surface.
src/pages/Dashboard.tsx - Doctor · Physician workflow surface for review, analysis, and decision support.
src/pages/dashboards/DoctorDashboard.tsx - Lab · Laboratory workflow surface for results handling and status updates.
src/pages/dashboards/LabDashboard.tsx - Patient · Patient-facing workflow surface for viewing records and results.
src/pages/dashboards/PatientDashboard.tsx - Pharmacist · Pharmacy workflow surface for medication and fulfillment tasks.
src/pages/dashboards/PharmacistDashboard.tsx - UI shell · App-specific layout and navigation components such as header, links, language, and theme controls.
src/components/Header.tsx - UI primitives · Reusable shadcn-style interface primitives used across the app.
src/components/ui/button.tsx - Mobile & toast · Viewport responsiveness and global notification plumbing.
src/hooks/use-mobile.tsx
Platform Services
Adapters for identity, persistence, AI, i18n, and shared helpers.
- Supabase client · Client gateway for auth, database, and storage access.
src/lib/supabase.ts - Auth logic · Session handling and role checks for the clinical dashboards.
src/lib/auth.ts - AI service · Encapsulates AI-assisted clinical analysis and summarization calls.
src/lib/ai-service.ts - I18n · Language and translation support for the client UI.
src/lib/i18n.ts
Supabase Boundary
Database schema, auth rules, storage, and setup scripts that back the app.
Quality & Deploy
Testing and deployment/runtime configuration around the SPA.
- Vitest · Fast automated tests for application logic and components.
vitest.config.ts - Playwright · End-to-end browser test harness for routed and role-based flows.
playwright.config.ts - Vercel · Frontend deployment target and runtime hosting configuration.
vercel.json
Connections 25
- Main entry → App shell: boots · Bootstraps the React application shell.
- App shell → Landing: routes · Public entry route.
- App shell → Auth: routes · Authentication route.
- App shell → Index: routes · Primary index route.
- App shell → Dashboard: routes · Role-aware dashboard gate.
- Dashboard → Doctor: selects · Doctor workflow surface.
- Dashboard → Lab: selects · Lab workflow surface.
- Dashboard → Patient: selects · Patient workflow surface.
- Dashboard → Pharmacist: selects · Pharmacist workflow surface.
- App shell → UI shell: composes · Shared chrome and navigation.
- UI shell → UI primitives: uses · Builds on reusable UI primitives.
- App shell → Mobile & toast: uses · Shared responsiveness and notifications.
- App shell → Supabase client: reads/writes · Client data and session access.
- Auth logic → Supabase client: uses · Session and role checks rely on Supabase auth state.
- Doctor → AI service: calls · Doctor-facing AI assistance and summarization.
- Doctor → Auth logic: guards · Role-based access and session checks.
- Lab → Supabase client: updates · Writes clinical status and result data.
- Patient → Supabase client: reads · Fetches patient records and results.
- Pharmacist → Supabase client: updates · Maintains fulfillment and medication state.
- App shell → I18n: localizes · Language-aware client presentation.
- Supabase client → Schema: backed by · Relational model and stored clinical data.
- Supabase client → Setup: configured by · Provisioning, policies, and triggers.
- Vitest → App shell: covers · Unit and integration coverage for the SPA.
- Playwright → App shell: covers · Browser-level routing and role flows.
- Vercel → App shell: hosts · Frontend runtime and deployment target.