# josephrmartinez/soapnotescribe architecture

> Architecture diagram of the GitHub repository josephrmartinez/soapnotescribe, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/josephrmartinez/soapnotescribe
- Repository: https://github.com/josephrmartinez/soapnotescribe

## Overview

##### Main Components

A. Client-Side (Frontend)
- Next.js Application Layer
- Audio Recording/Upload Components
- Management Interface
- Patient Management Interface
- Authentication UI
- Real-time Processing Status Display

B. Server-Side Components
- API Routes (Next.js/Vercel Serverless Functions)
- Authentication Service (Supabase)
- Storage Service (Supabase)
- Vector Database (Supabase)

C. External Services
- Replicate (AI Processing)
- OpenAI Integration
- PDF Generation Service

**[Client Tier]**
- ↕
**[Application Tier]**
- ↕
**[Data & External Services Tier]**

##### Component Relationships to Highlight

a. User Flow Path:
- Auth UI → Dashboard → Audio Upload → Processing → Note Generation → Review/Edit

b. Data Flow Path:
- Audio Upload → Storage → AI Processing → Vector DB → Note Generation

##### Specific Implementation Details

- /dashboard/* components
- /auth/* components
- /api/* endpoints
- /components/* shared components

##### Key Architectural Elements

a. Frontend Layer:
- Next.js pages router structure
- Dashboard layout with sidenav
- Audio processing components
- Form handling for notes and patients

b. Backend Layer:
- API routes for webhook handling
- Supabase integration points
- Serverless function architecture

c. Data Storage Layer:
- Supabase tables for patients, notes, and templates
- File storage for audio files
- Vector storage for AI processing results

##### Integration Points

- Authentication flow with Supabase
- Audio file processing pipeline
- AI model integration points
- PDF generation service

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        direction TB
        UI["UI Components"]:::frontend
        Auth["Authentication UI"]:::frontend
        Dashboard["Dashboard Interface"]:::frontend
        AudioComp["Audio Components"]:::frontend
        NoteUI["Note Management UI"]:::frontend
        PatientUI["Patient Management UI"]:::frontend
        TemplateUI["Template Management UI"]:::frontend
        StatusUI["Processing Status UI"]:::frontend
    end

    subgraph Server["Application Layer"]
        direction TB
        APIRoutes["API Routes"]:::backend
        AuthMiddle["Auth Middleware"]:::backend
        PDFGen["PDF Generation"]:::backend
        RTUpdates["Real-time Updates"]:::backend
    end

    subgraph Services["Services Layer"]
        direction TB
        SupaAuth["Supabase Auth"]:::database
        SupaStore["Supabase Storage"]:::database
        SupaVec["Vector Database"]:::database
        AIProc["AI Processing Pipeline"]:::ai
        Replicate["Replicate Service"]:::ai
        OpenAI["OpenAI Service"]:::ai
    end

    UI --> Auth
    Auth --> SupaAuth
    Dashboard --> APIRoutes
    AudioComp --> SupaStore
    NoteUI --> APIRoutes
    PatientUI --> APIRoutes
    TemplateUI --> APIRoutes
    StatusUI --> RTUpdates

    APIRoutes --> SupaStore
    APIRoutes --> SupaVec
    APIRoutes --> AIProc
    AuthMiddle --> SupaAuth
    
    AIProc --> Replicate
    AIProc --> OpenAI
    
    RTUpdates --> SupaStore

    %% Click Events
    click AudioComp "https://github.com/josephrmartinez/soapnotescribe/blob/main/app/components/AudioRecorder.tsx"
    click Auth "https://github.com/josephrmartinez/soapnotescribe/tree/main/app/auth/"
    click Dashboard "https://github.com/josephrmartinez/soapnotescribe/tree/main/app/dashboard/(overview)/"
    click NoteUI "https://github.com/josephrmartinez/soapnotescribe/tree/main/app/dashboard/notes/"
    click PatientUI "https://github.com/josephrmartinez/soapnotescribe/tree/main/app/dashboard/patients/"
    click TemplateUI "https://github.com/josephrmartinez/soapnotescribe/tree/main/app/dashboard/templates/"
    click AIProc "https://github.com/josephrmartinez/soapnotescribe/tree/main/app/api/replicate-webhook/"
    click PDFGen "https://github.com/josephrmartinez/soapnotescribe/blob/main/utils/generatePdf.ts"
    click StatusUI "https://github.com/josephrmartinez/soapnotescribe/tree/main/app/dashboard/notes/[id]/processing/"
    click RTUpdates "https://github.com/josephrmartinez/soapnotescribe/blob/main/app/dashboard/notes/realtimetable.tsx"
    click UI "https://github.com/josephrmartinez/soapnotescribe/tree/main/app/ui/"

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#e67e22,stroke:#d35400,color:white
    classDef ai fill:#9b59b6,stroke:#8e44ad,color:white

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Service"]:::backend
        Database["Database/Storage"]:::database
        AI["AI Service"]:::ai
    end
```
