Monorepo for SG Cars Trends backend services
npx skills add https://github.com/sgcarstrends/sgcarstrends --skill api-testingInstale esta skill com a CLI e comece a usar o fluxo de trabalho SKILL.md em seu espaço de trabalho.
This monorepo provides a complete platform for SG Cars Trends, tracking Singapore's car registration statistics and Certificate of Entitlement (COE) data. The system includes:
/admin path. Also hosts the data updater workflows.graph TB
subgraph "Frontend & Workflows"
WEB[Web App<br/>Next.js 16]
BLOG[Blog Posts<br/>AI Generated]
WORKFLOWS[Data Workflows<br/>Vercel WDK]
LLM[Vercel AI SDK<br/>Blog Generation]
end
subgraph "Data Layer"
DB[(PostgreSQL<br/>Neon)]
REDIS[(Redis Cache<br/>Upstash)]
end
subgraph "External APIs"
LTA[LTA DataMall<br/>Gov Data]
end
subgraph "Social Platforms"
DISCORD[Discord]
LINKEDIN[LinkedIn]
TWITTER[Twitter]
TELEGRAM[Telegram]
end
subgraph "Infrastructure"
VERCEL[Vercel<br/>Edge Network]
end
WEB --> WORKFLOWS
WEB --> DB
WEB --> REDIS
WORKFLOWS --> LTA
WORKFLOWS --> DB
WORKFLOWS --> LLM
LLM --> BLOG
WORKFLOWS --> DISCORD
WORKFLOWS --> LINKEDIN
WORKFLOWS --> TWITTER
WORKFLOWS --> TELEGRAM
WEB --> VERCEL
classDef frontend fill:#e1f5fe
classDef backend fill:#f3e5f5
classDef data fill:#e8f5e8
classDef external fill:#fff3e0
classDef social fill:#fce4ec
classDef infra fill:#f1f8e9
class WEB,BLOG,WORKFLOWS,LLM frontend
class DB,REDIS data
class LTA external
class DISCORD,LINKEDIN,TWITTER,TELEGRAM social
class VERCEL infra
sgcarstrends/
├── apps/
│ ├── docs/ # Fumadocs documentation site (Next.js 16)
│ │ ├── content/ # MDX documentation files
│ │ ├── src/app/ # Next.js App Router with docs layout
│ │ └── src/lib/ # Fumadocs source adapter and shared config
│ ├── mcp/ # MCP server for blog post CRUD (published to npm)
│ │ └── src/ # TypeScript server implementation
│ ├── web/ # Next.js 16 frontend application with integrated workflows
│ │ ├── src/app/ # Next.js App Router pages and layouts
│ │ │ ├── (social)/ # Social media redirect routes with UTM tracking
│ │ │ ├── admin/ # Integrated admin interface for content management
│ │ │ ├── blog/ # Blog pages with AI-generated content
│ │ │ └── api/workflows/ # Vercel WDK workflow endpoints
│ │ ├── src/lib/workflows/ # Data updater workflows and social media integration
│ │ ├── src/queries/ # Data fetching queries (cars, COE, logos) with comprehensive tests
│ │ ├── src/actions/ # Server actions (maintenance tasks)
│ │ ├── src/components/ # React components with comprehensive tests
│ │ ├── src/utils/ # Web-specific utility functions
│ │ └── src/config/ # Database, Redis, and platform configurations
├── packages/
│ ├── ai/ # AI-powered blog generation package
│ │ ├── src/generate-post.ts # 2-step blog generation
│ │ ├── src/schemas.ts # Zod schemas for structured output
│ │ └── src/instrumentation.ts # Langfuse telemetry
│ ├── database/ # Database schema and migrations (Drizzle ORM)
│ │ ├── src/schema/ # Schema definitions for all tables
│ │ └── migrations/ # Database migration files
│ ├── logos/ # Car logo management with Vercel Blob storage
│ ├── types/ # Shared TypeScript types
│ ├── ui/ # Shared UI component library (shadcn/ui, Radix UI, Tailwind CSS)
│ │ ├── src/components/ # shadcn/ui components
│ │ ├── src/hooks/ # Custom React hooks
│ │ ├── src/lib/ # Utility functions
│ │ └── src/styles/ # Global styles
│ └── utils/ # Shared utility functions and Redis configuration
For developers working on this codebase, detailed component-specific guidance is available:
System architecture diagrams are available in the docs/ directory:
# Clone the repository
git clone https://github.com/sgcarstrends/sgcarstrends.git
cd sgcarstrends
# Install dependencies
pnpm install
This project uses pnpm catalog for centralised dependency version management. Shared dependencies (React, Next.js, TypeScript, testing tools, etc.) are defined in pnpm-workspace.yaml and referenced by workspace packages using the catalog: protocol.
Key catalog packages:
react (^19.2.3), react-dom (^19.2.3), next (^16.1.0)typescript (^5.8.3), @types/node (^22.16.4), @types/react (^19.2.0), @types/react-dom (^19.2.0)vitest (^4.0.15), @vitest/coverage-v8 (^4.0.15)ai (^6.0.1), @ai-sdk/google (^3.0.6), @langfuse/otel (^4.4.2)date-fns (^3.6.0), zod (^4.1.13), sonner (2.0.7)Root-level dependencies (not in catalog):
turbo (^2.6.3)@biomejs/biome (2.3.0), husky (^9.1.7), lint-staged (^16.1.5)semantic-release (^24.0.0)This ensures version consistency across all workspace packages and simplifies dependency upgrades.
# Development
pnpm dev # Run all development servers
pnpm dev:web # Web application only
cd apps/web && pnpm dev # Web application development
# Build
pnpm build # Build all applications
pnpm build:web # Build web application only
# Testing
pnpm test # Run all unit tests
pnpm test:watch # Run tests in watch mode
pnpm test:coverage # Run tests with coverage
pnpm test:web # Run web tests only
cd apps/web && pnpm test # Web tests only
# E2E Testing (Web App)
pnpm -F @sgcarstrends/web test:e2e # Run Playwright E2E tests
pnpm -F @sgcarstrends/web test:e2e:ui # Run E2E tests with Playwright UI
# Code Quality
pnpm lint # Run Biome linting on all packages
pnpm format # Run Biome formatting on all packages
pnpm lint:web # Lint web application only
cd apps/web && pnpm lint # Lint web application only
# Database
pnpm db:migrate # Run database migrations
pnpm db:migrate:check # Check migration status
pnpm db:generate # Generate new migrations
pnpm db:push # Push schema changes
pnpm db:drop # Drop database
Deployment is handled automatically by Vercel:
main branch triggers automatic deploymentWorkflow Endpoints (Vercel Cron Triggered):
GET /api/workflows/cars - Car data processing workflowGET /api/workflows/coe - COE data processing workflowGET /api/workflows/deregistrations - Vehicle deregistration processing workflow