How gnshx/codepulse works
Purpose and Runtime
CodePulse is a modular-monolith competitive-programming intelligence platform: it ingests linked coding-platform activity, persists normalized history, computes learner analytics, and serves dashboards, recommendations, roadmaps, goals, and AI coaching. It runs as a Next.js 16 / React 19 TypeScript application, with background work delegated to Inngest.
Primary UI entry points are src/app/page.tsx, dashboard routes under src/app/dashboard/, and the root layout src/app/layout.tsx.
Application Boundary: App Router
The Next.js App Router provides server-rendered pages, route handlers, and server actions. Dashboard pages consume domain services rather than provider APIs directly; user-facing mutation/auth flows enter through actions and API endpoints.
Key boundaries:
• UI/dashboard: src/app/dashboard/layout.tsx, src/app/dashboard/page.tsx
• API endpoints: src/app/api/analytics/route.ts, src/app/api/user/profile/route.ts
• Auth actions: src/app/actions/auth.ts, src/app/login/actions.ts
Authentication and Identity
Auth.js supports credentials plus Google and GitHub OAuth. Authentication configuration, password handling, and input validation are isolated from UI and other domains.
Core paths: src/modules/auth/config.ts, src/modules/auth/password.ts, src/app/api/auth/[...nextauth]/route.ts.
Persistence and Read Performance
PostgreSQL is the source of truth, accessed through Prisma. The relational schema separates user/profile/platform activity from derived analytics, goals, achievements, and refresh history; migrations establish the durable contract. Redis is an optional fail-open read-through cache, not a correctness dependency.
Core paths: prisma/schema.prisma, prisma/migrations/0_init/migration.sql, src/shared/db/client.ts, src/shared/cache/redis.ts.
Platform Ingestion and Background Orchestration
Platform-specific adapters isolate external response formats for LeetCode and Codeforces. Synchronization is initiated asynchronously and processed by Inngest, preventing slow or unreliable provider calls from blocking requests. The job can coordinate provider work, normalization, persistence, and recomputation, with retries/concurrency controls supplied by Inngest.
Core paths: src/modules/sync/service.ts, src/modules/leetcode/service.ts, src/modules/codeforces/service.ts, src/jobs/platform-refresh.ts, src/app/api/inngest/route.ts.
Analytics and Derived Intelligence
Raw submissions are transformed into persisted learner signals: solved and attempted activity, acceptance rate, difficulty distribution, topic mastery, trends, and streaks. This persisted read model is the boundary between ingestion and consumers, keeping dashboard reads and downstream personalization efficient.
Core paths: src/modules/analytics/service.ts, src/modules/learning/live-analytics.ts, src/app/api/analytics/route.ts.
Personalization Consumers
Recommendation, learning/roadmap, goals, and AI modules consume analytics rather than provider-specific data. The AI service uses OpenAI when configured and falls back to deterministic analytics-based guidance, preserving core coaching behavior during provider failure.
Core paths: src/modules/recommendations/service.ts, src/modules/goals/service.ts, src/modules/ai/service.ts, src/app/dashboard/roadmap/page.tsx, src/app/dashboard/ai-coach/page.tsx.
External Infrastructure
Material integrations are PostgreSQL via Prisma, Upstash Redis, Inngest event/job infrastructure, LeetCode and Codeforces APIs, Auth.js OAuth providers, and optional OpenAI. Deployment is intended for Vercel; runtime configuration is represented by prisma.config.ts and Next.js configuration in next.config.ts.
Main entry points: analytics/service.ts Analytics read model · page.tsx Dashboard pages · sync/service.ts Sync coordinator · client.ts Prisma data access
Components 21
Next.js application
- Root UI and layout
src/app/layout.tsx - Dashboard pages · Dashboard reads domain services instead of platform APIs.
src/app/dashboard/page.tsx - Auth actions and route
src/app/actions/auth.ts - Analytics API
src/app/api/analytics/route.ts - Inngest endpoint
src/app/api/inngest/route.ts
Domain services
- Auth and identity · Credentials, OAuth, password handling, and validation boundary.
src/modules/auth/config.ts - Analytics read model · Persists learner signals for efficient downstream reads.
src/modules/analytics/service.ts - Recommendations
src/modules/recommendations/service.ts - Goals
src/modules/goals/service.ts - AI coaching · Falls back to deterministic analytics-based guidance.
src/modules/ai/service.ts
Platform ingestion
- Sync coordinator · Coordinates provider work, normalization, persistence, and recomputation.
src/modules/sync/service.ts - Platform refresh job · Runs sync asynchronously with retries and concurrency controls.
src/jobs/platform-refresh.ts - LeetCode adapter
src/modules/leetcode/service.ts - Codeforces adapter
src/modules/codeforces/service.ts
Data and infrastructure
- Prisma data access
src/shared/db/client.ts - PostgreSQL · Stores normalized activity and derived learner data.
prisma/schema.prisma - Redis cache · Optional read-through cache, not a correctness dependency.
src/shared/cache/redis.ts
External services
- Inngest
- Coding platform APIs · LeetCode and Codeforces activity sources.
- Google and GitHub OAuth
- OpenAI
Connections 25
- Root UI and layout → Dashboard pages: renders
- Dashboard pages → Analytics read model: reads signals
- Dashboard pages → Recommendations: gets guidance
- Dashboard pages → Goals: manages
- Dashboard pages → AI coaching: coaching
- Auth actions and route → Auth and identity: authenticates
- Auth and identity → Google and GitHub OAuth: OAuth
- Auth and identity → Prisma data access: identity data
- Analytics API → Analytics read model: serves
- Inngest endpoint → Inngest: receives events
- Inngest → Platform refresh job: executes
- Platform refresh job → Sync coordinator: runs
- Sync coordinator → LeetCode adapter: fetches
- Sync coordinator → Codeforces adapter: fetches
- LeetCode adapter → Coding platform APIs: LeetCode
- Codeforces adapter → Coding platform APIs: Codeforces
- Sync coordinator → Prisma data access: normalizes and persists
- Sync coordinator → Analytics read model: recomputes
- Analytics read model → Prisma data access: stores read model
- Prisma data access → PostgreSQL: reads and writes
- Analytics read model → Redis cache: caches reads
- Recommendations → Analytics read model: consumes
- Goals → Analytics read model: consumes
- AI coaching → Analytics read model: consumes
- AI coaching → OpenAI: optional generation