How tsukunea1/git_feed works
Project Type and Purpose
• This is a full-stack, API-driven web application (“GitFeed”) that aggregates GitHub events and provides a Twitter-like feed for software engineers.
• The frontend is a Next.js + TypeScript + Tailwind UI app.
• The backend is a Ruby on Rails (API mode) monolith exposing a JSON REST API, persisting to PostgreSQL, and running scheduled background jobs to fetch GitHub events.
High-Level Architecture Components
A. Frontend (Next.js App)
• Renders UI, handles routing (App Router), state (Zustand), styling (Tailwind + shadcn/ui).
• Communicates with Backend API via HTTP (fetch/axios).
• Consumes OpenAPI-generated client (orval) to type-safe calls.
B. Backend API (Rails)
• Controllers → Services → Models (ActiveRecord)
• Auth layer: GitHub OAuth → JWT issuance (jwt_service.rb), stored in Redis/cookies.
• Background jobs (ActiveJob) for GitHub event fetching:
– Scheduler (cron or Taskfile) enqueues fetch jobs
– Job workers dequeue and call GitHub REST API (with ETag / If-Modified-Since)
– Upsert into github_events, tag assignment, update cursor
• Exposes REST endpoints (e.g., /api/v1/languages, /api/v1/user_tag_prefs)
• Uses PostgreSQL for data and possibly Redis/Sidekiq or DelayedJob for queueing (config/queue.yml)
C. Data Stores
• PostgreSQL: users, posts/likes/follows, subscriptions, events, tags, preferences.
• (Optional) Redis: queue adapter for background jobs & caching.
D. External Services
• GitHub REST API: fetch events & OAuth.
• (Planned) OpenAI GPT-3.5: profile analysis, AI chat.
Relationships & Data Flows
• User → Frontend (browser)
• Frontend → Backend API (request/response JSON)
• Backend → PostgreSQL (read/write)
• Backend Scheduler → Job Queue → GitHub API → Backend → Database
• (Future) Backend → OpenAI API → Database → Frontend
Architectural Patterns & Design Principles
• API-First: OpenAPI schema in schema/openapi.yaml generates client/server stubs.
• MVC on the backend, with a clear service-layer for business logic (e.g., EventFetcher, RepositorySearcher).
• Single-Page/Server-Rendered Hybrid on the frontend (Next.js App Router).
• Containerization: Dockerfile in each service + docker-compose.yml for local orchestration.
• CI/CD: GitHub Actions workflows for frontend, backend, and full pipeline.
• Task runner (Taskfile.yml) unifies local dev, linting, formatting, and hooks.
Must-Include
• Annotations for major technologies (Next.js, Rails, PostgreSQL, Sidekiq/ActiveJob, GitHub API, OpenAI).