# codewavewithasante/fullstack-healthcare architecture

> Architecture diagram of the GitHub repository codewavewithasante/fullstack-healthcare, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codewavewithasante/fullstack-healthcare
- Repository: https://github.com/codewavewithasante/fullstack-healthcare

## Overview

##### Project Type and Purpose
- Type: Full-stack Next.js web application.
- Purpose: It involves multiple user roles (e.g., admin, doctor, patient) with authentication (sign-up/sign-in) and protected functionalities. The system handles clinical records, appointments, billing, medical history, and various administrative tasks supported by a robust UI and data layer.
- Key Technologies: Next.js (app router with file-based routing), Prisma for database migrations/ORM, Tailwind CSS for styling, and various UI components.

##### Analyzing the File Structure
- Frontend Routes:
- The “app” directory contains route segments, notably the (auth) group for authentication pages and the (protected) group for role-based dashboard functionality.
- Nested routes in (protected) indicate multiple functionalities (admin system settings, doctor and patient dashboards, appointment records, billing, etc.)
- “app/layout.tsx” and page components at various levels indicate usage of Next.js’s new routing conventions.

- Backend & Services:
- The “lib” directory holds key modules like the database connection (db.ts) and route definitions, suggesting utilities that tie into backend logic.
- “utils/services” contains service modules for handling distinct areas (admin, appointment, doctor, billing, etc.) ensuring separation of concerns.
- “prisma” is used for managing database schema and migrations.
- “middleware.ts” indicates that there is request-level logic (authentication, authorization, etc.) at work.

- UI Components:
- The “components” directory is well-organized into smaller parts for dialogs, forms, charts, tables, navigation, and more. This suggests a component-based, modular UI architecture that feeds into the overall presentation layer.

- Browser Client.
- Next.js Application Server (split into sections: App Router, Middleware, and API/Service Logic).
- Database (Prisma ORM).
- Utility and Services layer.
- UI Component grouping (e.g., charts, forms, dialogs).
- Data flow from Browser to Next.js server.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Browser Client"]:::browser
    B["Frontend Routes (app/)"]:::nextjs
    C["Authentication Module (app/(auth))"]:::nextjs
    D["Protected Routes (app/(protected))"]:::nextjs
    E["Layout Components (app/layout.tsx & app/(protected)/layout.tsx)"]:::nextjs
    G["Middleware (middleware.ts)"]:::middleware
    F["API/Server Actions (app/actions)"]:::api
    H1["Utility Layer (lib)"]:::utility
    H2["Service Layer (utils/services)"]:::utility
    J1["Prisma ORM (prisma)"]:::database
    J2["DB Connector (lib/db.ts)"]:::database
    I["UI Components (components/)"]:::ui

    %% Flows
    A --> B
    B --> C
    B --> D
    C --> E
    D --> E
    E --> G
    E --> I
    G --> F
    F --> H1
    F --> H2
    F --> I
    H1 --> J1
    H2 --> J2
    I --> A

    %% Click Events
    click B "https://github.com/codewavewithasante/fullstack-healthcare/tree/main/app/"
    click C "https://github.com/codewavewithasante/fullstack-healthcare/tree/main/app/(auth)"
    click D "https://github.com/codewavewithasante/fullstack-healthcare/tree/main/app/(protected)"
    click E "https://github.com/codewavewithasante/fullstack-healthcare/blob/main/app/layout.tsx"
    click E "https://github.com/codewavewithasante/fullstack-healthcare/blob/main/app/(protected)/layout.tsx"
    click F "https://github.com/codewavewithasante/fullstack-healthcare/tree/main/app/actions"
    click G "https://github.com/codewavewithasante/fullstack-healthcare/blob/main/middleware.ts"
    click H1 "https://github.com/codewavewithasante/fullstack-healthcare/tree/main/lib/"
    click H2 "https://github.com/codewavewithasante/fullstack-healthcare/tree/main/utils/services/"
    click J1 "https://github.com/codewavewithasante/fullstack-healthcare/tree/main/prisma/"
    click J2 "https://github.com/codewavewithasante/fullstack-healthcare/blob/main/lib/db.ts"
    click I "https://github.com/codewavewithasante/fullstack-healthcare/tree/main/components/"

    %% Styles
    classDef browser fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef nextjs fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef middleware fill:#ffcc99,stroke:#000,stroke-width:2px;
    classDef api fill:#d3d3d3,stroke:#000,stroke-width:2px;
    classDef utility fill:#ffb6c1,stroke:#000,stroke-width:2px;
    classDef database fill:#f5f5f5,stroke:#000,stroke-width:2px;
    classDef ui fill:#dda0dd,stroke:#000,stroke-width:2px;
```
