How zagart47/rsssf works
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 Post operations · main.go Application entry · router.go Router · postgres/post.go Post queries
Components 15
Bootstrap
- Application entry · Composes runtime dependencies and starts the service.
cmd/rsssf/main.go - Configuration
config/config.go - Runtime config
config/config.json
HTTP transport
- Router · Maps HTTP requests to post service operations.
router/router.go - Middleware · Applies cross-cutting HTTP behavior.
router/middleware.go - Post updater · Exposes or triggers post-update behavior.
router/updater.go
Domain & service
- Post · Shared post data contract.
entity/post.go - Service composition
service/service.go - Post operations · Orchestrates post creation, retrieval, and updates.
service/post.go
Persistence
- Storage abstraction · Storage boundary consumed by services.
storage/storage.go - PostgreSQL adapter · Provides PostgreSQL implementation and connection management.
storage/postgres/postgresql.go - Post queries · Executes post-specific persistence queries.
storage/postgres/post.go
Database
- Posts migration
storage/postgres/migrations/000001_posts.up.sql - Database schema
schema.sql - PostgreSQL · Persists posts.
Connections 18
- 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