How cp-20/traqing works
Main system components
• Frontend (apps/client)
• Reverse proxy / static asset server (Caddy)
• Backend API server (apps/server)
• Shared database library (packages/database)
• Database (PostgreSQL)
• External traQ API (OAuth & message feed)
• Migration subsystem (drizzle folder)
• Orchestration layer (docker-compose)
Relationships & data flows
• Browser → HTTP(S) → Caddy
• Serves index.html and static JS/CSS from apps/client build
• Proxies /api/* to Backend API server
• Backend API server ↔ Database
• Queries & writes via Drizzle ORM (packages/database)
• Backend API server ↔ External traQ API
• OAuth handshake (TRAQ_AUTH_CLIENT_ID)
• Bot token pulls historical messages & stamps (TRAQ_TOKEN)
• extractor.ts component runs background jobs to sync data
• Migration subsystem applies SQL migrations to PostgreSQL on startup
• docker‑compose wires up containers: caddy, client, server, postgres
Architectural layers & patterns
• Monorepo with Yarn/Bun workspaces
• Client: React + Vite + TypeScript + Tailwind CSS
• API server: Node.js + TypeScript, tsup build, functional layering
• gateway.ts for HTTP routes
• auth.ts for OAuth
• extractor.ts for background sync jobs
• cache.ts for in‑memory caching
• Database access layer extracted into a separate package (packages/database)
• Migration driven by Drizzle (zero‑down‑time SQL migrations)
Technologies & frameworks
• Frontend: React, Vite, Tailwind, PostCSS
• Backend: Node.js, tsup, Express‑style gateway (or any HTTP framework you see in gateway.ts)
• DB client: Drizzle ORM, PostgreSQL
• Reverse proxy: Caddy
• Containerization: Docker, docker‑compose
• CI/CD: GitHub Actions (.github/workflows)