# keltoumboukra/protein-optimizer architecture

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

- Interactive diagram: https://gitdiagram.com/keltoumboukra/protein-optimizer
- Repository: https://github.com/keltoumboukra/protein-optimizer

## Overview

##### Primary Components
- API Service (Backend): Represented by "src/api/main.py". This FastAPI-based service provides REST endpoints to serve prediction results and likely manage job submissions or other back-office workflows.
- Data Pipeline: Located in "src/data_pipeline/mock_data.py". It handles the generation or processing of data, including creating mock data for development or testing.
- Machine Learning Models: Found in "src/ml_models/predictor.py". This module implements a RandomForest-based model for predicting protein expression and solubility.

##### Relationships and Interactions
- The Dashboard queries the API service to fetch prediction data.
- The API service acts as the central hub that accepts requests (e.g., prediction requests), processes them, and interacts with both the data pipeline (for raw or mock data generation/processing) and the ML models (to generate and return predictions).
- The Data Pipeline module supplies or transforms data that feeds into the ML predictor.
- Both the API and ML modules are built on Python and utilize libraries such as scikit-learn for modeling, with configuration managed by common Python configuration files (e.g., pyproject.toml, setup.py).

##### Architectural Patterns and Design Principles
- Separation of Concerns: The system clearly separates user interface (dashboard), presentation/API layer (FastAPI), data processing (data_pipeline), and model inference (ml_models).
- Modularity: Each functional component is isolated in separate directories promoting easy testing and potential for future extension.
- RESTful Architecture: The API layer follows REST paradigms, allowing integration with diverse lab workflows.

##### Relevant Technologies and Frameworks
- Backend: FastAPI (for API endpoints) and Uvicorn (for ASGI server)
- Frontend: Streamlit (for dashboard visualizations) and Plotly (for interactive plots)
- Machine Learning: scikit-learn (for model implementation, specifically RandomForest)
- Testing & Development: Pytest, mypy, and black for ensuring code quality

##### Putting It All Together
- A note section or annotations summarizing that the API layer is built using FastAPI with uvicorn, and that the dashboard is built using Streamlit with plotly visualizations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend"
        A["Dashboard (Streamlit UI)"]:::frontend
    end

    subgraph "Backend Services"
        B["API Service (FastAPI)"]:::backend
        subgraph "Internal Modules"
            C["Data Pipeline"]:::backend
            D["ML Predictor (RandomForest)"]:::backend
        end
    end

    subgraph "Planned External Integrations"
        E["External Integrations (Planned)"]:::external
    end

    A -->|"sends_request"| B
    B -->|"calls_data_pipeline"| C
    B -->|"calls_ml_predictor"| D
    B -.->|"calls_external"| E
    B -->|"responds_to_dashboard"| A

    click A "https://github.com/keltoumboukra/protein-optimizer/blob/main/dashboard/app.py"
    click B "https://github.com/keltoumboukra/protein-optimizer/blob/main/src/api/main.py"
    click C "https://github.com/keltoumboukra/protein-optimizer/blob/main/src/data_pipeline/mock_data.py"
    click D "https://github.com/keltoumboukra/protein-optimizer/blob/main/src/ml_models/predictor.py"

    classDef frontend fill:#ffcccc,stroke:#aa0000,stroke-width:2px;
    classDef backend fill:#cce5ff,stroke:#003366,stroke-width:2px;
    classDef external fill:#d4edda,stroke:#155724,stroke-width:2px,stroke-dasharray:5,5
```
