How pawafulu7/techtrend works
Project Type and Purpose
• This is a full-stack “TechTrend” article aggregator: a Next.js 15 + React 18 frontend, Next.js API routes backend, Prisma-powered PostgreSQL database, Redis cache, and Google Gemini AI summarization. It ingests RSS/HTTP feeds, processes and caches content, generates AI summaries, and serves pages and APIs.
Main Components
a. Frontend
• Next.js pages (app/*, components/*)
• React UI components, Tailwind CSS styling
• NextAuth for authentication flows
b. Backend (Next.js API Routes)
• API endpoints under app/api/*
• Business logic libraries in lib/ (fetchers, enrichers, ai, services, cache, recommendation, rag, dataloader)
• Dependency Injection (lib/di)
• Scheduler & Workers (lib/workers) for background embedding jobs, summary regeneration, scheduled feeds
• CLI tools (lib/cli, scripts/)
c. Data Layer
• Prisma ORM → PostgreSQL (prisma/schema.prisma & migrations)
• Redis cache (lib/cache, lib/redis)
d. External Services
• Google Gemini API for AI summarization
• Various RSS and corporate blog endpoints (lib/fetchers, scripts/)
• Email/SMS via Nodemailer
• Observability via OpenTelemetry Collector, Loki, Tempo, Grafana
Relationships & Data Flows
• User’s browser ↔ Next.js front (SSR/CSR) → API routes
• API routes call business-logic layers:
• Fetchers → ingest new articles
• Enrichers → normalize content
• AI modules → call Gemini API
• Cache layer → Redis read/write
• Prisma → persistent read/write
• Background workers & scheduler trigger jobs via cron (e.g., feed collection, embedding)
• Observability agents collect traces/logs → OTEL Collector → Loki/Tempo → Grafana
Architectural Patterns
• Layered architecture: Presentation (frontend), API/Controller (Next.js routes), Service/Use-Case (lib/services, lib/ai, lib/recommendation), Data (Prisma, Redis)
• Hexagonal/DI: lib/di providers inject Prisma, Redis, scheduler into services
• Caching & Circuit-breaker: lib/cache modules implement layered and distributed caches
• Micro-task workers: lib/workers handle asynchronous jobs
Details
• Component names matching file tree: “app/api/articles”, “lib/ai/unified-summary-service”
• Data models via Prisma schema
• Background job queue (embedding-worker.ts)
• Deployment: Docker/Docker-Compose, Vercel, monitoring containers
• Environment variables boundary (env secret store)