# tuandung222/convert-phowhisper-asr-from-encdec-to-ctc architecture

> Architecture diagram of the GitHub repository tuandung222/convert-phowhisper-asr-from-encdec-to-ctc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc
- Repository: https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc

## Overview

##### Project type and purpose
- This is a full-stack, containerized ML application for Vietnamese Automatic Speech Recognition.
- The system comprises:
- A FastAPI backend serving a CTC-based PhoWhisper model for inference
- Interactive UIs (Streamlit and Gradio) for end users
- Observability stack (Prometheus, Grafana, Jaeger)
- Deployment automation via Docker Compose, Kubernetes (DigitalOcean), and Terraform
- CI/CD pipelines using GitHub Actions and Jenkins

##### File structure
- Top-level directories:
- api/         – FastAPI server, model loading, metrics and tracing clients
- ui/          – Streamlit and legacy UI code, static assets
- src/         – Core inference & training code (models, trainer, utilities, Gradio demo)
- configs/     – YAML configurations for training, model parameters, inference
- docker/      – Docker Compose overlays for API, UI, monitoring, full stack
- k8s/         – Kubernetes manifests and setup scripts (base, ingress, monitoring)
- terraform/   – IaC for DigitalOcean Kubernetes cluster and resources
- monitoring/  – Stand-alone Prometheus, Grafana, Alertmanager configs
- jenkins/     – Jenkinsfile, Dockerfile for Jenkins master, deployment scripts
- tests/       – Integration and unit tests for API, UI, model scripts
- notebooks/   – Jupyter notebooks for experimentation and refactoring

##### README insights
- User → UI → API → Model inference pipeline
- API pushes metrics to Prometheus and traces to Jaeger
- Grafana visualizes Prometheus metrics
- Deployment options: Docker Compose vs. Kubernetes (provisioned by Terraform)
- CI/CD flow: GitHub → Jenkins → Build & Deploy to Docker Compose or K8s

##### Detail
- Don’t omit the training code under src/training or notebook experiments; show them as optional developer workflows
- CI/CD pipeline steps: code → build → push → deploy
- Infrastructure provisioning: Terraform → DOKS → kubeconfig → kubectl apply
- How API metrics & traces flow into the monitoring stack

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    User["Client Browser"]:::frontend

    %% Presentation Layer
    subgraph "UI Layer"
        style UI fill:none,stroke:none
        Streamlit["Streamlit UI"]:::frontend
        Gradio["Gradio Demo"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        API["FastAPI Server"]:::app
    end

    %% Model Tier
    subgraph "Inference Tier"
        Model["PhoWhisper CTC Model"]:::app
    end

    %% Developer Workflow
    subgraph "Developer Workflow"
        Training["Training Module"]:::app
        Utils["Utility Library"]:::app
        Notebooks["Notebooks"]:::app
    end

    %% Configuration
    Configs["Configuration Files"]:::config

    %% Observability
    subgraph "Monitoring & Observability"
        Prometheus["Prometheus"]:::infra
        Grafana["Grafana"]:::infra
        Jaeger["Jaeger"]:::infra
    end

    %% Deployment Options
    subgraph "Deployment Options"
        DockerCompose["Docker Compose (Local)"]:::infra
        Kubernetes["Kubernetes Cluster (DigitalOcean)"]:::cloud
    end

    %% Infrastructure as Code
    Terraform["Terraform IaC"]:::config

    %% CI/CD
    subgraph "CI/CD Pipeline"
        GHActions["GitHub Actions"]:::ci
        Jenkins["Jenkins Server"]:::ci
    end

    %% Cloud Provider
    DO["DigitalOcean"]:::cloud

    %% Relationships
    User -->|"upload audio"| Streamlit
    User -->|"upload audio"| Gradio
    Streamlit -->|"POST /transcribe"| API
    Gradio -->|"POST /transcribe"| API
    API -->|"load & infer"| Model
    API -->|"push metrics"| Prometheus
    API -->|"send traces"| Jaeger
    Prometheus -->|"scrape metrics"| Grafana
    GHActions -->|"trigger build"| Jenkins
    Jenkins -->|"build & push images"| DockerCompose
    Jenkins -->|"build & push images"| Kubernetes
    Terraform -->|"provision cluster"| DO
    DO -->|"kubeconfig"| Kubernetes
    Kubernetes -->|"apply manifests"| API
    Kubernetes -->|"apply manifests"| Streamlit
    Kubernetes -->|"apply manifests"| Gradio
    Kubernetes -->|"apply manifests"| Prometheus
    Kubernetes -->|"apply manifests"| Grafana
    Kubernetes -->|"apply manifests"| Jaeger
    Configs -->|"used by"| API
    Configs -->|"used by"| Model
    Configs -->|"used by"| Training
    Utils -->|"helpers for"| API
    Utils -->|"helpers for"| Model
    Training -->|"trains model"| Model
    Notebooks -->|"explore & refactor"| Model

    %% Optional Local vs Cloud styling
    DockerCompose -.->|Optional| API
    DockerCompose -.->|Optional| Streamlit
    DockerCompose -.->|Optional| Gradio
    DockerCompose -.->|Optional| Prometheus
    DockerCompose -.->|Optional| Grafana
    DockerCompose -.->|Optional| Jaeger

    %% Click Events
    click API "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/api/app.py"
    click API "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/api/metrics.py"
    click API "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/api/requirements.txt"
    click API "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/tree/main/api/Dockerfile"
    click API "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/api/.dockerignore"
    click Streamlit "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/ui/app.py"
    click Streamlit "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/ui/components.py"
    click Streamlit "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/ui/static/style.css"
    click Streamlit "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/ui/requirements.txt"
    click Streamlit "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/tree/main/ui/Dockerfile"
    click Streamlit "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/ui/.dockerignore"
    click Gradio "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/src/app/gradio_demo.py"
    click Gradio "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/src/app/Dockerfile.gradio"
    click Model "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/src/models/ctc_model.py"
    click Model "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/src/models/inference_model.py"
    click Model "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/src/models/improved_inference_model.py"
    click Model "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/src/models/model_manager.py"
    click Training "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/src/training/trainer.py"
    click Notebooks "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/tree/main/notebooks/original_notebooks/"
    click Notebooks "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/tree/main/notebooks/refactor_notebooks/"
    click Utils "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/src/utils/audio.py"
    click Utils "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/src/utils/config.py"
    click Utils "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/src/utils/logging.py"
    click Configs "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/configs/inference_config.yaml"
    click Configs "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/configs/model_config.yaml"
    click Configs "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/configs/training_config.yaml"
    click DockerCompose "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/docker/docker-compose.base.yml"
    click DockerCompose "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/docker/docker-compose.api.yml"
    click DockerCompose "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/docker/docker-compose.ui.yml"
    click DockerCompose "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/docker/docker-compose.monitoring.yml"
    click DockerCompose "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/docker/docker-compose.full.yml"
    click Kubernetes "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/k8s/base/api-deployment.yaml"
    click Kubernetes "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/k8s/base/api-service.yaml"
    click Kubernetes "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/k8s/base/ui-deployment.yaml"
    click Kubernetes "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/k8s/base/ui-service.yaml"
    click Kubernetes "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/k8s/ingress/asr-ingress.yaml"
    click Kubernetes "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/k8s/monitoring/prometheus-deployment.yaml"
    click Kubernetes "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/k8s/monitoring/grafana-deployment.yaml"
    click Kubernetes "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/k8s/monitoring/jaeger-instance.yaml"
    click Terraform "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/terraform/main.tf"
    click Terraform "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/terraform/variables.tf"
    click Terraform "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/terraform/outputs.tf"
    click Terraform "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/terraform/terraform.tfvars.example"
    click Jenkins "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/tree/main/jenkins/Jenkinsfile"
    click Jenkins "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/tree/main/jenkins/Dockerfile"
    click Jenkins "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/jenkins/scripts/build-image.sh"
    click Jenkins "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/jenkins/scripts/deploy.sh"
    click Jenkins "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/tree/main/Jenkinsfile"
    click GHActions "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/.github/workflows/docker-build.yml"
    click GHActions "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/.github/workflows/docker-publish.yml"
    click GHActions "https://github.com/tuandung222/convert-phowhisper-asr-from-encdec-to-ctc/blob/main/.github/workflows/pre-commit.yml"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef app fill:#e0ccff,stroke:#333,stroke-width:1px
    classDef config fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef infra fill:#d9d9d9,stroke:#333,stroke-width:1px
    classDef cloud fill:#ffcc80,stroke:#333,stroke-width:1px
    classDef ci fill:#f0f0f0,stroke:#333,stroke-width:1px
```
