How sharathdoes/daymark works
1. What this service is
- Daymark is a Go backend that converts RSS news feeds into category-based quizzes.
- The core loop is: ingest feeds → scrape full articles → persist them in Postgres → ask Groq to generate multiple-choice questions from recent articles.
2. Runtime entrypoints
- cmd/api/main.go is the main HTTP API process.
- cmd/workers/worker.go is a separate background process, and internal/scheduler/daily_quiz.go suggests scheduled quiz-related jobs.
- cmd/workers/createfeed.js is an auxiliary worker script, likely used for feed creation/automation outside the main Go API flow.
3. HTTP/API boundary
- The API is built with Gin and organized through internal/router/router.go.
- Each domain module exposes its own router, handler, service, and repository layer, so the main boundary is the HTTP handler layer versus internal business/data layers.
- Swagger docs are generated and served from docs/ for the public API contract.
4. Main domain modules
- category manages category CRUD and likely groups feed sources.
- feedSource manages RSS feed sources attached to categories.
- articles handles article persistence and retrieval.
- quiz generates quizzes and stores quiz results.
- user and subscribe support user identity and subscription-related flows.
5. Feed ingestion pipeline
- Feed sources are fetched by category, parsed with RSS tooling (internal/services/rss_service.go and pkg/utils/getarticles.go are likely involved).
- Feed items become article candidates, then the article page is scraped and cleaned by internal/services/scraper_service.go.
- Articles are deduplicated by URL and written into Postgres through the article repository.
6. Quiz generation pipeline
- Quiz requests gather recent articles for a category.
- internal/services/llm_service.go sends a structured prompt to Groq to generate grounded multiple-choice questions.
- The quiz API returns the generated quiz immediately rather than relying on precomputed quiz caches.
7. Persistence model
- Postgres is the primary data store, accessed through GORM (pkg/database/postgres.go).
- The model layer includes article, category, feed, quiz, subscriber, user, and user_quiz_result, which maps directly to the main business entities.
- The database is the durable source of truth for feeds, scraped content, quiz records, and user-related state.
8. Cross-cutting auth and request utilities
- pkg/utils/jwt.go, password.go, and middleware.go indicate JWT-based auth and protected routes.
- helpers.go, getarticles.go, and related utilities support shared request/data handling across modules.
- This shared package layer keeps auth, hashing, and request middleware out of the feature modules.
9. Background and scheduled work
- The presence of internal/scheduler/daily_quiz.go and a worker entrypoint indicates some logic runs outside request/response handling.
- This likely covers recurring quiz generation or feed maintenance so the API can stay responsive.
- The architecture therefore has both synchronous API flows and asynchronous/background jobs.
10. Tooling and external dependencies
- External services that materially shape the architecture are PostgreSQL for storage and Groq for LLM quiz generation.
- RSS parsing depends on feed ingestion libraries, and article extraction depends on scraper logic rather than trusting feed summaries alone.
- docs/swagger.yaml/json and swaggo make the API contract part of the repo, which helps keep the HTTP surface explicit.
Main entry points: router.go Router · quiz_router.go Quizzes · postgres.go Postgres · feed_router.go Feed sources
Components 18
Runtime
Executable entrypoints and scheduled/background work
- API main · Starts the Gin HTTP API process
cmd/api/main.go - Worker main · Background worker process
cmd/workers/worker.go - Create feed · Auxiliary automation script
cmd/workers/createfeed.js - Daily quiz · Scheduled quiz-related background job
internal/scheduler/daily_quiz.go
HTTP API
Request routing and domain handlers
- Router · Wires API routes and middleware
internal/router/router.go - Swagger docs · Generated OpenAPI documentation
docs/swagger.yaml
Domain modules
Feature areas with service/repository boundaries
- Categories · Category CRUD and grouping of feed sources
internal/modules/category/catergory_router.go - Feed sources · RSS feed source management
internal/modules/feedSource/feed_router.go - Articles · Article ingestion and retrieval
internal/modules/articles/article_router.go - Quizzes · Quiz generation and quiz result flows
internal/modules/quiz/quiz_router.go - Users · User identity and account flows
internal/modules/user/user_router.go - Subscriptions · Subscription-related user flows
internal/modules/subscribe/subscribe_router.go
Shared infra
Cross-cutting services, utilities, and persistence
- RSS service · Fetches and parses RSS feeds
internal/services/rss_service.go - Scraper · Fetches and cleans full article pages
internal/services/scraper_service.go - LLM service · Builds prompts and calls Groq for questions
internal/services/llm_service.go - JWT auth · Token auth and protected-route middleware
pkg/utils/jwt.go
External systems
Third-party services and durable stores
- Postgres · Primary durable store via GORM
pkg/database/postgres.go - Groq · Generates quiz questions from recent articles
Connections 23
- API main → Router: bootstraps · Starts the HTTP server and mounts routes
- Router → Swagger docs: serves · Exposes generated API documentation
- Router → Categories: routes to · Dispatches category requests
- Router → Feed sources: routes to · Dispatches feed source requests
- Router → Articles: routes to · Dispatches article requests
- Router → Quizzes: routes to · Dispatches quiz requests
- Router → Users: routes to · Dispatches user requests
- Router → Subscriptions: routes to · Dispatches subscription requests
- Router → JWT auth: protects · Applies auth middleware to guarded routes
- Feed sources → RSS service: ingests via · Fetches and parses feed content
- Feed sources → Postgres: persists · Stores feed source records
- RSS service → Scraper: hands off to · Parsed items may be expanded into full articles
- Scraper → Articles: feeds · Supplies cleaned article content for storage
- Articles → Postgres: reads/writes · Stores and retrieves articles
- Quizzes → LLM service: generates via · Creates quizzes from recent articles
- Quizzes → Articles: reads recent · Pulls article context for quiz generation
- LLM service → Groq: calls · Sends structured prompts to Groq
- Quizzes → Postgres: persists · Stores quiz records and results
- Users → Postgres: persists · Stores user data
- Subscriptions → Postgres: persists · Stores subscriber state
- Daily quiz → Quizzes: triggers · Runs recurring quiz-related jobs
- Worker main → Daily quiz: runs · Worker process executes scheduled background logic
- Create feed → Feed sources: automation · Auxiliary feed-creation workflow