# bcraxyz/model-armor architecture

> Architecture diagram of the GitHub repository bcraxyz/model-armor, 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/bcraxyz/model-armor
- Repository: https://github.com/bcraxyz/model-armor

## Overview

##### Main Components
- Client/User Interface – This is where end users interact with the Streamlit application via a web browser.
- Streamlit Application – The heart of the project is implemented in streamlit_app.py. This component handles user interaction, display logic, and integrates with the safety & security testing provided by Google Model Armor.
- Cloud Run Deployment – The presence of cloudrun_app.py and the Dockerfile indicates that the app is designed to be containerized and deployed on Google Cloud Run. Represent this as the deployment/execution environment.
- Docker Container – Use the Dockerfile to highlight the containerization aspect. This encapsulates the runtime environment, dependencies (from requirements.txt), and ensures consistency across development and production.
- External Service: Google Model Armor LLM Safety & Security Tool – Although not part of the codebase, the README makes it clear that this is a core integration. Represent this external dependency to show how the application interacts with it.

##### Interactions & Data Flow
- Start at the client end: Users access the Streamlit interface through their browser.
- The Streamlit UI (from streamlit_app.py) then processes these interactions and, as needed, calls out to the Google Model Armor service to test LLM safety/security.

##### Architectural Patterns & Components
- Component Segregation: Clearly distinguish between the client, application server (Streamlit), container/Cloud Run environment, and the external LLM safety tool.
- Containerization: Mark the Docker container as the fundamental execution and deployment context.
- Integration Points: Highlight the external dependency on Google Model Armor; this emphasizes that while the application is self-contained, it leverages external API/services to perform LLM safety tests.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Layer"
        UB["User Browser"]:::client
    end

    subgraph "Deployment Environment"
        CR["Cloud Run Deployment"]:::deployment
        DC["Docker Container"]:::container
        SA["Streamlit Application"]:::app
    end

    ES["Google Model Armor API"]:::external

    UB -->|"accesses"| CR
    CR -->|"routesTo"| DC
    DC -->|"hosts"| SA
    SA -->|"calls"| ES
    SA -->|"respondsTo"| UB

    click SA "https://github.com/bcraxyz/model-armor/blob/main/streamlit_app.py"
    click CR "https://github.com/bcraxyz/model-armor/blob/main/cloudrun_app.py"
    click DC "https://github.com/bcraxyz/model-armor/tree/main/Dockerfile"

    classDef client fill:#ffcccb,stroke:#333,stroke-width:2px;
    classDef app fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef deployment fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef container fill:#f0e68c,stroke:#333,stroke-width:2px;
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:2px,stroke-dasharray:5,5
```
