# sohamnigh/mini-inference-serving-system architecture

> Architecture diagram of the GitHub repository sohamnigh/mini-inference-serving-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sohamnigh/mini-inference-serving-system
- Repository: https://github.com/sohamnigh/mini-inference-serving-system

## Overview

This is a split-process MNIST inference-serving system: clients submit JSON predictions to a Go HTTP front end, which validates requests, queues and dynamically batches them, then calls a C++ gRPC engine for model inference. The graph also preserves the documented metrics and offline training/export capabilities. Edges follow shown wiring and documented calls; the batcher and engine client implementations are indexed as read but not excerpted, so their connection is supported by the README rather than inspected implementation details.

Main entry points: [`go-server/internal/app/app.go`](https://github.com/sohamnigh/mini-inference-serving-system/blob/main/go-server/internal/app/app.go) (Server wiring), [`go-server/internal/engineclient/client.go`](https://github.com/sohamnigh/mini-inference-serving-system/blob/main/go-server/internal/engineclient/client.go) (gRPC client), [`go-server/internal/httpapi/server.go`](https://github.com/sohamnigh/mini-inference-serving-system/blob/main/go-server/internal/httpapi/server.go) (HTTP API), [`go-server/internal/batcher/batcher.go`](https://github.com/sohamnigh/mini-inference-serving-system/blob/main/go-server/internal/batcher/batcher.go) (Queue and batcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Go serving front end"]
  node_http["HTTP API<br/>[server.go]"]
  node_batcher["Queue and batcher<br/>[batcher.go]"]
  node_engineclient["gRPC client<br/>[client.go]"]
  node_app["Server wiring<br/>[app.go]"]
  node_metrics["Metrics<br/>[metrics.go]"]
end

subgraph group_engine["C++ inference engine"]
  node_engine_service["gRPC service<br/>[main.cc]"]
  node_model["Model loader and inference<br/>[model.cc]"]
  node_kernels["Inference kernels<br/>[kernels.cc]"]
end

subgraph group_training["Offline model training"]
  node_trainer["MNIST trainer<br/>[train.py]"]
  node_weights_export["Weights export<br/>[weights_io.py]"]
end

subgraph group_contract["Service contract"]
  node_contract_proto["PredictBatch contract<br/>[inference.proto]"]
end

node_client(("Inference client"))

node_client -->|"submits JSON"| node_http
node_http -->|"submits requests"| node_batcher
node_batcher -->|"sends batches"| node_engineclient
node_engineclient -->|"calls gRPC"| node_engine_service
node_engine_service -->|"invokes predict"| node_model
node_model -->|"calls kernels"| node_kernels
node_engine_service -->|"implements RPC"| node_contract_proto
node_engineclient -->|"uses RPC contract"| node_contract_proto
node_trainer -->|"exports weights"| node_weights_export
node_app -->|"creates client"| node_engineclient
node_app -->|"creates batcher"| node_batcher
node_app -->|"creates API"| node_http
node_app -->|"registers metrics"| node_metrics
node_app -->|"attaches observer"| node_batcher
node_app -->|"attaches recorder"| node_http

click node_http "https://github.com/sohamnigh/mini-inference-serving-system/blob/main/go-server/internal/httpapi/server.go"
click node_batcher "https://github.com/sohamnigh/mini-inference-serving-system/blob/main/go-server/internal/batcher/batcher.go"
click node_engineclient "https://github.com/sohamnigh/mini-inference-serving-system/blob/main/go-server/internal/engineclient/client.go"
click node_app "https://github.com/sohamnigh/mini-inference-serving-system/blob/main/go-server/internal/app/app.go"
click node_metrics "https://github.com/sohamnigh/mini-inference-serving-system/blob/main/go-server/internal/metrics/metrics.go"
click node_engine_service "https://github.com/sohamnigh/mini-inference-serving-system/blob/main/cpp-engine/main.cc"
click node_model "https://github.com/sohamnigh/mini-inference-serving-system/blob/main/cpp-engine/model.cc"
click node_kernels "https://github.com/sohamnigh/mini-inference-serving-system/blob/main/cpp-engine/kernels.cc"
click node_contract_proto "https://github.com/sohamnigh/mini-inference-serving-system/blob/main/proto/inference.proto"
click node_trainer "https://github.com/sohamnigh/mini-inference-serving-system/blob/main/training/train.py"
click node_weights_export "https://github.com/sohamnigh/mini-inference-serving-system/blob/main/training/weights_io.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_http,node_batcher,node_engineclient,node_app,node_metrics,node_client toneBlue
class node_engine_service,node_model,node_kernels toneAmber
class node_trainer,node_weights_export toneMint
class node_contract_proto toneRose
```

## Components

### Go serving front end

- [HTTP API](https://github.com/sohamnigh/mini-inference-serving-system/blob/main/go-server/internal/httpapi/server.go): `go-server/internal/httpapi/server.go`
- [Queue and batcher](https://github.com/sohamnigh/mini-inference-serving-system/blob/main/go-server/internal/batcher/batcher.go): `go-server/internal/batcher/batcher.go`
- [gRPC client](https://github.com/sohamnigh/mini-inference-serving-system/blob/main/go-server/internal/engineclient/client.go): `go-server/internal/engineclient/client.go`
- [Server wiring](https://github.com/sohamnigh/mini-inference-serving-system/blob/main/go-server/internal/app/app.go): `go-server/internal/app/app.go`
- [Metrics](https://github.com/sohamnigh/mini-inference-serving-system/blob/main/go-server/internal/metrics/metrics.go): `go-server/internal/metrics/metrics.go`

### C++ inference engine

- [gRPC service](https://github.com/sohamnigh/mini-inference-serving-system/blob/main/cpp-engine/main.cc): `cpp-engine/main.cc`
- [Model loader and inference](https://github.com/sohamnigh/mini-inference-serving-system/blob/main/cpp-engine/model.cc): `cpp-engine/model.cc`
- [Inference kernels](https://github.com/sohamnigh/mini-inference-serving-system/blob/main/cpp-engine/kernels.cc): `cpp-engine/kernels.cc`

### Offline model training

- [MNIST trainer](https://github.com/sohamnigh/mini-inference-serving-system/blob/main/training/train.py): `training/train.py`
- [Weights export](https://github.com/sohamnigh/mini-inference-serving-system/blob/main/training/weights_io.py): `training/weights_io.py`

### Service contract

- [PredictBatch contract](https://github.com/sohamnigh/mini-inference-serving-system/blob/main/proto/inference.proto): `proto/inference.proto`

### Other components

- **Inference client**

## Connections

- Inference client → HTTP API: submits JSON (evidence: `README.md`)
- HTTP API → Queue and batcher: submits requests (evidence: `go-server/internal/httpapi/server.go`)
- Queue and batcher → gRPC client: sends batches (evidence: `README.md`)
- gRPC client → gRPC service: calls gRPC (evidence: `README.md`)
- gRPC service → Model loader and inference: invokes predict (evidence: `cpp-engine/main.cc`)
- Model loader and inference → Inference kernels: calls kernels (evidence: `cpp-engine/model.cc`)
- gRPC service → PredictBatch contract: implements RPC (evidence: `proto/inference.proto`)
- gRPC client → PredictBatch contract: uses RPC contract (evidence: `README.md`)
- MNIST trainer → Weights export: exports weights (evidence: `training/train.py`)
- Server wiring → gRPC client: creates client (evidence: `go-server/internal/app/app.go`)
- Server wiring → Queue and batcher: creates batcher (evidence: `go-server/internal/app/app.go`)
- Server wiring → HTTP API: creates API (evidence: `go-server/internal/app/app.go`)
- Server wiring → Metrics: registers metrics (evidence: `go-server/internal/app/app.go`)
- Server wiring → Queue and batcher: attaches observer (evidence: `go-server/internal/app/app.go`)
- Server wiring → HTTP API: attaches recorder (evidence: `go-server/internal/app/app.go`)
