How yukionishi1129/daily-api works
Project Type and Purpose
• Daily API V2 is a backend monolith that serves the content “feed” domain for the daily.dev extension. It exposes HTTP/GraphQL endpoints (Fastify + Apollo), runs background processors (workers and cron jobs), and persists data in PostgreSQL via TypeORM. It also integrates with external services (pub/sub, Slack, OneSignal, Customer.io, search, etc.).
High-Level Architectural Components
a. API Layer
• Fastify HTTP server (+ REST + GraphQL via Apollo)
• Route handlers (“src/routes”), GraphQL schemas/resolvers (“src/schema”), directives (“src/directive”)
b. Data Layer
• Primary PostgreSQL (TypeORM entities under “src/entity”, migrations under “src/migration”)
• Read replicas / caching layer (Redis pub/sub/cache clients in “src/common/redisCache” and pub/sub abstractions)
c. Background Processing
• Pub/Sub workers (“src/workers” + “src/notifications”, “src/temporal”)
• Cron Jobs (“src/cron” + binaries under “bin”)
• Temporal workflows / client (“src/temporal”)
d. Integrations / External Services
• Message brokers / pub-sub (Google Pub/Sub, or typedPubsub)
• Third-party APIs: Slack, Customer.io, OneSignal, Meilisearch, Snotra, Garmr, etc.
• File/CDN (Cloudinary)
e. Infrastructure & Deployment
• Docker Compose (local: “docker-compose.yml”)
• Kubernetes via Helm chart (“helm” folder)
• Pulumi IaC (“infra” folder)
• CI/CD (CircleCI config, Tiltfile for local microservice orchestration)
Relationships & Data Flows
1. Client (Browser extension, other consumers) → HTTP/GraphQL → Fastify
2. Fastify routes/Apollo resolvers → TypeORM → PostgreSQL primary (reads/writes)
3. Read traffic can be served via read-replica or Redis cache where configured
4. Mutations/triggers → publish events to Pub/Sub
5. Worker processes consume Pub/Sub → execute domain logic (notifications, digests, image processing) → write back to DB or send push/Slack notifications
6. Cron scheduler triggers scheduled tasks (daily digest, tag updates) → perform DB reads/writes + publish events
7. Temporal workflows orchestrate long-running processes (e.g., notifications, retries)
8. External integrations are called both synchronously (e.g., Slack when a notification is created) and asynchronously via workers or Temporal
Architectural Patterns & Principles
• Single-responsibility: separate web server, cron jobs, and background workers
• Event-driven: Pub/Sub to decouple producer (API, cron) from consumer (workers)
• Hexagonal-ish / layered: HTTP layer → service layer (“src/common/*”) → persistence layer (TypeORM)
• CQRS flavor: GraphQL queries vs. mutation events feeding workers
• Infrastructure as code: Pulumi + Helm for reproducible deployment
• Technologies: Fastify, Apollo, TypeORM, PostgreSQL, Redis, Google Pub/Sub, Temporal, Pulumi, Helm, CircleCI