# shivanshvermaa/mlops-deployment architecture

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

- Interactive diagram: https://gitdiagram.com/shivanshvermaa/mlops-deployment
- Repository: https://github.com/shivanshvermaa/mlops-deployment

## Overview

##### Main Components
- FastAPI Application: Represented by the “app” folder (with main.py, logging configuration, and model scripts). This is the core API server that handles requests, serves the ML model, and logs events.
- Logging & Monitoring: Indicate two parts – internal application logs (app/logs) and external fastapi-logs that are processed by Filebeat. The “filebeat” folder contains container configuration, showing that logs are being collected and forwarded (presumably to an ELK stack).
- Containerization & Orchestration: Show the Dockerfile and docker-compose.yaml, indicating that the application and its associated services are packaged into containers. Also include the Heroku deployment file (heroku.yml) since it represents another deployment target.

##### Relationships and Interactions
- Incoming User Traffic flowing to the FastAPI container running on Docker within the AWS EC2 instance.
- If applicable, add interactions between the FastAPI application and AWS services like S3 (for accessing or storing objects) and possibly other AWS resources for scaling or security.

##### Important Architectural Patterns & Technologies
- Microservice/Containerized Architecture: Emphasize that the application is containerized (using Docker and docker-compose) and modularized into separate components (API, logging, CI/CD).
- CI/CD Integration: Note that GitHub Actions provide automated builds and deployments, orchestrating changes from code commit to production in AWS.
- Observability: Mark the logging components (Filebeat and log directories) which interface with the ELK stack for centralized logging and monitoring.
- Cloud Deployment: Indicate that the application is designed to be deployed on AWS EC2 with associated configurations for security, scaling, and network access.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Global External Entities
    User["User Traffic"]:::external

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        CICD["CI/CD (GitHub Actions)"]:::cicd
    end

    %% Containerization & Orchestration Components
    subgraph "Containerization & Orchestration"
        DF["Dockerfile"]:::container
        DC["docker-compose.yaml"]:::container
        HY["heroku.yml"]:::container
        DF --> DC
        DC --> HY
    end

    %% AWS Infrastructure
    subgraph "AWS Infrastructure"
        AWS["AWS EC2 & Supporting Services"]:::aws
        S3["AWS S3 Bucket"]:::aws
    end

    %% External Logging System
    subgraph "External Systems"
        ELK["External ELK Stack"]:::external
    end

    %% FastAPI Application Container with Subcomponents
    subgraph "FastAPI Application (Container)"
        FAPI["FastAPI Service"]:::service
        MODEL["ML Model Module"]:::model
        INTLOGS["Internal Application Logs"]:::logs
        EXTLOGS["External FastAPI Logs"]:::logs
        FILEBEAT["Filebeat Logging Collector"]:::filebeat
    end

    %% Data Flow / Relationships
    User -->|"requests"| AWS
    AWS -->|"hosts"| FAPI
    FAPI -->|"invokes"| MODEL
    FAPI -->|"logs to"| INTLOGS
    FAPI -->|"exports logs to"| EXTLOGS
    EXTLOGS -->|"collected by"| FILEBEAT
    FILEBEAT -->|"forwards to"| ELK
    FAPI -->|"stores/retrieves models"| S3
    CICD -->|"triggers build"| DF
    DF -->|"builds containers for"| FAPI
    AWS -->|"runs containers via"| DC
    CICD -->|"automates deployment to"| AWS

    %% Click Events for Component Mappings
    click FAPI "https://github.com/shivanshvermaa/mlops-deployment/tree/main/app/"
    click MODEL "https://github.com/shivanshvermaa/mlops-deployment/tree/main/app/model/"
    click INTLOGS "https://github.com/shivanshvermaa/mlops-deployment/tree/main/app/logs/"
    click EXTLOGS "https://github.com/shivanshvermaa/mlops-deployment/tree/main/fastapi-logs/"
    click DF "https://github.com/shivanshvermaa/mlops-deployment/tree/main/Dockerfile"
    click DC "https://github.com/shivanshvermaa/mlops-deployment/blob/main/docker-compose.yaml"
    click HY "https://github.com/shivanshvermaa/mlops-deployment/blob/main/heroku.yml"
    click CICD "https://github.com/shivanshvermaa/mlops-deployment/tree/main/.github/workflows/"
    click FILEBEAT "https://github.com/shivanshvermaa/mlops-deployment/tree/main/filebeat/"

    %% Styling Classes
    classDef service fill:#f9a,stroke:#333,stroke-width:2px;
    classDef model fill:#fc9,stroke:#333,stroke-width:2px;
    classDef logs fill:#bbf,stroke:#333,stroke-width:2px;
    classDef container fill:#afa,stroke:#333,stroke-width:2px;
    classDef aws fill:#faa,stroke:#333,stroke-width:2px;
    classDef external fill:#ccc,stroke:#333,stroke-width:2px;
    classDef filebeat fill:#cff,stroke:#333,stroke-width:2px;
    classDef cicd fill:#dda,stroke:#333,stroke-width:2px;
```
