# microblink/doc-ver-ops architecture

> Architecture diagram of the GitHub repository microblink/doc-ver-ops, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microblink/doc-ver-ops
- Repository: https://github.com/microblink/doc-ver-ops

## Overview

##### Project Type and Purpose
- This project isn’t a traditional full-stack “application” but rather a packaged deployment solution. Its primary purpose is to deploy a microservices-based document verification system using either Kubernetes (via Helm charts) or Docker Compose.
- The README clearly describes that you need a license key to enable the solution and that the system supports both scalable production environments (Helm with Kubernetes) and simpler docker-compose setups.

##### File Structure
- Notice the top-level directories and files such as “docker-compose” and “helm.” They indicate that the solution is delivered in a containerized form.
- Within the docker-compose directory, you see a base folder with several sub-folders for different service “bundles” (e.g., bundle-doc-ver, bundle-va, doc-ver-api, doc-ver-runner, embedding-store, retrieval-intermediary, visual-anomaly). Each bundle folder includes docker-compose.yaml files and service-specific subdirectories (like “nginx”, “proxy”, “model-serving”).
- The existence of configuration files (like .env files, nginx.conf, and proxy/bundle-signature.yaml) suggests that each component has a well-defined role and configuration file.
- In the Helm directory, the “doc-ver” chart shows templated Kubernetes configuration, indicating resource definitions, autoscaling setups, and secret management (e.g., for the licence key), which all support production-level deployment.

##### Main Components and Their Interactions
- Document Verification API (doc-ver-api)
- Document Runner (doc-ver-runner)
- Visual Anomaly detection (visual-anomaly)
- Embedding Store (embedding-store)
- Retrieval Intermediary (retrieval-intermediary)
- Model Serving components: This includes further subdivisions because both “bundle-doc-ver” and “bundle-va” directories have a “model-serving” folder that includes:
- Model download modules (script: model-download.sh, configuration: rclone.conf)
- Tensorflow-based model serving (with monitoring.txt to help observe performance)
- Proxy and NGINX Components: Each bundle also has nginx and proxy configuration – these indicate reverse proxy/load balancer functionalities.
- Incoming API traffic being routed (likely via an ingress controller or NGINX) towards the appropriate backend service.
- Inter-service communications between the retrieval intermediary, embedding store, and document verification API.
- Data flows from model serving (where models are downloaded, loaded, and served using TensorFlow) interacting with the document verification logic.
- The proxy components (with bundle-signature configurations) likely secure or modify the communication between services.

##### Architectural Patterns and Technologies
- Microservices architecture. Although every container is managed separately through docker-compose files or Kubernetes charts, the service decomposition follows clear boundaries.
- In a Helm deployment, include components such as autoscaling, resource limits, and possibly service meshes or ingress controllers (even if they’re not in the repository, they are inherently part of Kubernetes deployments).
- Technologies:
- Docker containers for packaging.
- Kubernetes for Helm-based deployments.
- NGINX as a reverse proxy/front end.
- TensorFlow for model serving.
- Scripts (like model-download.sh) for auxiliary functions like model retrieval.

##### Detailed Review and Final Touches
- Revisit each folder from the docker-compose and helm directories to ensure you capture all the individual services (for instance, distinguishing between bundle-doc-ver and bundle-va which may represent different verification modalities).
- To include auxiliary tools like the model download scripts, which are essential for the dynamic retrieval of ML models.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top-level Deployment Selection
    A["BlinkID Verify Deployment Package"]:::title
    A -->|"Use Helm (Kubernetes)"| B["Kubernetes/Helm Deployment"]:::helm
    A -->|"Use Docker Compose"| C["Docker Compose Deployment"]:::compose

    %% Kubernetes/Helm Deployment Subgraph
    subgraph "Kubernetes/Helm Deployment"
        B1["Helm Chart (doc-ver)"]:::helm
    end

    %% Docker Compose Deployment Subgraph
    subgraph "Docker Compose Deployment"
        %% Core Services Group
        subgraph "Core Services"
            D1["Document Verification API<br/>(Exposes endpoints)"]:::core
            D2["Document Runner<br/>(Processes docs)"]:::core
            D3["Visual Anomaly Detection<br/>(Analyzes visual cues)"]:::core
            D4["Embedding Store<br/>(Manages feature embeddings)"]:::core
            D5["Retrieval Intermediary<br/>(Coordinates data retrieval)"]:::core
        end

        %% Bundle Doc-Ver Group
        subgraph "Bundle Doc-Ver"
            E1["Model Download Script"]:::model
            E2["Model Download Config"]:::model
            E3["TensorFlow Serving Monitoring"]:::model
            E4["NGINX Configuration"]:::proxy
            E5["Proxy Bundle Signature"]:::proxy
        end

        %% Bundle VA Group
        subgraph "Bundle VA"
            F1["Model Download Script"]:::model
            F2["Model Download Config"]:::model
            F3["TensorFlow Serving Monitoring"]:::model
            F4["NGINX Configuration"]:::proxy
            F5["Proxy Bundle Signature"]:::proxy
        end

        %% Ingress/Router for Docker Compose
        G["Ingress/NGINX Router"]:::proxy
    end

    %% Interactions for Kubernetes/Helm deployment
    B1 -->|"defines services"| D1
    B1 -->|"defines services"| D2
    B1 -->|"defines services"| D3
    B1 -->|"defines services"| D4
    B1 -->|"defines services"| D5

    %% Ingress flows for Docker Compose
    G -->|"routes-to"| E4
    G -->|"routes-to"| F4
    E4 -->|"routes-to"| D1
    F4 -->|"routes-to"| D3

    %% Inter-service communications in Docker Compose
    D1 -->|"calls"| D5
    D1 -->|"fetches"| D4
    D1 -->|"triggers"| D2

    %% Bundle Doc-Ver Model Serving flow
    E1 -->|"initiates download"| E3
    E2 --> E3
    E3 -->|"serves model"| D1

    %% Bundle VA Model Serving flow
    F1 -->|"initiates download"| F3
    F2 --> F3
    F3 -->|"serves model"| D3

    %% Proxy interactions in bundles
    E5 -->|"secures traffic"| D1
    F5 -->|"secures traffic"| D3

    %% Click Events for Kubernetes/Helm
    click B1 "https://github.com/microblink/doc-ver-ops/tree/master/helm/doc-ver"

    %% Click Events for Docker Compose Core Services
    click D1 "https://github.com/microblink/doc-ver-ops/blob/master/docker-compose/base/doc-ver-api/docker-compose.yaml"
    click D2 "https://github.com/microblink/doc-ver-ops/blob/master/docker-compose/base/doc-ver-runner/docker-compose.yaml"
    click D3 "https://github.com/microblink/doc-ver-ops/blob/master/docker-compose/base/visual-anomaly/docker-compose.yaml"
    click D4 "https://github.com/microblink/doc-ver-ops/blob/master/docker-compose/base/embedding-store/docker-compose.yaml"
    click D5 "https://github.com/microblink/doc-ver-ops/blob/master/docker-compose/base/retrieval-intermediary/docker-compose.yaml"

    %% Click Events for Bundle Doc-Ver Model Serving
    click E1 "https://github.com/microblink/doc-ver-ops/blob/master/docker-compose/base/bundle-doc-ver/model-serving/model-download/model-download.sh"
    click E2 "https://github.com/microblink/doc-ver-ops/blob/master/docker-compose/base/bundle-doc-ver/model-serving/model-download/rclone.conf"
    click E3 "https://github.com/microblink/doc-ver-ops/blob/master/docker-compose/base/bundle-doc-ver/model-serving/tensorflow/monitoring.txt"
    click E4 "https://github.com/microblink/doc-ver-ops/blob/master/docker-compose/base/bundle-doc-ver/nginx/nginx.conf"
    click E5 "https://github.com/microblink/doc-ver-ops/blob/master/docker-compose/base/bundle-doc-ver/proxy/bundle-signature.yaml"

    %% Click Events for Bundle VA Model Serving
    click F1 "https://github.com/microblink/doc-ver-ops/blob/master/docker-compose/base/bundle-va/model-serving/model-download/model-download.sh"
    click F2 "https://github.com/microblink/doc-ver-ops/blob/master/docker-compose/base/bundle-va/model-serving/model-download/rclone.conf"
    click F3 "https://github.com/microblink/doc-ver-ops/blob/master/docker-compose/base/bundle-va/model-serving/tensorflow/monitoring.txt"
    click F4 "https://github.com/microblink/doc-ver-ops/blob/master/docker-compose/base/bundle-va/nginx/nginx.conf"
    click F5 "https://github.com/microblink/doc-ver-ops/blob/master/docker-compose/base/bundle-va/proxy/bundle-signature.yaml"

    %% Styles
    classDef title fill:#ffebcc,stroke:#e6a700,stroke-width:2px;
    classDef helm fill:#f9d6a5,stroke:#d89e68,stroke-width:2px;
    classDef compose fill:#cce5ff,stroke:#66b3ff,stroke-width:2px;
    classDef core fill:#d0f0c0,stroke:#5cb85c,stroke-width:2px;
    classDef model fill:#ffdbac,stroke:#ff9500,stroke-width:2px;
    classDef proxy fill:#ffb3b3,stroke:#ff6666,stroke-width:2px;
```
