# zagart47/rsssf architecture

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

- Interactive diagram: https://gitdiagram.com/zagart47/rsssf
- Repository: https://github.com/zagart47/rsssf

## Overview

#### Purpose and Entry Point
This is a Go service named `rsssf`, organized as an HTTP-facing post service backed by PostgreSQL. The executable starts at `cmd/rsssf/main.go`, which composes configuration, storage, service, and router layers.

#### Bootstrap and Configuration
Startup configuration is defined in `config/config.go` and supplied by `config/config.json`. The composition root in `cmd/rsssf/main.go` is the primary boundary where runtime dependencies should be initialized and injected.

#### HTTP Routing and Middleware
The transport layer is centered on `router/router.go`, with cross-cutting HTTP behavior in `router/middleware.go`. Route handlers delegate to the service layer rather than accessing persistence directly. `router/updater.go` is a distinct HTTP/control component, likely responsible for triggering or exposing post-update behavior.

#### Domain Model
`entity/post.go` defines the core `Post` domain entity shared across transport, business, and persistence layers. This is the principal data contract for post creation, retrieval, and update flows.

#### Service Layer
Business orchestration is implemented in `service/service.go` and `service/post.go`. This layer forms the boundary between HTTP handlers and storage: router code invokes service operations, and services use storage abstractions rather than PostgreSQL-specific calls.

#### Storage Abstraction and PostgreSQL Adapter
`storage/storage.go` defines the persistence-facing abstraction used by services. PostgreSQL implementation and connection management live in `storage/postgres/postgresql.go`, while post-specific queries are in `storage/postgres/post.go`. This isolates database details from the rest of the application and allows alternate storage implementations in principle.

#### Database Schema and Runtime Infrastructure
PostgreSQL is the material external dependency. Schema initialization is represented by `schema.sql` and the migration `storage/postgres/migrations/000001_posts.up.sql`. The expected primary flow is:

HTTP request → `router/router.go` / middleware → service post operations → storage interface → PostgreSQL post adapter → posts table/schema.

The inverse flow returns persisted `entity.Post` values through service and router layers to the caller.

Main entry points: [`service/post.go`](https://github.com/zagart47/rsssf/blob/master/service/post.go) (Post operations), [`cmd/rsssf/main.go`](https://github.com/zagart47/rsssf/blob/master/cmd/rsssf/main.go) (Application entry), [`router/router.go`](https://github.com/zagart47/rsssf/blob/master/router/router.go) (Router), [`storage/postgres/post.go`](https://github.com/zagart47/rsssf/blob/master/storage/postgres/post.go) (Post queries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bootstrap["Bootstrap"]
  node_main{{"Application entry<br/>Go executable<br/>[main.go]"}}
  node_config["Configuration<br/>Go config<br/>[config.go]"]
  node_config_file["Runtime config<br/>JSON config<br/>[config.json]"]
end

subgraph group_http["HTTP transport"]
  node_router["Router<br/>[router.go]"]
  node_middleware["Middleware<br/>[middleware.go]"]
  node_updater["Post updater<br/>HTTP control handler<br/>[updater.go]"]
end

subgraph group_domain["Domain &amp; service"]
  node_post_entity["Post<br/>Domain entity<br/>[post.go]"]
  node_service["Service composition<br/>Go service<br/>[service.go]"]
  node_post_service["Post operations<br/>Business service<br/>[post.go]"]
end

subgraph group_persistence["Persistence"]
  node_storage_interface["Storage abstraction<br/>Persistence interface<br/>[storage.go]"]
  node_postgres_connection[("PostgreSQL adapter<br/>PostgreSQL storage<br/>[postgresql.go]")]
  node_postgres_posts["Post queries<br/>PostgreSQL repository<br/>[post.go]"]
end

subgraph group_database["Database"]
  node_migration["Posts migration<br/>SQL migration"]
  node_schema["Database schema<br/>SQL schema<br/>[schema.sql]"]
  node_postgres_db[("PostgreSQL<br/>External database")]
end

node_config_file -->|"supplies"| node_config
node_main -->|"loads"| node_config
node_main -->|"initializes"| node_router
node_main -->|"injects"| node_service
node_main -->|"connects"| node_postgres_connection
node_middleware -->|"wraps"| node_router
node_router -->|"routes update control"| node_updater
node_router -->|"invokes"| node_post_service
node_updater -->|"triggers"| node_post_service
node_service -->|"provides"| node_post_service
node_post_service -->|"uses"| node_storage_interface
node_post_service -->|"reads and returns"| node_post_entity
node_storage_interface -.->|"implemented by"| node_postgres_connection
node_postgres_connection -->|"provides connection"| node_postgres_posts
node_postgres_posts -->|"maps"| node_post_entity
node_postgres_posts -->|"queries posts"| node_postgres_db
node_migration -->|"creates posts table"| node_postgres_db
node_schema -->|"defines schema"| node_postgres_db

click node_main "https://github.com/zagart47/rsssf/blob/master/cmd/rsssf/main.go"
click node_config "https://github.com/zagart47/rsssf/blob/master/config/config.go"
click node_config_file "https://github.com/zagart47/rsssf/blob/master/config/config.json"
click node_router "https://github.com/zagart47/rsssf/blob/master/router/router.go"
click node_middleware "https://github.com/zagart47/rsssf/blob/master/router/middleware.go"
click node_updater "https://github.com/zagart47/rsssf/blob/master/router/updater.go"
click node_post_entity "https://github.com/zagart47/rsssf/blob/master/entity/post.go"
click node_service "https://github.com/zagart47/rsssf/blob/master/service/service.go"
click node_post_service "https://github.com/zagart47/rsssf/blob/master/service/post.go"
click node_storage_interface "https://github.com/zagart47/rsssf/blob/master/storage/storage.go"
click node_postgres_connection "https://github.com/zagart47/rsssf/blob/master/storage/postgres/postgresql.go"
click node_postgres_posts "https://github.com/zagart47/rsssf/blob/master/storage/postgres/post.go"
click node_migration "https://github.com/zagart47/rsssf/blob/master/storage/postgres/migrations/000001_posts.up.sql"
click node_schema "https://github.com/zagart47/rsssf/blob/master/schema.sql"

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_main,node_config,node_config_file toneBlue
class node_router,node_middleware,node_updater toneAmber
class node_post_entity,node_service,node_post_service toneMint
class node_storage_interface,node_postgres_connection,node_postgres_posts toneRose
class node_migration,node_schema,node_postgres_db toneIndigo
```

## Components

### Bootstrap

- [Application entry](https://github.com/zagart47/rsssf/blob/master/cmd/rsssf/main.go): Go executable · Composes runtime dependencies and starts the service. · `cmd/rsssf/main.go`
- [Configuration](https://github.com/zagart47/rsssf/blob/master/config/config.go): Go config · `config/config.go`
- [Runtime config](https://github.com/zagart47/rsssf/blob/master/config/config.json): JSON config · `config/config.json`

### HTTP transport

- [Router](https://github.com/zagart47/rsssf/blob/master/router/router.go): HTTP router · Maps HTTP requests to post service operations. · `router/router.go`
- [Middleware](https://github.com/zagart47/rsssf/blob/master/router/middleware.go): HTTP middleware · Applies cross-cutting HTTP behavior. · `router/middleware.go`
- [Post updater](https://github.com/zagart47/rsssf/blob/master/router/updater.go): HTTP control handler · Exposes or triggers post-update behavior. · `router/updater.go`

### Domain & service

- [Post](https://github.com/zagart47/rsssf/blob/master/entity/post.go): Domain entity · Shared post data contract. · `entity/post.go`
- [Service composition](https://github.com/zagart47/rsssf/blob/master/service/service.go): Go service · `service/service.go`
- [Post operations](https://github.com/zagart47/rsssf/blob/master/service/post.go): Business service · Orchestrates post creation, retrieval, and updates. · `service/post.go`

### Persistence

- [Storage abstraction](https://github.com/zagart47/rsssf/blob/master/storage/storage.go): Persistence interface · Storage boundary consumed by services. · `storage/storage.go`
- [PostgreSQL adapter](https://github.com/zagart47/rsssf/blob/master/storage/postgres/postgresql.go): PostgreSQL storage · Provides PostgreSQL implementation and connection management. · `storage/postgres/postgresql.go`
- [Post queries](https://github.com/zagart47/rsssf/blob/master/storage/postgres/post.go): PostgreSQL repository · Executes post-specific persistence queries. · `storage/postgres/post.go`

### Database

- [Posts migration](https://github.com/zagart47/rsssf/blob/master/storage/postgres/migrations/000001_posts.up.sql): SQL migration · `storage/postgres/migrations/000001_posts.up.sql`
- [Database schema](https://github.com/zagart47/rsssf/blob/master/schema.sql): SQL schema · `schema.sql`
- **PostgreSQL**: External database · Persists posts.

## Connections

- Runtime config → Configuration: supplies
- Application entry → Configuration: loads
- Application entry → Router: initializes
- Application entry → Service composition: injects
- Application entry → PostgreSQL adapter: connects
- Middleware → Router: wraps
- Router → Post updater: routes update control
- Router → Post operations: invokes
- Post updater → Post operations: triggers
- Service composition → Post operations: provides
- Post operations → Storage abstraction: uses
- Post operations → Post: reads and returns
- Storage abstraction → PostgreSQL adapter: implemented by
- PostgreSQL adapter → Post queries: provides connection
- Post queries → Post: maps
- Post queries → PostgreSQL: queries posts
- Posts migration → PostgreSQL: creates posts table
- Database schema → PostgreSQL: defines schema
