# ashishbamania/open-scribe architecture

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

- Interactive diagram: https://gitdiagram.com/ashishbamania/open-scribe
- Repository: https://github.com/ashishbamania/open-scribe

## Overview

##### Main Components
- Frontend: The React-based user interface (located in the “open-scribe-frontend” directory) that handles audio recording (via MediaRecorder API), playback, and user interactions.
- Backend: The Node.js/Express.js server (located in the “open-scribe-backend” directory) responsible for processing audio uploads, interacting with OpenAI’s APIs (for transcription and text formatting), and handling file uploads (with Multer).
- External Services: OpenAI’s Whisper model for speech-to-text transcription and GPT-4 for formatting transcriptions into structured medical notes.
- User’s Browser/Client: The source interface where users interact with the application.

##### Relationships and Interactions
- The User’s Browser interacts with the Frontend: Users record audio, review recordings, and send a “Process Recording” request.
- The Frontend sends audio file data and any related requests to the Backend through HTTP API endpoints.
- The Backend receives these requests, uses Multer to handle audio file uploads, and then processes the file by calling external APIs:
- First, sending the audio to OpenAI Whisper for transcription.
- Next, sending the transcribed text to GPT-4 to format into organized medical notes.
- The Backend returns the processed results to the Frontend for display and possible download.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clear division between the frontend (user interface/interaction) and the backend (data processing and API calls).
- API-driven Communication: Use of HTTP endpoints for cross-component communication, ensuring loose coupling between frontend and backend.
- External Integration: Clear dependency on external AI services (OpenAI API) which are abstractly integrated into the backend’s workflow.
- Modular Design: With separate directories for frontend and backend, each component is self-contained and maintainable.

##### Technology and Framework Details
- Frontend Technologies: React.js for building components (e.g., ConsultationRecorder), CSS3 for styles, MediaRecorder API for handling audio capture.
- Backend Technologies: Node.js with Express.js to set up server routes, Multer for file uploading, and integration with OpenAI APIs (Whisper for transcription and GPT-4 for text formatting).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    Browser["User's Browser/Client"]:::browser

    %% Frontend
    subgraph "React Frontend (Port 3000)"
        ConsultationRecorder["React Frontend – Audio Recording UI"]:::frontend
        MainApp["React Frontend – Main Application"]:::frontend
        PublicAssets["Frontend Public Assets"]:::frontend
    end

    %% Backend
    subgraph "Express Backend (Port 3001)"
        Backend["Express Backend – API & File Processing<br/>(Uses Multer for File Uploads)"]:::backend
        BackendPackage["Express Backend – Package and Dependency Management"]:::backend
    end

    %% External AI Services
    subgraph "External AI Services"
        Whisper["OpenAI Whisper API"]:::external
        GPT4["OpenAI GPT-4 API"]:::external
    end

    %% Data Flow
    Browser -->|"initiates request"| ConsultationRecorder
    ConsultationRecorder -->|"sends audio data via HTTP"| Backend
    Backend -->|"for transcription"| Whisper
    Whisper -->|"transcription result"| Backend
    Backend -->|"for formatting"| GPT4
    GPT4 -->|"formatted medical notes"| Backend
    Backend -->|"returns processed data"| MainApp
    MainApp -->|"displays results"| Browser

    %% Click Events
    click ConsultationRecorder "https://github.com/ashishbamania/open-scribe/blob/main/open-scribe-frontend/src/components/ConsultationRecorder/ConsultationRecorder.js"
    click MainApp "https://github.com/ashishbamania/open-scribe/blob/main/open-scribe-frontend/src/App.js"
    click PublicAssets "https://github.com/ashishbamania/open-scribe/tree/main/open-scribe-frontend/public"
    click Backend "https://github.com/ashishbamania/open-scribe/blob/main/open-scribe-backend/server.js"
    click BackendPackage "https://github.com/ashishbamania/open-scribe/blob/main/open-scribe-backend/package.json"

    %% Styles
    classDef browser fill:#f0ad4e,stroke:#333,stroke-width:2px;
    classDef frontend fill:#5bc0de,stroke:#333,stroke-width:2px;
    classDef backend fill:#5cb85c,stroke:#333,stroke-width:2px;
    classDef external fill:#d9534f,stroke:#333,stroke-width:2px;
```
