# kirasync2748/profile-pulse architecture

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

- Interactive diagram: https://gitdiagram.com/kirasync2748/profile-pulse
- Repository: https://github.com/kirasync2748/profile-pulse

## Overview

ProfilePulse serves GitHub profile view-count badges and a JSON count endpoint. A profile image request reaches either the standalone server or a Vercel entry point, then shared handlers validate parameters, atomically increment a Redis-backed counter, format the result, and render SVG or JSON. Health routes work without Redis; Upstash, local Redis, and no-op stores are selectable. The excerpts show the runtime wiring and principal stages; Vercel routing and some renderer details are documented but not independently inspected.

Main entry points: [`internal/server/server.go`](https://github.com/kirasync2748/profile-pulse/blob/main/internal/server/server.go) (Shared HTTP handlers), [`internal/config/config.go`](https://github.com/kirasync2748/profile-pulse/blob/main/internal/config/config.go) (Runtime configuration), [`api/badge/badge.go`](https://github.com/kirasync2748/profile-pulse/blob/main/api/badge/badge.go) (Vercel badge route), [`api/count/count.go`](https://github.com/kirasync2748/profile-pulse/blob/main/api/count/count.go) (Vercel count route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["HTTP entry points"]
  node_standalone["Standalone server<br/>[main.go]"]
  node_vercel_badge["Vercel badge route<br/>[badge.go]"]
  node_vercel_count["Vercel count route<br/>[count.go]"]
  node_vercel_health["Vercel health route<br/>[health.go]"]
  node_vercel_root["Vercel root route<br/>[index.go]"]
end

subgraph group_handlers["Request handling"]
  node_shared_handlers["Shared HTTP handlers<br/>[server.go]"]
  node_input_validation["Input validation<br/>[validation.go]"]
  node_runtime_config["Runtime configuration<br/>[config.go]"]
end

subgraph group_counting["Counting and storage"]
  node_counter_selection["Store selection<br/>[server.go]"]
  node_store_contract["Counter store contract<br/>[counter.go]"]
  node_upstash_store["Upstash REST store<br/>[redis.go]"]
  node_local_store["Local Redis store<br/>[redis.go]"]
  node_noop_store["No-op store<br/>[counter.go]"]
end

subgraph group_output["Response generation"]
  node_value_formatting["Count formatting<br/>[badge.go]"]
  node_svg_renderer["SVG renderer<br/>[badge.go]"]
  node_json_response["JSON responses<br/>[server.go]"]
end

node_profile_viewer(("Profile viewer"))
node_upstash_redis[("Upstash Redis")]
node_local_redis[("Local Redis")]

node_profile_viewer -.->|"requests badge"| node_vercel_badge
node_profile_viewer -.->|"requests count"| node_vercel_count
node_standalone -->|"loads config"| node_runtime_config
node_standalone -->|"mounts handlers"| node_shared_handlers
node_vercel_badge -->|"loads config"| node_runtime_config
node_vercel_badge -->|"dispatches"| node_shared_handlers
node_vercel_count -->|"loads config"| node_runtime_config
node_vercel_count -->|"dispatches"| node_shared_handlers
node_vercel_health -->|"loads config"| node_runtime_config
node_vercel_health -->|"dispatches"| node_shared_handlers
node_vercel_root -->|"loads config"| node_runtime_config
node_vercel_root -->|"dispatches"| node_shared_handlers
node_shared_handlers -->|"validates inputs"| node_input_validation
node_shared_handlers -->|"parses base"| node_runtime_config
node_shared_handlers -->|"selects store"| node_counter_selection
node_counter_selection -->|"chooses first"| node_upstash_store
node_counter_selection -->|"chooses next"| node_local_store
node_counter_selection -->|"falls back"| node_noop_store
node_upstash_store -->|"sends INCR"| node_upstash_redis
node_local_store -->|"increments key"| node_local_redis
node_shared_handlers -->|"increments key"| node_store_contract
node_store_contract -->|"returns count"| node_value_formatting
node_shared_handlers -->|"formats count"| node_value_formatting
node_shared_handlers -->|"renders badge"| node_svg_renderer
node_shared_handlers -->|"encodes count"| node_json_response

click node_standalone "https://github.com/kirasync2748/profile-pulse/blob/main/cmd/server/main.go"
click node_vercel_badge "https://github.com/kirasync2748/profile-pulse/blob/main/api/badge/badge.go"
click node_vercel_count "https://github.com/kirasync2748/profile-pulse/blob/main/api/count/count.go"
click node_vercel_health "https://github.com/kirasync2748/profile-pulse/blob/main/api/health/health.go"
click node_vercel_root "https://github.com/kirasync2748/profile-pulse/blob/main/api/index/index.go"
click node_shared_handlers "https://github.com/kirasync2748/profile-pulse/blob/main/internal/server/server.go"
click node_input_validation "https://github.com/kirasync2748/profile-pulse/blob/main/internal/validation/validation.go"
click node_runtime_config "https://github.com/kirasync2748/profile-pulse/blob/main/internal/config/config.go"
click node_counter_selection "https://github.com/kirasync2748/profile-pulse/blob/main/internal/server/server.go"
click node_store_contract "https://github.com/kirasync2748/profile-pulse/blob/main/internal/counter/counter.go"
click node_upstash_store "https://github.com/kirasync2748/profile-pulse/blob/main/internal/counter/redis.go"
click node_local_store "https://github.com/kirasync2748/profile-pulse/blob/main/internal/counter/redis.go"
click node_noop_store "https://github.com/kirasync2748/profile-pulse/blob/main/internal/counter/counter.go"
click node_value_formatting "https://github.com/kirasync2748/profile-pulse/blob/main/internal/badge/badge.go"
click node_svg_renderer "https://github.com/kirasync2748/profile-pulse/blob/main/internal/badge/badge.go"
click node_json_response "https://github.com/kirasync2748/profile-pulse/blob/main/internal/server/server.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_standalone,node_vercel_badge,node_vercel_count,node_vercel_health,node_vercel_root,node_profile_viewer toneBlue
class node_shared_handlers,node_input_validation,node_runtime_config,node_upstash_redis,node_local_redis toneAmber
class node_counter_selection,node_store_contract,node_upstash_store,node_local_store,node_noop_store toneMint
class node_value_formatting,node_svg_renderer,node_json_response toneRose
```

## Components

### HTTP entry points

- [Standalone server](https://github.com/kirasync2748/profile-pulse/blob/main/cmd/server/main.go): `cmd/server/main.go`
- [Vercel badge route](https://github.com/kirasync2748/profile-pulse/blob/main/api/badge/badge.go): `api/badge/badge.go`
- [Vercel count route](https://github.com/kirasync2748/profile-pulse/blob/main/api/count/count.go): `api/count/count.go`
- [Vercel health route](https://github.com/kirasync2748/profile-pulse/blob/main/api/health/health.go): `api/health/health.go`
- [Vercel root route](https://github.com/kirasync2748/profile-pulse/blob/main/api/index/index.go): `api/index/index.go`

### Request handling

- [Shared HTTP handlers](https://github.com/kirasync2748/profile-pulse/blob/main/internal/server/server.go): `internal/server/server.go`
- [Input validation](https://github.com/kirasync2748/profile-pulse/blob/main/internal/validation/validation.go): `internal/validation/validation.go`
- [Runtime configuration](https://github.com/kirasync2748/profile-pulse/blob/main/internal/config/config.go): `internal/config/config.go`

### Counting and storage

- [Store selection](https://github.com/kirasync2748/profile-pulse/blob/main/internal/server/server.go): `internal/server/server.go`
- [Counter store contract](https://github.com/kirasync2748/profile-pulse/blob/main/internal/counter/counter.go): `internal/counter/counter.go`
- [Upstash REST store](https://github.com/kirasync2748/profile-pulse/blob/main/internal/counter/redis.go): `internal/counter/redis.go`
- [Local Redis store](https://github.com/kirasync2748/profile-pulse/blob/main/internal/counter/redis.go): `internal/counter/redis.go`
- [No-op store](https://github.com/kirasync2748/profile-pulse/blob/main/internal/counter/counter.go): `internal/counter/counter.go`

### Response generation

- [Count formatting](https://github.com/kirasync2748/profile-pulse/blob/main/internal/badge/badge.go): `internal/badge/badge.go`
- [SVG renderer](https://github.com/kirasync2748/profile-pulse/blob/main/internal/badge/badge.go): `internal/badge/badge.go`
- [JSON responses](https://github.com/kirasync2748/profile-pulse/blob/main/internal/server/server.go): `internal/server/server.go`

### Other components

- **Profile viewer**
- **Upstash Redis**
- **Local Redis**

## Connections

- Profile viewer → Vercel badge route: requests badge (evidence: `README.md`)
- Profile viewer → Vercel count route: requests count (evidence: `README.md`)
- Standalone server → Runtime configuration: loads config (evidence: `cmd/server/main.go`)
- Standalone server → Shared HTTP handlers: mounts handlers (evidence: `cmd/server/main.go`)
- Vercel badge route → Runtime configuration: loads config (evidence: `api/badge/badge.go`)
- Vercel badge route → Shared HTTP handlers: dispatches (evidence: `api/badge/badge.go`)
- Vercel count route → Runtime configuration: loads config (evidence: `api/count/count.go`)
- Vercel count route → Shared HTTP handlers: dispatches (evidence: `api/count/count.go`)
- Vercel health route → Runtime configuration: loads config (evidence: `api/health/health.go`)
- Vercel health route → Shared HTTP handlers: dispatches (evidence: `api/health/health.go`)
- Vercel root route → Runtime configuration: loads config (evidence: `api/index/index.go`)
- Vercel root route → Shared HTTP handlers: dispatches (evidence: `api/index/index.go`)
- Shared HTTP handlers → Input validation: validates inputs (evidence: `internal/server/server.go`)
- Shared HTTP handlers → Runtime configuration: parses base (evidence: `internal/server/server.go`)
- Shared HTTP handlers → Store selection: selects store (evidence: `internal/server/server.go`)
- Store selection → Upstash REST store: chooses first (evidence: `internal/server/server.go`)
- Store selection → Local Redis store: chooses next (evidence: `internal/server/server.go`)
- Store selection → No-op store: falls back (evidence: `internal/server/server.go`)
- Upstash REST store → Upstash Redis: sends INCR (evidence: `internal/counter/redis.go`)
- Local Redis store → Local Redis: increments key (evidence: `internal/counter/redis.go`)
- Shared HTTP handlers → Counter store contract: increments key (evidence: `internal/server/server.go`)
- Counter store contract → Count formatting: returns count (evidence: `README.md`)
- Shared HTTP handlers → Count formatting: formats count (evidence: `internal/server/server.go`)
- Shared HTTP handlers → SVG renderer: renders badge (evidence: `internal/server/server.go`)
- Shared HTTP handlers → JSON responses: encodes count (evidence: `internal/server/server.go`)
