# architjen/murmur_api architecture

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

- Interactive diagram: https://gitdiagram.com/architjen/murmur_api
- Repository: https://github.com/architjen/murmur_api

## Overview

##### Project Type and Purpose
- This is a full-stack backend API service centered on Automatic Speech Recognition (ASR). The purpose is to expose audio transcription functionality via a FastAPI web service, incorporating a faster-whisper model for audio processing.
- The README clearly outlines that the system focuses on transcribing audio files and providing performance metrics, with support for both local and containerized (Docker/Kubernetes) deployment. It also integrates a Postgres database for persistence.

##### Analyzing the File Structure
- The top-level structure includes:
- “app” directory that encapsulates the main application – API endpoints (app/api), database interaction (app/db), models (app/models), and schemas (app/schemas).
- “tests” folder for unit tests.
- Kubernetes manifests in the “manifests” directory.
- Deployment support files like Dockerfile, docker-compose.yml, CI workflows in .github, etc.
- This indicates a layered architecture separating the API layer, business/domain logic (models), data access layer (db), and schema definitions used for request/response validation.

##### Identifying Main Components
a. API Layer (FastAPI):
- Located in "app/api" with endpoints for transcription, metrics, and data retrieval.
- Interacts with the user (clients via HTTP) and drives the processing by calling underlying services.
b. Transcription Service:
- Incorporates the “faster-whisper” model (indicated in the README and possibly organized in “app/models/whisper_model.py”) to process and convert audio into text.
c. Database Component (Postgres):
- The “app/db” directory contains scripts (SQL table creation) and code for CRUD operations. The inclusion of “manifests” for db-deployment also confirms persistence is managed via a Postgres container.
d. Schemas & Models:
- Found in “app/schemas” and “app/models”, these define the structure of data both for internal purposes and API responses/requests.
e. External/Deployment Components:
- Docker: Dockerfile and docker-compose.yml illustrate containerization.
- Kubernetes Deployment: “manifests/” providing deployment/service configuration.
- CI/CD: GitHub workflows and tests indicate code quality and integration practices.
f. Dependency Management & Testing:
- Use of uv for dependency management and unit tests in “tests”.

##### Relationships and Interactions
- Client(s) send HTTP requests (e.g., to /transcribe or /metrics endpoints) to the FastAPI service.
- The FastAPI layer routes these requests to relevant modules (such as calling the transcription functionality in the whisper model or executing CRUD operations via the db component).
- The transcription logic processes the audio, potentially triggers database inserts/updates.
- Metrics are gathered and returned via dedicated endpoints.
- Containers (Docker) and orchestration (Kubernetes) wrap the application and database for production deployments.

##### Architectural Patterns and Design Principles
- Layered architecture: Clear separation (API routes, business models, database access) signifying separation of concerns.
- Containerization: Use of Docker and Kubernetes deployment manifests indicates microservice-like deployment and ease of scalability.
- API Documentation and Testing: FastAPI’s auto-generated docs and defined tests demonstrate an emphasis on maintainability and reliability.
- CI/CD: GitHub workflows and pre-commit checks through Ruff assure code quality through automation.

##### Relevant Technologies and Frameworks
- FastAPI for the API layer.
- Faster-Whisper for transcription.
- Postgres as the persistent database.
- Docker and docker-compose for containerized development.
- Kubernetes (via minikube and kompose) for deployment.
- uv for dependency and environment management.
- Ruff for code formatting and linting.
- Pytest for testing.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Interaction Layer
    subgraph "Client Interaction"
        Client("Client (Browser/CLI)"):::client
    end

    %% API Layer
    subgraph "API Layer"
        API("FastAPI Service"):::api
        Endpoints("Endpoints: '/transcribe','/metrics','/data'"):::api
        API --> Endpoints
    end

    %% Business Logic
    subgraph "Business Logic"
        Transcription("Transcription Service (Faster-Whisper)"):::service
        Schemas("Schemas & Models"):::schema
        DBModel("DB Model"):::schema
        TransSchema("Transcription Schema"):::schema
        Schemas --> DBModel
        Schemas --> TransSchema
    end

    %% Data Access Layer
    subgraph "Data Access"
        CRUD("DB CRUD Operations"):::dbop
        DB("Postgres Database"):::database
        DBTable("DB Table Script"):::database
        CRUD --> DB
        CRUD --> DBTable
    end

    %% Deployment Layer
    subgraph "Deployment"
        DockerContainer("Docker Container"):::docker
        Kubernetes("Kubernetes Cluster"):::k8s
    end

    %% Supporting Components
    subgraph "Supporting"
        CICD("CI/CD Pipeline & Code Quality"):::ci
        Tests("Unit Testing"):::test
        DepFiles("Dependency Files (uv.lock)"):::test
        DepConfig("Dependency Config (pyproject.toml)"):::test
    end

    %% Connections
    Client -->|"HTTP_Request"| API
    API -->|"Calls"| Transcription
    API -->|"Uses"| Schemas
    API -->|"Triggers"| CRUD
    DockerContainer -->|"Encapsulates"| API
    DockerContainer -->|"Encapsulates"| DB
    Kubernetes -->|"Manages"| DockerContainer
    CICD -->|"Validates"| API
    CICD -->|"Validates"| DB
    Tests -->|"Tests"| API

    %% Styles
    classDef client fill:#FFC0CB,stroke:#333,stroke-width:2px;
    classDef api fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef service fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef schema fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef dbop fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef database fill:#FF6347,stroke:#333,stroke-width:2px;
    classDef docker fill:#F4A460,stroke:#333,stroke-width:2px;
    classDef k8s fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef ci fill:#EEE8AA,stroke:#333,stroke-width:2px;
    classDef test fill:#D3D3D3,stroke:#333,stroke-width:2px;

    %% Click Events
    click API "https://github.com/architjen/murmur_api/blob/main/app/api/routes.py"
    click Endpoints "https://github.com/architjen/murmur_api/blob/main/app/api/metrics.py"
    click Transcription "https://github.com/architjen/murmur_api/blob/main/app/models/whisper_model.py"
    click CRUD "https://github.com/architjen/murmur_api/blob/main/app/db/crud.py"
    click DB "https://github.com/architjen/murmur_api/blob/main/app/db/database.py"
    click DBTable "https://github.com/architjen/murmur_api/blob/main/app/db/create_table.sql"
    click Schemas "https://github.com/architjen/murmur_api/blob/main/app/schemas/db_schema.py"
    click TransSchema "https://github.com/architjen/murmur_api/blob/main/app/schemas/transcription.py"
    click DBModel "https://github.com/architjen/murmur_api/blob/main/app/models/db_model.py"
    click DockerContainer "https://github.com/architjen/murmur_api/tree/main/Dockerfile"
    click Kubernetes "https://github.com/architjen/murmur_api/tree/main/manifests/"
    click CICD "https://github.com/architjen/murmur_api/tree/main/.github/"
    click Tests "https://github.com/architjen/murmur_api/tree/main/tests/"
    click DepFiles "https://github.com/architjen/murmur_api/blob/main/uv.lock"
    click DepConfig "https://github.com/architjen/murmur_api/blob/main/pyproject.toml"
```
