# turahe/blog-api architecture

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

- Interactive diagram: https://gitdiagram.com/turahe/blog-api
- Repository: https://github.com/turahe/blog-api

## Overview

This is a contracts-first Go REST backend for a multi-role blog platform. The principal workflow is a client request routed through HTTP middleware and domain handlers into a core service, which validates domain rules and uses persistence or external adapters; responses return through the HTTP layer. Major branches include identity and RBAC, content and media, comments, privacy-conscious analytics, audit/activity, and newsletter/notification delivery. The README documents capabilities beyond the sampled implementation; those branches are represented at their supported module paths, without assuming uninspected call wiring.

Main entry points: [`internal/adapters/inbound/http/handlers`](https://github.com/turahe/blog-api/tree/main/internal/adapters/inbound/http/handlers) (HTTP Handlers), [`internal/adapters/outbound/outbox/relay.go`](https://github.com/turahe/blog-api/blob/main/internal/adapters/outbound/outbox/relay.go) (Outbox Relay), [`internal/adapters/inbound/http/router.go`](https://github.com/turahe/blog-api/blob/main/internal/adapters/inbound/http/router.go) (HTTP Router), [`internal/adapters/outbound/persistence`](https://github.com/turahe/blog-api/tree/main/internal/adapters/outbound/persistence) (Repositories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_router["HTTP Router<br/>[router.go]"]
  node_handlers["HTTP Handlers"]
  node_routes["Route Registration"]
end

subgraph group_identity["Identity Governance"]
  node_auth["Authentication"]
  node_users["User Profiles"]
  node_roles["RBAC"]
  node_impersonation["Impersonation"]
end

subgraph group_content["Content Community"]
  node_posts["Posts Revisions SEO"]
  node_taxonomy["Categories Tags"]
  node_comments["Comments Moderation"]
  node_media["Media Transforms"]
  node_newsletter["Newsletter"]
end

subgraph group_insights["Analytics Audit"]
  node_analytics["Analytics"]
  node_consent["Consent Privacy"]
  node_audit["Audit Activity"]
end

subgraph group_runtime["Runtime Integrations"]
  node_notifications["Notifications"]
  node_bootstrap["Application Wiring<br/>[app.go]"]
  node_persistence["Repositories"]
  node_database[("PostgreSQL")]
  node_storage["Object Storage<br/>[s3.go]"]
  node_events["Outbox Relay<br/>[relay.go]"]
  node_worker["Async Consumers<br/>[worker.go]"]
end

node_client(("API Client"))
node_broker["Message Broker"]

node_client -->|"sends requests"| node_router
node_router -->|"dispatches routes"| node_routes
node_routes -->|"registers handlers"| node_handlers
node_handlers -->|"invokes"| node_auth
node_handlers -->|"invokes"| node_users
node_handlers -->|"invokes"| node_roles
node_handlers -->|"invokes"| node_impersonation
node_handlers -->|"invokes"| node_posts
node_handlers -->|"invokes"| node_taxonomy
node_handlers -->|"invokes"| node_comments
node_handlers -->|"invokes"| node_media
node_handlers -->|"invokes"| node_newsletter
node_handlers -->|"invokes"| node_analytics
node_handlers -->|"invokes"| node_consent
node_handlers -->|"invokes"| node_audit
node_handlers -->|"invokes"| node_notifications
node_bootstrap -->|"builds server"| node_router
node_bootstrap -->|"wires services"| node_persistence
node_persistence -->|"reads and writes"| node_database
node_media -->|"stores originals"| node_storage
node_events -->|"reads outbox"| node_persistence
node_worker -->|"runs relay"| node_events
node_events -->|"publishes events"| node_broker
node_worker -->|"consumes messages"| node_broker

click node_router "https://github.com/turahe/blog-api/blob/main/internal/adapters/inbound/http/router.go"
click node_handlers "https://github.com/turahe/blog-api/tree/main/internal/adapters/inbound/http/handlers"
click node_routes "https://github.com/turahe/blog-api/tree/main/internal/adapters/inbound/routes"
click node_auth "https://github.com/turahe/blog-api/tree/main/internal/core/auth/service"
click node_users "https://github.com/turahe/blog-api/tree/main/internal/core/user/service"
click node_roles "https://github.com/turahe/blog-api/tree/main/internal/core/rbac/service"
click node_impersonation "https://github.com/turahe/blog-api/tree/main/internal/core/impersonation/service"
click node_posts "https://github.com/turahe/blog-api/tree/main/internal/core/post/service"
click node_taxonomy "https://github.com/turahe/blog-api/tree/main/internal/core/category/service"
click node_comments "https://github.com/turahe/blog-api/tree/main/internal/core/comment/service"
click node_media "https://github.com/turahe/blog-api/tree/main/internal/core/media/service"
click node_newsletter "https://github.com/turahe/blog-api/tree/main/internal/core/newsletter/service"
click node_analytics "https://github.com/turahe/blog-api/tree/main/internal/core/analytics/service"
click node_consent "https://github.com/turahe/blog-api/tree/main/internal/core/consent/service"
click node_audit "https://github.com/turahe/blog-api/tree/main/internal/core/audit/service"
click node_notifications "https://github.com/turahe/blog-api/tree/main/internal/core/notification/service"
click node_bootstrap "https://github.com/turahe/blog-api/blob/main/internal/bootstrap/app.go"
click node_persistence "https://github.com/turahe/blog-api/tree/main/internal/adapters/outbound/persistence"
click node_database "https://github.com/turahe/blog-api/tree/main/internal/platform/database"
click node_storage "https://github.com/turahe/blog-api/blob/main/internal/adapters/outbound/storage/s3.go"
click node_events "https://github.com/turahe/blog-api/blob/main/internal/adapters/outbound/outbox/relay.go"
click node_worker "https://github.com/turahe/blog-api/blob/main/cmd/worker.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_router,node_handlers,node_routes,node_client toneBlue
class node_auth,node_users,node_roles,node_impersonation toneAmber
class node_posts,node_taxonomy,node_comments,node_media,node_newsletter toneMint
class node_analytics,node_consent,node_audit toneRose
class node_notifications,node_bootstrap,node_persistence,node_database,node_storage,node_events,node_worker,node_broker toneIndigo
```

## Components

### HTTP API

- [HTTP Router](https://github.com/turahe/blog-api/blob/main/internal/adapters/inbound/http/router.go): `internal/adapters/inbound/http/router.go`
- [HTTP Handlers](https://github.com/turahe/blog-api/tree/main/internal/adapters/inbound/http/handlers): `internal/adapters/inbound/http/handlers`
- [Route Registration](https://github.com/turahe/blog-api/tree/main/internal/adapters/inbound/routes): `internal/adapters/inbound/routes`

### Identity Governance

- [Authentication](https://github.com/turahe/blog-api/tree/main/internal/core/auth/service): `internal/core/auth/service`
- [User Profiles](https://github.com/turahe/blog-api/tree/main/internal/core/user/service): `internal/core/user/service`
- [RBAC](https://github.com/turahe/blog-api/tree/main/internal/core/rbac/service): `internal/core/rbac/service`
- [Impersonation](https://github.com/turahe/blog-api/tree/main/internal/core/impersonation/service): `internal/core/impersonation/service`

### Content Community

- [Posts Revisions SEO](https://github.com/turahe/blog-api/tree/main/internal/core/post/service): `internal/core/post/service`
- [Categories Tags](https://github.com/turahe/blog-api/tree/main/internal/core/category/service): `internal/core/category/service`
- [Comments Moderation](https://github.com/turahe/blog-api/tree/main/internal/core/comment/service): `internal/core/comment/service`
- [Media Transforms](https://github.com/turahe/blog-api/tree/main/internal/core/media/service): `internal/core/media/service`
- [Newsletter](https://github.com/turahe/blog-api/tree/main/internal/core/newsletter/service): `internal/core/newsletter/service`

### Analytics Audit

- [Analytics](https://github.com/turahe/blog-api/tree/main/internal/core/analytics/service): `internal/core/analytics/service`
- [Consent Privacy](https://github.com/turahe/blog-api/tree/main/internal/core/consent/service): `internal/core/consent/service`
- [Audit Activity](https://github.com/turahe/blog-api/tree/main/internal/core/audit/service): `internal/core/audit/service`

### Runtime Integrations

- [Notifications](https://github.com/turahe/blog-api/tree/main/internal/core/notification/service): `internal/core/notification/service`
- [Application Wiring](https://github.com/turahe/blog-api/blob/main/internal/bootstrap/app.go): `internal/bootstrap/app.go`
- [Repositories](https://github.com/turahe/blog-api/tree/main/internal/adapters/outbound/persistence): `internal/adapters/outbound/persistence`
- [PostgreSQL](https://github.com/turahe/blog-api/tree/main/internal/platform/database): `internal/platform/database`
- [Object Storage](https://github.com/turahe/blog-api/blob/main/internal/adapters/outbound/storage/s3.go): `internal/adapters/outbound/storage/s3.go`
- [Outbox Relay](https://github.com/turahe/blog-api/blob/main/internal/adapters/outbound/outbox/relay.go): `internal/adapters/outbound/outbox/relay.go`
- [Async Consumers](https://github.com/turahe/blog-api/blob/main/cmd/worker.go): `cmd/worker.go`

### Other components

- **API Client**
- **Message Broker**

## Connections

- API Client → HTTP Router: sends requests
- HTTP Router → Route Registration: dispatches routes
- Route Registration → HTTP Handlers: registers handlers
- HTTP Handlers → Authentication: invokes
- HTTP Handlers → User Profiles: invokes
- HTTP Handlers → RBAC: invokes
- HTTP Handlers → Impersonation: invokes
- HTTP Handlers → Posts Revisions SEO: invokes
- HTTP Handlers → Categories Tags: invokes
- HTTP Handlers → Comments Moderation: invokes
- HTTP Handlers → Media Transforms: invokes
- HTTP Handlers → Newsletter: invokes
- HTTP Handlers → Analytics: invokes
- HTTP Handlers → Consent Privacy: invokes
- HTTP Handlers → Audit Activity: invokes
- HTTP Handlers → Notifications: invokes
- Application Wiring → HTTP Router: builds server
- Application Wiring → Repositories: wires services
- Repositories → PostgreSQL: reads and writes
- Media Transforms → Object Storage: stores originals
- Outbox Relay → Repositories: reads outbox
- Async Consumers → Outbox Relay: runs relay
- Outbox Relay → Message Broker: publishes events
- Async Consumers → Message Broker: consumes messages
