# piyush-eon/doctors-appointment-platform architecture

> Architecture diagram of the GitHub repository piyush-eon/doctors-appointment-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/piyush-eon/doctors-appointment-platform
- Repository: https://github.com/piyush-eon/doctors-appointment-platform

## Overview

##### Project Type and Purpose
- This is a full-stack doctors-appointment platform built with Next.js (App Router), Tailwind CSS, Shadcn UI, Prisma ORM, and Neon (PostgreSQL). It includes server-side actions (the “actions” folder) for business logic (appointments, credits, payouts, onboarding, etc.) and integrates Vonage for video calls.

##### File Structure
- Top-level folders:
- app/ – Next.js App Router pages and layouts, divided into (auth) and (main) routes
- actions/ – Server actions handling CRUD and business operations
- components/ & components/ui/ – Reusable UI primitives (Shadcn UI wrappers)
- lib/ – Utilities, Prisma client setup (lib/prisma.js), schema, auth helpers
- prisma/ – Database schema and migration history
- hooks/ – Custom React hooks (e.g., use-fetch)
- public/ – Static assets
- Configs: next.config.mjs, postcss.config.mjs, eslint.config.mjs, jsconfig.json
- Middleware: middleware.js handles auth redirects or guarding routes.

##### README and Dependencies
- Confirms the stack: Next.js, Neon (Postgres), Tailwind, Shadcn UI, Vonage for video calls

##### Main Components
a. Client Browser
- Renders React components, calls server via Server Actions or fetch hooks
b. Next.js Server
- App Router (app/…) reacts to route requests, serves Server Components & SSR pages
- API Endpoints / Server Actions (actions/*.js) for login, signup, appointments, credits, payouts, doctor onboarding
- Middleware for auth gating
c. Database (Neon/PostgreSQL)
- Managed via Prisma ORM (prisma/schema.prisma & lib/prisma.js)
d. External Services
- Vonage Video API for telehealth sessions
- (Optional) Payment provider if used for credits/payouts
e. File-based UI Library
- Shadcn UI primitives under components/ui

##### Relationships and Interactions
- Browser → Next.js App Router
- Auth pages under /app/(auth)
- Main app under /app/(main) with sub-routes (admin, doctor, doctors, onboarding, pricing, video-call)
- Next.js Server → Database
- All actions/*.js modules import Prisma client to read/write appointments, users, credits, payouts
- Next.js Server → Vonage
- Video-call route invokes Vonage SDK via server action to generate tokens, sessions
- UI Components ← App Router
- Page.jsx files compose components from components/ and components/ui/

##### Important Architectural Patterns
- Next.js App Router with nested layouts (e.g., app/(main)/layout.jsx)
- Server Actions for form submissions and data mutations (instead of traditional REST)
- Prisma ORM for type-safe DB access
- Component-driven UI with Shadcn primitives
- Middleware for route protection

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layers
    Browser["Browser<br/>(React Components & UI)"]:::frontend
    subgraph "Next.js Server" 
        direction TB
        AppRouter["App Router<br/>app/"]:::backend
        AuthRoutes["Authentication Routes<br/>app/(auth)/"]:::backend
        MainRoutes["Main Application Routes<br/>app/(main)/"]:::backend
        Middleware["Middleware<br/>middleware.js"]:::backend
        ServerActions["Server Actions<br/>actions/"]:::backend
    end
    PrismaClient["Prisma Client<br/>lib/prisma.js"]:::database
    DB["Neon (PostgreSQL)<br/>prisma/schema.prisma"]:::database
    Vonage["Vonage Video API"]:::external

    %% Interactions
    Browser -->|HTTP Request| AppRouter
    AppRouter -->|Route to Sign-In/Sign-Up| AuthRoutes
    AppRouter -->|Route to Main App| MainRoutes
    AppRouter -->|Auth Guard| Middleware
    AppRouter -->|Invoke Business Logic| ServerActions
    ServerActions -->|DB Query| PrismaClient
    PrismaClient -->|Connect| DB
    ServerActions -->|Token Request| Vonage

    %% Click Events
    click AppRouter "https://github.com/piyush-eon/doctors-appointment-platform/tree/main/app/"
    click AuthRoutes "https://github.com/piyush-eon/doctors-appointment-platform/tree/main/app/(auth)/"
    click MainRoutes "https://github.com/piyush-eon/doctors-appointment-platform/tree/main/app/(main)/"
    click ServerActions "https://github.com/piyush-eon/doctors-appointment-platform/tree/main/actions/"
    click Middleware "https://github.com/piyush-eon/doctors-appointment-platform/blob/main/middleware.js"
    click PrismaClient "https://github.com/piyush-eon/doctors-appointment-platform/blob/main/lib/prisma.js"
    click DB "https://github.com/piyush-eon/doctors-appointment-platform/blob/main/prisma/schema.prisma"

    %% Styling
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
    classDef backend fill:#d4edda,stroke:#155724,color:#155724
    classDef database fill:#fff3cd,stroke:#856404,color:#856404
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d
```
