# boyeep/nextjs-go-monorepo-kit architecture

> Architecture diagram of the GitHub repository boyeep/nextjs-go-monorepo-kit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/boyeep/nextjs-go-monorepo-kit
- Repository: https://github.com/boyeep/nextjs-go-monorepo-kit

## Overview

This is a Next.js/Go/PostgreSQL full-stack starter. The principal workflow is a user registering or signing in through the frontend, completing email verification when required, and accessing a protected dashboard; the Go API validates requests and persists account state. A separate owner-only analytics endpoint fetches Plausible metrics. The graph retains the documented landing and auth capabilities, but source excerpts do not show every frontend route or backend handler, so those links rely on README statements or are omitted where wiring is uncertain.

Main entry points: [`backend/internal/server/router.go`](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/server/router.go) (HTTP router), [`backend/internal/handler/http/auth_handler.go`](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/handler/http/auth_handler.go) (Auth endpoints), [`backend/internal/service/auth_service.go`](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/service/auth_service.go) (Auth rules), [`backend/internal/service/analytics_service.go`](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/service/analytics_service.go) (Analytics query)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Next.js frontend"]
  node_landing["Landing pages"]
  node_auth_ui["Auth flows"]
  node_auth_client["Auth API client<br/>[auth-service.ts]"]
  node_dashboard_ui["Dashboard"]
  node_api_client["HTTP client<br/>[api.ts]"]
end

subgraph group_api["Go API"]
  node_router["HTTP router<br/>[router.go]"]
  node_auth_handler["Auth endpoints<br/>[auth_handler.go]"]
  node_analytics_handler["Analytics endpoint"]
  node_health_handler["Health endpoint<br/>[health_handler.go]"]
  node_auth_service["Auth rules<br/>[auth_service.go]"]
  node_analytics_service["Analytics query"]
  node_health_service["Health check<br/>[health_service.go]"]
  node_domain["Domain models<br/>[models.go]"]
  node_config["Runtime config<br/>[config.go]"]
end

subgraph group_persistence["Persistence"]
  node_user_repo["User repository<br/>[user_repository.go]"]
  node_db_setup["Database setup<br/>[db.go]"]
  node_migrations["Schema migrations<br/>[migrations.go]"]
  node_demo_seed["Demo account seed<br/>[demo_seed.go]"]
end

subgraph group_operations["External services"]
  node_postgres[("PostgreSQL")]
  node_plausible["Plausible"]
  node_mail["Email delivery"]
end

node_visitor(("User"))

node_visitor -->|"browses"| node_landing
node_visitor -->|"registers or signs in"| node_auth_ui
node_visitor -->|"opens protected area"| node_dashboard_ui
node_auth_ui -->|"requests auth"| node_auth_client
node_auth_client -.->|"sends requests"| node_api_client
node_api_client -.->|"calls API"| node_router
node_router -->|"routes auth"| node_auth_handler
node_router -->|"routes analytics"| node_analytics_handler
node_router -->|"routes health"| node_health_handler
node_auth_handler -->|"delegates auth"| node_auth_service
node_health_handler -->|"requests status"| node_health_service
node_auth_service -->|"reads and writes users"| node_user_repo
node_user_repo -->|"queries account data"| node_postgres
node_health_service -->|"pings database"| node_postgres
node_analytics_handler -.->|"requests overview"| node_analytics_service
node_analytics_service -->|"queries metrics"| node_plausible
node_auth_service -->|"sends verification and reset mail"| node_mail
node_db_setup -.->|"opens pool"| node_postgres
node_migrations -.->|"updates schema"| node_postgres
node_demo_seed -->|"seeds demo account"| node_postgres
node_auth_handler -->|"decodes auth inputs"| node_domain
node_analytics_service -->|"returns overview"| node_domain

click node_landing "https://github.com/boyeep/nextjs-go-monorepo-kit/tree/main/frontend/src/features/home"
click node_auth_ui "https://github.com/boyeep/nextjs-go-monorepo-kit/tree/main/frontend/src/features/auth"
click node_auth_client "https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/frontend/src/features/auth/services/auth-service.ts"
click node_dashboard_ui "https://github.com/boyeep/nextjs-go-monorepo-kit/tree/main/frontend/src/features/dashboard"
click node_api_client "https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/frontend/src/lib/api.ts"
click node_router "https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/server/router.go"
click node_auth_handler "https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/handler/http/auth_handler.go"
click node_analytics_handler "https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/handler/http/analytics_handler.go"
click node_health_handler "https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/handler/http/health_handler.go"
click node_auth_service "https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/service/auth_service.go"
click node_analytics_service "https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/service/analytics_service.go"
click node_health_service "https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/service/health_service.go"
click node_domain "https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/domain/models.go"
click node_config "https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/config/config.go"
click node_user_repo "https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/repository/user_repository.go"
click node_db_setup "https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/repository/db.go"
click node_migrations "https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/repository/migrations.go"
click node_demo_seed "https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/repository/demo_seed.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_landing,node_auth_ui,node_auth_client,node_dashboard_ui,node_api_client,node_visitor toneBlue
class node_router,node_auth_handler,node_analytics_handler,node_health_handler,node_auth_service,node_analytics_service,node_health_service,node_domain,node_config toneAmber
class node_user_repo,node_db_setup,node_migrations,node_demo_seed toneMint
class node_postgres,node_plausible,node_mail toneRose
```

## Components

### Next.js frontend

- [Landing pages](https://github.com/boyeep/nextjs-go-monorepo-kit/tree/main/frontend/src/features/home): `frontend/src/features/home`
- [Auth flows](https://github.com/boyeep/nextjs-go-monorepo-kit/tree/main/frontend/src/features/auth): `frontend/src/features/auth`
- [Auth API client](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/frontend/src/features/auth/services/auth-service.ts): `frontend/src/features/auth/services/auth-service.ts`
- [Dashboard](https://github.com/boyeep/nextjs-go-monorepo-kit/tree/main/frontend/src/features/dashboard): `frontend/src/features/dashboard`
- [HTTP client](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### Go API

- [HTTP router](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/server/router.go): `backend/internal/server/router.go`
- [Auth endpoints](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/handler/http/auth_handler.go): `backend/internal/handler/http/auth_handler.go`
- [Analytics endpoint](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/handler/http/analytics_handler.go): `backend/internal/handler/http/analytics_handler.go`
- [Health endpoint](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/handler/http/health_handler.go): `backend/internal/handler/http/health_handler.go`
- [Auth rules](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/service/auth_service.go): `backend/internal/service/auth_service.go`
- [Analytics query](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/service/analytics_service.go): `backend/internal/service/analytics_service.go`
- [Health check](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/service/health_service.go): `backend/internal/service/health_service.go`
- [Domain models](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/domain/models.go): `backend/internal/domain/models.go`
- [Runtime config](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/config/config.go): `backend/internal/config/config.go`

### Persistence

- [User repository](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/repository/user_repository.go): `backend/internal/repository/user_repository.go`
- [Database setup](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/repository/db.go): `backend/internal/repository/db.go`
- [Schema migrations](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/repository/migrations.go): `backend/internal/repository/migrations.go`
- [Demo account seed](https://github.com/boyeep/nextjs-go-monorepo-kit/blob/main/backend/internal/repository/demo_seed.go): `backend/internal/repository/demo_seed.go`

### External services

- **PostgreSQL**
- **Plausible**
- **Email delivery**

### Other components

- **User**

## Connections

- User → Landing pages: browses (evidence: `README.md`)
- User → Auth flows: registers or signs in (evidence: `README.md`)
- User → Dashboard: opens protected area (evidence: `README.md`)
- Auth flows → Auth API client: requests auth (evidence: `frontend/src/features/auth/components/verify-email-page-client.tsx`)
- Auth API client → HTTP client: sends requests
- HTTP client → HTTP router: calls API
- HTTP router → Auth endpoints: routes auth (evidence: `backend/internal/server/router.go`)
- HTTP router → Analytics endpoint: routes analytics (evidence: `backend/internal/server/router.go`)
- HTTP router → Health endpoint: routes health (evidence: `backend/internal/server/router.go`)
- Auth endpoints → Auth rules: delegates auth (evidence: `backend/internal/handler/http/auth_handler.go`)
- Health endpoint → Health check: requests status (evidence: `backend/internal/handler/http/health_handler.go`)
- Auth rules → User repository: reads and writes users (evidence: `backend/internal/service/auth_service.go`)
- User repository → PostgreSQL: queries account data (evidence: `backend/internal/repository/user_repository.go`)
- Health check → PostgreSQL: pings database (evidence: `backend/internal/service/health_service.go`)
- Analytics endpoint → Analytics query: requests overview
- Analytics query → Plausible: queries metrics (evidence: `backend/internal/service/analytics_service.go`)
- Auth rules → Email delivery: sends verification and reset mail (evidence: `backend/internal/service/auth_service.go`)
- Database setup → PostgreSQL: opens pool
- Schema migrations → PostgreSQL: updates schema
- Demo account seed → PostgreSQL: seeds demo account (evidence: `backend/internal/repository/demo_seed.go`)
- Auth endpoints → Domain models: decodes auth inputs (evidence: `backend/internal/handler/http/auth_handler.go`)
- Analytics query → Domain models: returns overview (evidence: `backend/internal/service/analytics_service.go`)
