How carlosetorresm/rss_aggregator_expl works
Project type and purpose
• This is a Go‐based backend service (“RSS Aggregator Example”) that exposes an HTTP API to manage users, subscribe to RSS feeds, fetch and scrape feed items, and persist them in a PostgreSQL database.
• It's intended to run in Docker (via docker-compose.yaml), with migrations managed by Goose and SQL queries generated by SQLC.
File structure
• At the root:
• main.go – application entrypoint (HTTP server setup).
• handler_*.go – HTTP handlers for users, feeds, follows, readiness, error handling.
• middleware_auth.go – JWT or API‐key auth middleware.
• scapper.go & rss.go – RSS fetching and parsing logic.
• json.go, models.go – shared models / DTOs.
• internal/auth, internal/database – core packages: auth logic, database connectivity, SQLC‐generated models and queries.
• sql/schema & sql/queries – raw SQL migrations and query templates.
• docker-compose.yaml, .env.template – container orchestration, environment config.
Extract architecture insights from the README
• Exposes REST endpoints to: create users, add/remove RSS sources, subscribe/unsubscribe, scrape content.
• Data is stored in PostgreSQL, which runs in Docker.
• Goose applies schema migrations; SQLC generates type‐safe query code.
Main components
a. HTTP/API Layer
• API Gateway / HTTP Router (Go’s net/http or a router like chi/mux if used).
• Authentication Middleware (API Key / JWT).
• Handler Modules (User, Feed, Follow, Readiness, Error).
b. Business Logic Layer
• RSS Scraper (scapper.go), Parser (rss.go).
• Service functions tying handlers to the database layer.
c. Data Access Layer
• internal/database – DB connection pool, SQLC‐generated query methods (feeds.sql.go, users.sql.go, etc.), migration management.
d. Database
• PostgreSQL container (defined in docker-compose.yaml).
• Schema versions (001–006 .sql files under sql/schema).
e. External Systems
• Third‐party RSS feed endpoints (HTTP).
f. Dev/Ops Artifacts
• Docker Compose (service definitions).
• Goose migrations.
• SQLC code generation.
Relationships and data flows
• Clients→HTTP Router→Auth Middleware→Handler→Business Logic→DB Layer→PostgreSQL.
• Scraper logic invoked either on‐demand via an endpoint or a background job → fetches RSS feed via HTTP → parses items → persists via SQLC queries.
• Handlers orchestrate calls to both the scraper and the DB layer.
Architectural patterns & design principles
• Layered Architecture: clear separation between HTTP handlers, business logic, and data access.
• Dependency Injection: pass DB clients and config from main.go into internal packages.
• Single Responsibility: each handler_*.go focuses on one resource.
• Infrastructure as Code: Docker Compose for the PostgreSQL service; Goose for migrations; SQLC for query codegen.