# dharmi10/bnb26_visionaries_internal_round architecture

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

## Overview

Fair Drop is a first-come-first-served limited-seat sale API; the README explicitly says it has no queue, lottery, rate limiting, or bot defence. Admins create drops, users obtain simulated phone-based JWTs, then authenticated buyers request seats; operators and the bot lab can inspect drop state, results, attempts, and metrics. The HTTP handlers apply domain rules and use the Redis-backed store, whose Lua script makes the normal buy atomic. Source excerpts establish the main routing and calls; Redis and the operator console are documented capabilities.

Main entry points: [`internal/httpapi/server.go`](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/server.go) (HTTP Router), [`internal/store/store.go`](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/store/store.go) (Redis Store), [`internal/httpapi/handlers.go`](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/handlers.go) (Seat Purchase), [`cmd/server/main.go`](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/cmd/server/main.go) (Server Process)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and API"]
  node_server["Server Process<br/>[main.go]"]
  node_config["Runtime Config<br/>[config.go]"]
  node_http["HTTP Router<br/>[server.go]"]
  node_console["Operator Console<br/>[index.html]"]
end

subgraph group_identity["Identity and Access"]
  node_auth["JWT Authentication<br/>[auth.go]"]
  node_login["Phone Login<br/>[handlers.go]"]
end

subgraph group_sales["Drop Sales"]
  node_dropdomain["Drop Rules<br/>[drop.go]"]
  node_dropadmin["Drop Creation<br/>[handlers.go]"]
  node_dropstatus["Drop Status<br/>[handlers.go]"]
  node_buy["Seat Purchase<br/>[handlers.go]"]
  node_results["Sale Results<br/>[handlers.go]"]
end

subgraph group_storage["Persistence"]
  node_store["Redis Store<br/>[store.go]"]
  node_redis[("Redis")]
end

subgraph group_ops["Operations"]
  node_metrics["Prometheus Metrics<br/>[metrics.go]"]
  node_attempts["Attempt History<br/>[handlers.go]"]
end

node_admin(("Drop Admin"))
node_buyer(("Buyer"))
node_botlab(("Bot Lab"))

node_server -->|"loads settings"| node_config
node_server -->|"connects and primes"| node_store
node_server -->|"serves requests"| node_http
node_http -->|"routes creation"| node_dropadmin
node_http -->|"routes login"| node_login
node_http -->|"routes status"| node_dropstatus
node_http -->|"routes purchase"| node_buy
node_http -->|"routes results"| node_results
node_http -->|"routes attempts"| node_attempts
node_http -->|"protects purchase"| node_auth
node_http -->|"instruments requests"| node_metrics
node_http -->|"serves embedded assets"| node_console
node_admin -.->|"creates drops"| node_http
node_buyer -.->|"uses sale API"| node_http
node_botlab -.->|"drives and analyzes"| node_http
node_login -->|"upserts user"| node_store
node_login -->|"issues token"| node_auth
node_auth -->|"provides identity"| node_buy
node_dropadmin -->|"creates drop"| node_store
node_dropstatus -->|"loads drop and sales"| node_store
node_dropstatus -->|"derives state"| node_dropdomain
node_buy -->|"allocates seat"| node_store
node_buy -->|"checks sale window"| node_dropdomain
node_buy -->|"records outcome"| node_attempts
node_results -->|"loads buyers"| node_store
node_attempts -->|"loads attempt log"| node_store
node_store -->|"reads and writes"| node_redis
node_metrics -.->|"exposes metrics"| node_botlab

click node_server "https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/cmd/server/main.go"
click node_config "https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/config/config.go"
click node_http "https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/server.go"
click node_metrics "https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/metrics.go"
click node_auth "https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/auth.go"
click node_login "https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/handlers.go"
click node_dropdomain "https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/drop/drop.go"
click node_dropadmin "https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/handlers.go"
click node_dropstatus "https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/handlers.go"
click node_buy "https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/handlers.go"
click node_results "https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/handlers.go"
click node_attempts "https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/handlers.go"
click node_store "https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/store/store.go"
click node_console "https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/web/index.html"

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_server,node_config,node_http,node_console toneBlue
class node_auth,node_login toneAmber
class node_dropdomain,node_dropadmin,node_dropstatus,node_buy,node_results toneMint
class node_store,node_redis toneRose
class node_metrics,node_attempts,node_admin,node_buyer,node_botlab toneIndigo
```

## Components

### Runtime and API

- [Server Process](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/cmd/server/main.go): `cmd/server/main.go`
- [Runtime Config](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/config/config.go): `internal/config/config.go`
- [HTTP Router](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/server.go): `internal/httpapi/server.go`
- [Operator Console](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/web/index.html): `web/index.html`

### Identity and Access

- [JWT Authentication](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/auth.go): `internal/httpapi/auth.go`
- [Phone Login](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/handlers.go): `internal/httpapi/handlers.go`

### Drop Sales

- [Drop Rules](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/drop/drop.go): `internal/drop/drop.go`
- [Drop Creation](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/handlers.go): `internal/httpapi/handlers.go`
- [Drop Status](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/handlers.go): `internal/httpapi/handlers.go`
- [Seat Purchase](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/handlers.go): `internal/httpapi/handlers.go`
- [Sale Results](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/handlers.go): `internal/httpapi/handlers.go`

### Persistence

- [Redis Store](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/store/store.go): `internal/store/store.go`
- **Redis**

### Operations

- [Prometheus Metrics](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/metrics.go): `internal/httpapi/metrics.go`
- [Attempt History](https://github.com/dharmi10/bnb26_visionaries_internal_round/blob/main/internal/httpapi/handlers.go): `internal/httpapi/handlers.go`

### Other components

- **Drop Admin**
- **Buyer**
- **Bot Lab**

## Connections

- Server Process → Runtime Config: loads settings (evidence: `cmd/server/main.go`)
- Server Process → Redis Store: connects and primes (evidence: `cmd/server/main.go`)
- Server Process → HTTP Router: serves requests (evidence: `cmd/server/main.go`)
- HTTP Router → Drop Creation: routes creation (evidence: `internal/httpapi/server.go`)
- HTTP Router → Phone Login: routes login (evidence: `internal/httpapi/server.go`)
- HTTP Router → Drop Status: routes status (evidence: `internal/httpapi/server.go`)
- HTTP Router → Seat Purchase: routes purchase (evidence: `internal/httpapi/server.go`)
- HTTP Router → Sale Results: routes results (evidence: `internal/httpapi/server.go`)
- HTTP Router → Attempt History: routes attempts (evidence: `internal/httpapi/server.go`)
- HTTP Router → JWT Authentication: protects purchase (evidence: `internal/httpapi/server.go`)
- HTTP Router → Prometheus Metrics: instruments requests (evidence: `internal/httpapi/server.go`)
- HTTP Router → Operator Console: serves embedded assets (evidence: `internal/httpapi/server.go`)
- Drop Admin → HTTP Router: creates drops (evidence: `README.md`)
- Buyer → HTTP Router: uses sale API (evidence: `README.md`)
- Bot Lab → HTTP Router: drives and analyzes (evidence: `README.md`)
- Phone Login → Redis Store: upserts user (evidence: `internal/httpapi/handlers.go`)
- Phone Login → JWT Authentication: issues token (evidence: `internal/httpapi/handlers.go`)
- JWT Authentication → Seat Purchase: provides identity
- Drop Creation → Redis Store: creates drop (evidence: `internal/httpapi/handlers.go`)
- Drop Status → Redis Store: loads drop and sales (evidence: `internal/httpapi/handlers.go`)
- Drop Status → Drop Rules: derives state (evidence: `internal/httpapi/handlers.go`)
- Seat Purchase → Redis Store: allocates seat (evidence: `internal/httpapi/handlers.go`)
- Seat Purchase → Drop Rules: checks sale window (evidence: `internal/httpapi/handlers.go`)
- Seat Purchase → Attempt History: records outcome (evidence: `internal/httpapi/handlers.go`)
- Sale Results → Redis Store: loads buyers (evidence: `internal/httpapi/handlers.go`)
- Attempt History → Redis Store: loads attempt log (evidence: `internal/httpapi/handlers.go`)
- Redis Store → Redis: reads and writes (evidence: `internal/store/store.go`)
- Prometheus Metrics → Bot Lab: exposes metrics (evidence: `README.md`)
