# stefanprodan/podinfo architecture

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

- Interactive diagram: https://gitdiagram.com/stefanprodan/podinfo
- Repository: https://github.com/stefanprodan/podinfo

## Overview

Podinfo is a Go microservice demo for exercising Kubernetes-facing service behavior. The main workflow starts the configured HTTP and optional gRPC servers; callers use health/readiness probes or API endpoints, which return runtime data, simulate faults and delays, or interact with configured backends and storage. The README documents a broad HTTP and gRPC surface, while the sampled server code shows HTTP route registration and gRPC service registration. Some handler implementations were not sampled, so their internal dependencies are not inferred.

Main entry points: [`pkg/api/http/server.go`](https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/server.go) (HTTP server), [`cmd/podinfo/main.go`](https://github.com/stefanprodan/podinfo/blob/master/cmd/podinfo/main.go) (Podinfo process), [`pkg/api/grpc/server.go`](https://github.com/stefanprodan/podinfo/blob/master/pkg/api/grpc/server.go) (gRPC server), [`pkg/api/http/cache.go`](https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/cache.go) (Redis cache)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_app["Podinfo process<br/>[main.go]"]
end

subgraph group_http["HTTP API"]
  node_http_server["HTTP server<br/>[server.go]"]
  node_http_core["HTTP responses<br/>[http.go]"]
  node_http_info["Runtime info<br/>[info.go]"]
  node_http_health["Health and readiness<br/>[health.go]"]
  node_http_metrics["Metrics<br/>[metrics.go]"]
  node_http_faults["Fault controls<br/>[fault_injection.go]"]
  node_http_data["HTTP API handlers"]
  node_http_cache["Redis cache<br/>[cache.go]"]
  node_http_store["Disk store<br/>[store.go]"]
  node_http_echo["Backend echo<br/>[echo.go]"]
end

subgraph group_grpc["gRPC API"]
  node_grpc_server["gRPC server<br/>[server.go]"]
  node_grpc_handlers["gRPC services"]
end

subgraph group_ops["Operations"]
  node_signals["Shutdown signals<br/>[shutdown.go]"]
  node_file_cache["Config file cache<br/>[fscache.go]"]
  node_podcli["Pod CLI<br/>[ws.go]"]
end

node_caller(("API caller"))
node_redis[("Redis")]
node_backend["Backend service"]

node_app -->|"starts"| node_http_server
node_app -->|"starts"| node_grpc_server
node_app -->|"configures shutdown"| node_signals
node_caller -->|"sends HTTP"| node_http_server
node_caller -->|"calls gRPC"| node_grpc_server
node_http_server -->|"routes to"| node_http_info
node_http_server -->|"routes to"| node_http_health
node_http_server -->|"routes to"| node_http_metrics
node_http_server -->|"routes to"| node_http_faults
node_http_server -->|"routes to"| node_http_data
node_http_server -->|"routes to"| node_http_cache
node_http_server -->|"routes to"| node_http_store
node_http_server -->|"routes to"| node_http_echo
node_http_cache -->|"reads and writes"| node_redis
node_http_echo -->|"forwards request"| node_backend
node_grpc_server -->|"registers services"| node_grpc_handlers
node_http_server -->|"uses"| node_file_cache
node_caller -.->|"runs commands"| node_podcli
node_podcli -.->|"opens WebSocket"| node_http_server

click node_app "https://github.com/stefanprodan/podinfo/blob/master/cmd/podinfo/main.go"
click node_http_server "https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/server.go"
click node_http_core "https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/http.go"
click node_http_info "https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/info.go"
click node_http_health "https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/health.go"
click node_http_metrics "https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/metrics.go"
click node_http_faults "https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/fault_injection.go"
click node_http_data "https://github.com/stefanprodan/podinfo/tree/master/pkg/api/http"
click node_http_cache "https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/cache.go"
click node_http_store "https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/store.go"
click node_http_echo "https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/echo.go"
click node_grpc_server "https://github.com/stefanprodan/podinfo/blob/master/pkg/api/grpc/server.go"
click node_grpc_handlers "https://github.com/stefanprodan/podinfo/tree/master/pkg/api/grpc"
click node_signals "https://github.com/stefanprodan/podinfo/blob/master/pkg/signals/shutdown.go"
click node_file_cache "https://github.com/stefanprodan/podinfo/blob/master/pkg/fscache/fscache.go"
click node_podcli "https://github.com/stefanprodan/podinfo/blob/master/cmd/podcli/ws.go"

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_app toneBlue
class node_http_server,node_http_core,node_http_info,node_http_health,node_http_metrics,node_http_faults,node_http_data,node_http_cache,node_http_store,node_http_echo,node_redis toneAmber
class node_grpc_server,node_grpc_handlers,node_caller toneMint
class node_signals,node_file_cache,node_podcli toneRose
class node_backend toneIndigo
```

## Components

### Runtime

- [Podinfo process](https://github.com/stefanprodan/podinfo/blob/master/cmd/podinfo/main.go): `cmd/podinfo/main.go`

### HTTP API

- [HTTP server](https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/server.go): `pkg/api/http/server.go`
- [HTTP responses](https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/http.go): `pkg/api/http/http.go`
- [Runtime info](https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/info.go): `pkg/api/http/info.go`
- [Health and readiness](https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/health.go): `pkg/api/http/health.go`
- [Metrics](https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/metrics.go): `pkg/api/http/metrics.go`
- [Fault controls](https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/fault_injection.go): `pkg/api/http/fault_injection.go`
- [HTTP API handlers](https://github.com/stefanprodan/podinfo/tree/master/pkg/api/http): `pkg/api/http`
- [Redis cache](https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/cache.go): `pkg/api/http/cache.go`
- [Disk store](https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/store.go): `pkg/api/http/store.go`
- [Backend echo](https://github.com/stefanprodan/podinfo/blob/master/pkg/api/http/echo.go): `pkg/api/http/echo.go`

### gRPC API

- [gRPC server](https://github.com/stefanprodan/podinfo/blob/master/pkg/api/grpc/server.go): `pkg/api/grpc/server.go`
- [gRPC services](https://github.com/stefanprodan/podinfo/tree/master/pkg/api/grpc): `pkg/api/grpc`

### Operations

- [Shutdown signals](https://github.com/stefanprodan/podinfo/blob/master/pkg/signals/shutdown.go): `pkg/signals/shutdown.go`
- [Config file cache](https://github.com/stefanprodan/podinfo/blob/master/pkg/fscache/fscache.go): `pkg/fscache/fscache.go`
- [Pod CLI](https://github.com/stefanprodan/podinfo/blob/master/cmd/podcli/ws.go): `cmd/podcli/ws.go`

### Other components

- **API caller**
- **Redis**
- **Backend service**

## Connections

- Podinfo process → HTTP server: starts (evidence: `cmd/podinfo/main.go`)
- Podinfo process → gRPC server: starts (evidence: `cmd/podinfo/main.go`)
- Podinfo process → Shutdown signals: configures shutdown (evidence: `cmd/podinfo/main.go`)
- API caller → HTTP server: sends HTTP
- API caller → gRPC server: calls gRPC
- HTTP server → Runtime info: routes to (evidence: `pkg/api/http/server.go`)
- HTTP server → Health and readiness: routes to (evidence: `pkg/api/http/server.go`)
- HTTP server → Metrics: routes to (evidence: `pkg/api/http/server.go`)
- HTTP server → Fault controls: routes to (evidence: `pkg/api/http/server.go`)
- HTTP server → HTTP API handlers: routes to (evidence: `pkg/api/http/server.go`)
- HTTP server → Redis cache: routes to (evidence: `pkg/api/http/server.go`)
- HTTP server → Disk store: routes to (evidence: `pkg/api/http/server.go`)
- HTTP server → Backend echo: routes to (evidence: `pkg/api/http/server.go`)
- Redis cache → Redis: reads and writes (evidence: `pkg/api/http/cache.go`)
- Backend echo → Backend service: forwards request (evidence: `pkg/api/http/echo.go`)
- gRPC server → gRPC services: registers services (evidence: `pkg/api/grpc/server.go`)
- HTTP server → Config file cache: uses (evidence: `pkg/api/http/server.go`)
- API caller → Pod CLI: runs commands
- Pod CLI → HTTP server: opens WebSocket
