# himanshukaswa7/carepulse architecture

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

- Interactive diagram: https://gitdiagram.com/himanshukaswa7/carepulse
- Repository: https://github.com/himanshukaswa7/carepulse

## Overview

##### Project Type and Purpose
- CarePulse is a full-stack healthcare management web application.
- Frontend: Next.js (app directory) with React/TypeScript, Tailwind CSS, ShadCN UI.
- Backend: Appwrite (BaaS) for authentication, database, functions.
- Integrations: Twilio for SMS notifications, Sentry for monitoring.

##### Main Components
a. Frontend Application
- Next.js app folder (app/layout.tsx, pages, React components in components/)
- UI library (ShadCN UI under components/ui)
- Data-entry components (forms, modals, tables)
b. Backend Services (Appwrite)
- Authentication (users/patients)
- Database service (collections for Patients, Appointments)
- Functions (if any custom serverless functions)
c. API Routes
- Next.js Route Handler at app/api/sentry-example-api/route.ts
- Any wrapper around Appwrite SDK calls (lib/actions/*.ts)
d. External Services
- Twilio (via lib/actions/appointment.action.ts)
- Sentry (client/server/edge config files)
e. Hosting / CDN
- Vercel (deployment)
- Public assets folder (public/assets/…)

##### Relationships & Data Flows
- User ↔ Frontend: Browses pages, submits registration or appointment forms.
- Frontend → Appwrite SDK (lib/actions):
- Patient registration → Appwrite Auth & Database collection “patients”.
- Appointment booking → Appwrite Database collection “appointments”.
- Backend → Twilio API: On appointment creation, send SMS.
- Frontend & API Routes → Sentry: Error logging & performance monitoring.

##### Architectural Patterns & Design Principles
- Server-Side Rendering & API Routes (Next.js 13 app directory).
- Component-driven UI (ShadCN + Tailwind).
- Service-oriented backend via Appwrite (BaaS).
- Separation of concerns: UI components vs. SDK actions vs. configuration.
- Externalization of configurations (appwrite.config.ts, .env.local).

- Entities:
1. Patient
- patient_id (PK)
- name, email, phone, created_at
2. Appointment
- appointment_id (PK)
- patient_id (FK → Patient.patient_id)
- datetime, status (confirmed/pending/canceled), created_at
- Relationships:
- One-to-Many: Patient → Appointment
- Attributes & Keys: Clearly label PK (underline) and FK.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Database ER Diagram for CarePulse
    subgraph "Appwrite Database Collections"
        direction TB
        Patient["Patient\nPK: patient_id\nname\nemail\nphone\ncreated_at"]:::entity
        Appointment["Appointment\nPK: appointment_id\nFK: patient_id\ndatetime\nstatus\ncreated_at"]:::entity
    end

    Patient -->|"1 to many"| Appointment

    classDef entity fill:#ffeb99,stroke:#333,stroke-width:2px,font-family:Arial;
```
