# yeegeek/uyou-go-api-starter architecture

> Architecture diagram of the GitHub repository yeegeek/uyou-go-api-starter, 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/yeegeek/uyou-go-api-starter
- Repository: https://github.com/yeegeek/uyou-go-api-starter

## Overview

UYou Go API Starter is a REST API starter with a React client for account and friend workflows. The main path is browser auth state → HTTP routes → handlers → services and repositories → configured data stores. The repository also documents gRPC, RabbitMQ/event messaging, health checks, Prometheus metrics, and scheduled jobs; those capabilities are represented where the tree or excerpts identify them, but their runtime wiring is not fully shown. Dashed edges mark documented or unverified integration; unsampled source was not inspected.

Main entry points: [`internal/server/router.go`](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/server/router.go) (HTTP routing), [`cmd/server/main.go`](https://github.com/yeegeek/uyou-go-api-starter/blob/main/cmd/server/main.go) (API server), [`internal/user/service.go`](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/user/service.go) (User service), [`internal/db/db.go`](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/db/db.go) (PostgreSQL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_webapp["Web app routes<br/>[App.tsx]"]
  node_authstate["Auth state<br/>[useAuth.ts]"]
  node_apiclient["API client<br/>[api.ts]"]
end

subgraph group_http["HTTP API"]
  node_server["API server<br/>[main.go]"]
  node_router["HTTP routing<br/>[router.go]"]
  node_middleware["HTTP middleware"]
end

subgraph group_identity["Identity and social"]
  node_userhandler["User handlers<br/>[handler.go]"]
  node_userservice["User service<br/>[service.go]"]
  node_userrepo["User repository<br/>[repository.go]"]
  node_authservice["Auth service<br/>[service.go]"]
  node_tokenrotation["Refresh tokens<br/>[refresh_token.go]"]
  node_friendhandler["Friend handlers<br/>[handler.go]"]
  node_friendservice["Friend service<br/>[service.go]"]
  node_friendrepo["Friend repository<br/>[repository.go]"]
end

subgraph group_platform["Persistence and operations"]
  node_postgres[("PostgreSQL<br/>[db.go]")]
  node_mongodb[("MongoDB<br/>[mongodb.go]")]
  node_redis[("Redis cache<br/>[redis.go]")]
  node_health["Health checks"]
  node_metrics["Prometheus metrics<br/>[metrics.go]"]
  node_migrator["Schema migrations<br/>[migrate.go]"]
end

subgraph group_integration["Service integrations"]
  node_grpcserver["gRPC server<br/>[server.go]"]
  node_grpcclient["gRPC client<br/>[user_client.go]"]
  node_protobuf["User protobuf<br/>[user.proto]"]
  node_rabbitmq["RabbitMQ messaging<br/>[rabbitmq.go]"]
  node_events["Event bus<br/>[events.go]"]
  node_scheduler["Task manager<br/>[manager.go]"]
  node_scheduledtasks["Scheduled tasks"]
end

node_person(("API user"))

node_person -->|"uses"| node_webapp
node_webapp -->|"reads auth"| node_authstate
node_webapp -.->|"requests"| node_apiclient
node_apiclient -.->|"HTTP calls"| node_server
node_server -->|"configures"| node_router
node_router -->|"routes"| node_userhandler
node_router -->|"routes"| node_friendhandler
node_router -->|"installs"| node_middleware
node_router -->|"routes"| node_health
node_userhandler -->|"calls"| node_userservice
node_userhandler -->|"auth operations"| node_authservice
node_userservice -.->|"uses"| node_userrepo
node_authservice -.->|"rotates tokens"| node_tokenrotation
node_friendhandler -->|"calls"| node_friendservice
node_friendservice -.->|"uses"| node_friendrepo
node_userrepo -.->|"persists users"| node_postgres
node_friendrepo -.->|"persists friendships"| node_postgres
node_userservice -.->|"cache integration"| node_redis
node_server -->|"opens connection"| node_postgres
node_server -->|"checks schema"| node_migrator
node_server -.->|"starts service"| node_grpcserver
node_grpcserver -.->|"serves user operations"| node_userservice
node_grpcclient -->|"uses definitions"| node_protobuf
node_rabbitmq -.->|"publishes events"| node_events
node_scheduler -->|"registers tasks"| node_scheduledtasks
node_health -.->|"checks database"| node_postgres
node_router -.->|"exposes metrics"| node_metrics

click node_webapp "https://github.com/yeegeek/uyou-go-api-starter/blob/main/frontend/src/App.tsx"
click node_authstate "https://github.com/yeegeek/uyou-go-api-starter/blob/main/frontend/src/hooks/useAuth.ts"
click node_apiclient "https://github.com/yeegeek/uyou-go-api-starter/blob/main/frontend/src/services/api.ts"
click node_server "https://github.com/yeegeek/uyou-go-api-starter/blob/main/cmd/server/main.go"
click node_router "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/server/router.go"
click node_middleware "https://github.com/yeegeek/uyou-go-api-starter/tree/main/internal/middleware"
click node_userhandler "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/user/handler.go"
click node_userservice "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/user/service.go"
click node_userrepo "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/user/repository.go"
click node_authservice "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/auth/service.go"
click node_tokenrotation "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/auth/refresh_token.go"
click node_friendhandler "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/friend/handler.go"
click node_friendservice "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/friend/service.go"
click node_friendrepo "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/friend/repository.go"
click node_postgres "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/db/db.go"
click node_mongodb "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/mongodb/mongodb.go"
click node_redis "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/redis/redis.go"
click node_health "https://github.com/yeegeek/uyou-go-api-starter/tree/main/internal/health"
click node_metrics "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/metrics/metrics.go"
click node_migrator "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/migrate/migrate.go"
click node_grpcserver "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/grpc/server/server.go"
click node_grpcclient "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/grpc/client/user_client.go"
click node_protobuf "https://github.com/yeegeek/uyou-go-api-starter/blob/main/api/proto/user/user.proto"
click node_rabbitmq "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/messaging/rabbitmq.go"
click node_events "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/messaging/events.go"
click node_scheduler "https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/scheduler/manager.go"
click node_scheduledtasks "https://github.com/yeegeek/uyou-go-api-starter/tree/main/internal/scheduler/tasks"

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_webapp,node_authstate,node_apiclient,node_person toneBlue
class node_server,node_router,node_middleware toneAmber
class node_userhandler,node_userservice,node_userrepo,node_authservice,node_tokenrotation,node_friendhandler,node_friendservice,node_friendrepo toneMint
class node_postgres,node_mongodb,node_redis,node_health,node_metrics,node_migrator toneRose
class node_grpcserver,node_grpcclient,node_protobuf,node_rabbitmq,node_events,node_scheduler,node_scheduledtasks toneIndigo
```

## Components

### Web client

- [Web app routes](https://github.com/yeegeek/uyou-go-api-starter/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Auth state](https://github.com/yeegeek/uyou-go-api-starter/blob/main/frontend/src/hooks/useAuth.ts): `frontend/src/hooks/useAuth.ts`
- [API client](https://github.com/yeegeek/uyou-go-api-starter/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`

### HTTP API

- [API server](https://github.com/yeegeek/uyou-go-api-starter/blob/main/cmd/server/main.go): `cmd/server/main.go`
- [HTTP routing](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/server/router.go): `internal/server/router.go`
- [HTTP middleware](https://github.com/yeegeek/uyou-go-api-starter/tree/main/internal/middleware): `internal/middleware`

### Identity and social

- [User handlers](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/user/handler.go): `internal/user/handler.go`
- [User service](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/user/service.go): `internal/user/service.go`
- [User repository](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/user/repository.go): `internal/user/repository.go`
- [Auth service](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/auth/service.go): `internal/auth/service.go`
- [Refresh tokens](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/auth/refresh_token.go): `internal/auth/refresh_token.go`
- [Friend handlers](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/friend/handler.go): `internal/friend/handler.go`
- [Friend service](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/friend/service.go): `internal/friend/service.go`
- [Friend repository](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/friend/repository.go): `internal/friend/repository.go`

### Persistence and operations

- [PostgreSQL](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/db/db.go): `internal/db/db.go`
- [MongoDB](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/mongodb/mongodb.go): `internal/mongodb/mongodb.go`
- [Redis cache](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/redis/redis.go): `internal/redis/redis.go`
- [Health checks](https://github.com/yeegeek/uyou-go-api-starter/tree/main/internal/health): `internal/health`
- [Prometheus metrics](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/metrics/metrics.go): `internal/metrics/metrics.go`
- [Schema migrations](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/migrate/migrate.go): `internal/migrate/migrate.go`

### Service integrations

- [gRPC server](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/grpc/server/server.go): `internal/grpc/server/server.go`
- [gRPC client](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/grpc/client/user_client.go): `internal/grpc/client/user_client.go`
- [User protobuf](https://github.com/yeegeek/uyou-go-api-starter/blob/main/api/proto/user/user.proto): `api/proto/user/user.proto`
- [RabbitMQ messaging](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/messaging/rabbitmq.go): `internal/messaging/rabbitmq.go`
- [Event bus](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/messaging/events.go): `internal/messaging/events.go`
- [Task manager](https://github.com/yeegeek/uyou-go-api-starter/blob/main/internal/scheduler/manager.go): `internal/scheduler/manager.go`
- [Scheduled tasks](https://github.com/yeegeek/uyou-go-api-starter/tree/main/internal/scheduler/tasks): `internal/scheduler/tasks`

### Other components

- **API user**

## Connections

- API user → Web app routes: uses (evidence: `frontend/src/App.tsx`)
- Web app routes → Auth state: reads auth (evidence: `frontend/src/App.tsx`)
- Web app routes → API client: requests
- API client → API server: HTTP calls
- API server → HTTP routing: configures (evidence: `cmd/server/main.go`)
- HTTP routing → User handlers: routes (evidence: `internal/server/router.go`)
- HTTP routing → Friend handlers: routes (evidence: `internal/server/router.go`)
- HTTP routing → HTTP middleware: installs (evidence: `internal/server/router.go`)
- HTTP routing → Health checks: routes (evidence: `internal/server/router.go`)
- User handlers → User service: calls (evidence: `internal/user/handler.go`)
- User handlers → Auth service: auth operations (evidence: `internal/user/handler.go`)
- User service → User repository: uses
- Auth service → Refresh tokens: rotates tokens
- Friend handlers → Friend service: calls (evidence: `internal/friend/handler.go`)
- Friend service → Friend repository: uses
- User repository → PostgreSQL: persists users
- Friend repository → PostgreSQL: persists friendships
- User service → Redis cache: cache integration
- API server → PostgreSQL: opens connection (evidence: `cmd/server/main.go`)
- API server → Schema migrations: checks schema (evidence: `cmd/server/main.go`)
- API server → gRPC server: starts service
- gRPC server → User service: serves user operations
- gRPC client → User protobuf: uses definitions (evidence: `internal/grpc/client/user_client.go`)
- RabbitMQ messaging → Event bus: publishes events
- Task manager → Scheduled tasks: registers tasks
- Health checks → PostgreSQL: checks database
- HTTP routing → Prometheus metrics: exposes metrics
