# 777natalie/groupg_cs4273capstone architecture

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

- Interactive diagram: https://gitdiagram.com/777natalie/groupg_cs4273capstone
- Repository: https://github.com/777natalie/groupg_cs4273capstone

## Overview

##### Project Type and Purpose
- Type: Full-stack web application (React frontend + FastAPI backend).
- Purpose: Receive EMS call transcripts, apply rule-based grading against an EMS protocol CSV, and display results for quality assurance and training.

##### File Structure
- Top-level directories:
- frontend/ – React + Vite UI
- backend/  – Python FastAPI API and grading logic
- Call_Files/ – raw audio (.wav) files (for testing)
- backend/data/ – protocol CSV and prebuilt index JSONs
- backend/schema/ – pydantic models
- Key files:
- frontend/src/api.js – HTTP helper
- EMS_CallAnalyzer.py – core rule-based grading
- api.py – FastAPI app exposing /analyze endpoint
- EMS-Calltaking-QA.csv – reference protocol questions

##### README Insights
- Workflow: Upload transcript → POST to /analyze → analyzer compares against CSV → returns asked/missed/coverage → frontend renders results.
- Future: AI grading layer, secure on-premise deployment (not yet in scope).

##### Main Components & Their Relationships
a. User Interface (Browser)
- React app pages (Upload, Results, History, Dispatchers).
b. Frontend Client
- Vite dev server (localhost:3000)
- Components call api.js → HTTP POST to backend.
c. API Layer (FastAPI)
- /analyze endpoint
- Receives transcript text or parsed lines.
d. Grading Engine
- EMS_CallAnalyzer.py + TranscriptExtractQ.py
- Loads EMS-Calltaking-QA.csv
- Compares token overlap, applies rules.
e. Data Storage
- CSV file (protocols) in backend/data
- Optional JSON index files in backend/data/db_indexing
- Transcripts stored temporarily or in memory
f. Response Models
- schema/models.py defines Pydantic schemas for result payload
g. (Future) AI Module
- Plug-in point for AI-based grading

##### Architectural Patterns & Principles
- Layered architecture: Presentation → API → Business Logic → Data.
- Single-responsibility: separate analyzer logic from HTTP handling.
- File-based “database”: simple CSV + JSON stores, no external RDBMS.
- Modular frontend: page-based routing, reusable components.

##### Technologies & Frameworks
- Frontend: React, Vite, JavaScript/JSX, CSS modules
- Backend: Python 3.9+, FastAPI, Pydantic, Uvicorn
- Data: CSV protocols, JSON vector/index stores
- (Planned) AI: future integration with NLP/LLM

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    BROWSER["Browser UI"]:::ui

    %% Frontend Layer
    subgraph "Frontend Layer"
        FE_APP["React SPA"]:::frontend
        API_HELPER["api.js"]:::frontend
        PAGES["Pages & Components"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        API["FastAPI Server (/analyze)"]:::server
        subgraph "Grading Engine"
            ANALYZER["EMS_CallAnalyzer.py"]:::logic
            TRANSCRIPT["TranscriptExtractQ.py"]:::logic
        end
        RESP_MODELS["Pydantic Schemas"]:::data
    end

    %% Data Storage
    subgraph "Data Storage"
        CSV["EMS-Calltaking-QA.csv"]:::data
        JSON_INDEX["JSON Index Stores"]:::data
        CALL_FILES["Call Files Repo (.wav)"]:::data
    end

    %% Future Module
    AI["AI Grading Module (Future)"]:::future

    %% Connections
    BROWSER -->|"User actions"| FE_APP
    FE_APP -->|"imports"| API_HELPER
    FE_APP -->|"HTTP POST JSON"| API
    API -->|"invokes"| ANALYZER
    API -->|"invokes"| TRANSCRIPT
    ANALYZER -->|"read CSV"| CSV
    ANALYZER -->|"read JSON"| JSON_INDEX
    TRANSCRIPT -->|"uses CSV rules"| CSV
    API -->|"validates| JSON"| RESP_MODELS
    API -->|"response JSON"| FE_APP
    API -->|"invoke"| AI

    %% Click Events
    click BROWSER "https://github.com/777natalie/groupg_cs4273capstone/blob/main/CallAnalysisTool/frontend/index.html"
    click FE_APP "https://github.com/777natalie/groupg_cs4273capstone/tree/main/CallAnalysisTool/frontend/src/"
    click API_HELPER "https://github.com/777natalie/groupg_cs4273capstone/blob/main/CallAnalysisTool/frontend/src/api.js"
    click PAGES "https://github.com/777natalie/groupg_cs4273capstone/tree/main/CallAnalysisTool/frontend/src/pages/"
    click API "https://github.com/777natalie/groupg_cs4273capstone/blob/main/CallAnalysisTool/backend/api.py"
    click ANALYZER "https://github.com/777natalie/groupg_cs4273capstone/blob/main/CallAnalysisTool/backend/EMS_CallAnalyzer.py"
    click TRANSCRIPT "https://github.com/777natalie/groupg_cs4273capstone/blob/main/CallAnalysisTool/backend/TranscriptExtractQ.py"
    click RESP_MODELS "https://github.com/777natalie/groupg_cs4273capstone/blob/main/CallAnalysisTool/backend/schema/models.py"
    click CSV "https://github.com/777natalie/groupg_cs4273capstone/blob/main/CallAnalysisTool/backend/data/EMS-Calltaking-QA.csv"
    click JSON_INDEX "https://github.com/777natalie/groupg_cs4273capstone/tree/main/CallAnalysisTool/backend/data/db_indexing/"
    click CALL_FILES "https://github.com/777natalie/groupg_cs4273capstone/tree/main/CallAnalysisTool/Call_Files/"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#22577E,color:#000
    classDef frontend fill:#B3E5FC,stroke:#1565C0,color:#000
    classDef server fill:#C8E6C9,stroke:#2E7D32,color:#000
    classDef logic fill:#FFE0B2,stroke:#EF6C00,color:#000
    classDef data fill:#FFF9C4,stroke:#F9A825,color:#000
    classDef future fill:#E1BEE7,stroke:#8E24AA,color:#000
```
