# algoamigoo/micdrop-backend architecture

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

- Interactive diagram: https://gitdiagram.com/algoamigoo/micdrop-backend
- Repository: https://github.com/algoamigoo/micdrop-backend

## Overview

MicDrop is a Go API for a crowdsourced comedy platform. Users authenticate, create and browse prompts, add responses, and vote; profiles expose user details and activity. The graph follows HTTP routing through handlers into persistence, and keeps prompt, response, profile, and voting responsibilities distinct. Source excerpts show startup, routing, selected handlers, and SQL behavior; unsampled handler implementations and some runtime wiring are not inferred beyond documented capabilities.

Main entry points: [`internal/router/router.go`](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/router/router.go) (Route dispatch), [`cmd/server/main.go`](https://github.com/algoamigoo/micdrop-backend/blob/master/cmd/server/main.go) (HTTP server), [`internal/handlers/auth.go`](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/handlers/auth.go) (OAuth and signup), [`internal/handlers/prompts.go`](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/handlers/prompts.go) (Prompt endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["HTTP server<br/>[main.go]"]
  node_router["Route dispatch<br/>[router.go]"]
  node_authmw["Session middleware<br/>[auth.go]"]
  node_handlers["Response handling<br/>[handlers.go]"]
  node_config["Environment config<br/>[config.go]"]
end

subgraph group_identity["Identity"]
  node_auth["OAuth and signup<br/>[auth.go]"]
  node_profiles["User profiles<br/>[users.go]"]
end

subgraph group_content["Comedy content"]
  node_prompth["Prompt endpoints<br/>[prompts.go]"]
  node_responseh["Response endpoints<br/>[responses.go]"]
  node_models["Domain models<br/>[models.go]"]
end

subgraph group_community["Community signals"]
  node_voteh["Vote endpoints<br/>[votes.go]"]
end

subgraph group_persistence["Persistence"]
  node_userstore["User persistence<br/>[users.go]"]
  node_promptstore["Prompt persistence<br/>[prompts.go]"]
  node_responsestore["Response persistence<br/>[responses.go]"]
  node_votestore["Vote transactions<br/>[votes.go]"]
  node_repository["Repository wiring<br/>[users.go]"]
  node_dbconn["DB connection<br/>[db.go]"]
end

node_client(("API client"))
node_google["Google OAuth"]
node_postgres[("PostgreSQL")]

node_client -->|"sends requests"| node_server
node_server -->|"loads config"| node_config
node_server -->|"connects to"| node_dbconn
node_server -->|"creates repository"| node_repository
node_server -->|"builds routes"| node_router
node_router -->|"routes auth"| node_auth
node_router -->|"routes profiles"| node_profiles
node_router -->|"routes prompts"| node_prompth
node_router -->|"routes responses"| node_responseh
node_router -->|"routes votes"| node_voteh
node_router -->|"applies auth"| node_authmw
node_auth -->|"exchanges OAuth"| node_google
node_auth -->|"creates users"| node_userstore
node_profiles -->|"reads and updates"| node_userstore
node_prompth -->|"reads and creates"| node_promptstore
node_responseh -.->|"delegates"| node_responsestore
node_voteh -.->|"delegates"| node_votestore
node_repository -->|"uses connection"| node_dbconn
node_userstore -.->|"queries"| node_postgres
node_promptstore -->|"queries"| node_postgres
node_responsestore -->|"queries"| node_postgres
node_votestore -->|"updates votes and scores"| node_postgres
node_prompth -.->|"returns prompt data"| node_models

click node_server "https://github.com/algoamigoo/micdrop-backend/blob/master/cmd/server/main.go"
click node_router "https://github.com/algoamigoo/micdrop-backend/blob/master/internal/router/router.go"
click node_authmw "https://github.com/algoamigoo/micdrop-backend/blob/master/internal/middleware/auth.go"
click node_handlers "https://github.com/algoamigoo/micdrop-backend/blob/master/internal/handlers/handlers.go"
click node_config "https://github.com/algoamigoo/micdrop-backend/blob/master/internal/config/config.go"
click node_auth "https://github.com/algoamigoo/micdrop-backend/blob/master/internal/handlers/auth.go"
click node_profiles "https://github.com/algoamigoo/micdrop-backend/blob/master/internal/handlers/users.go"
click node_userstore "https://github.com/algoamigoo/micdrop-backend/blob/master/internal/repository/users.go"
click node_prompth "https://github.com/algoamigoo/micdrop-backend/blob/master/internal/handlers/prompts.go"
click node_promptstore "https://github.com/algoamigoo/micdrop-backend/blob/master/internal/repository/prompts.go"
click node_responseh "https://github.com/algoamigoo/micdrop-backend/blob/master/internal/handlers/responses.go"
click node_responsestore "https://github.com/algoamigoo/micdrop-backend/blob/master/internal/repository/responses.go"
click node_voteh "https://github.com/algoamigoo/micdrop-backend/blob/master/internal/handlers/votes.go"
click node_votestore "https://github.com/algoamigoo/micdrop-backend/blob/master/internal/repository/votes.go"
click node_models "https://github.com/algoamigoo/micdrop-backend/blob/master/internal/models/models.go"
click node_repository "https://github.com/algoamigoo/micdrop-backend/blob/master/internal/repository/users.go"
click node_dbconn "https://github.com/algoamigoo/micdrop-backend/blob/master/internal/db/db.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_server,node_router,node_authmw,node_handlers,node_config,node_client toneBlue
class node_auth,node_profiles,node_postgres toneAmber
class node_prompth,node_responseh,node_models toneMint
class node_voteh toneRose
class node_userstore,node_promptstore,node_responsestore,node_votestore,node_repository,node_dbconn,node_google toneIndigo
```

## Components

### HTTP API

- [HTTP server](https://github.com/algoamigoo/micdrop-backend/blob/master/cmd/server/main.go): `cmd/server/main.go`
- [Route dispatch](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/router/router.go): `internal/router/router.go`
- [Session middleware](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/middleware/auth.go): `internal/middleware/auth.go`
- [Response handling](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/handlers/handlers.go): `internal/handlers/handlers.go`
- [Environment config](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/config/config.go): `internal/config/config.go`

### Identity

- [OAuth and signup](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/handlers/auth.go): `internal/handlers/auth.go`
- [User profiles](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/handlers/users.go): `internal/handlers/users.go`

### Comedy content

- [Prompt endpoints](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/handlers/prompts.go): `internal/handlers/prompts.go`
- [Response endpoints](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/handlers/responses.go): `internal/handlers/responses.go`
- [Domain models](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/models/models.go): `internal/models/models.go`

### Community signals

- [Vote endpoints](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/handlers/votes.go): `internal/handlers/votes.go`

### Persistence

- [User persistence](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/repository/users.go): `internal/repository/users.go`
- [Prompt persistence](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/repository/prompts.go): `internal/repository/prompts.go`
- [Response persistence](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/repository/responses.go): `internal/repository/responses.go`
- [Vote transactions](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/repository/votes.go): `internal/repository/votes.go`
- [Repository wiring](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/repository/users.go): `internal/repository/users.go`
- [DB connection](https://github.com/algoamigoo/micdrop-backend/blob/master/internal/db/db.go): `internal/db/db.go`

### Other components

- **API client**
- **Google OAuth**
- **PostgreSQL**

## Connections

- API client → HTTP server: sends requests (evidence: `README.md`)
- HTTP server → Environment config: loads config (evidence: `cmd/server/main.go`)
- HTTP server → DB connection: connects to (evidence: `cmd/server/main.go`)
- HTTP server → Repository wiring: creates repository (evidence: `cmd/server/main.go`)
- HTTP server → Route dispatch: builds routes (evidence: `cmd/server/main.go`)
- Route dispatch → OAuth and signup: routes auth (evidence: `internal/router/router.go`)
- Route dispatch → User profiles: routes profiles (evidence: `internal/router/router.go`)
- Route dispatch → Prompt endpoints: routes prompts (evidence: `internal/router/router.go`)
- Route dispatch → Response endpoints: routes responses (evidence: `internal/router/router.go`)
- Route dispatch → Vote endpoints: routes votes (evidence: `internal/router/router.go`)
- Route dispatch → Session middleware: applies auth (evidence: `internal/router/router.go`)
- OAuth and signup → Google OAuth: exchanges OAuth (evidence: `internal/handlers/auth.go`)
- OAuth and signup → User persistence: creates users (evidence: `internal/handlers/auth.go`)
- User profiles → User persistence: reads and updates (evidence: `internal/handlers/users.go`)
- Prompt endpoints → Prompt persistence: reads and creates (evidence: `internal/handlers/prompts.go`)
- Response endpoints → Response persistence: delegates
- Vote endpoints → Vote transactions: delegates
- Repository wiring → DB connection: uses connection
- User persistence → PostgreSQL: queries
- Prompt persistence → PostgreSQL: queries (evidence: `internal/repository/prompts.go`)
- Response persistence → PostgreSQL: queries (evidence: `internal/repository/responses.go`)
- Vote transactions → PostgreSQL: updates votes and scores (evidence: `internal/repository/votes.go`)
- Prompt endpoints → Domain models: returns prompt data
