This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
PostMaker X is a pnpm monorepo for optimizing X (Twitter) posts based on algorithm research. It analyzes post content against engagement signals and provides AI-powered suggestions using Gemini.
# Install dependencies
pnpm install
# Typecheck all packages (run after implementation)
pnpm tc
# Build all packages
pnpm build
# Build shared package (required before other packages if types changed)
pnpm build:shared
# Run individual typechecks
pnpm tc:web
pnpm tc:api
# Database operations (PostgreSQL via Drizzle)
pnpm db:push # Push schema changes
pnpm db:studio # Open Drizzle Studiopostmaker-x/
├── apps/
│ ├── web/ # Vite + React + TailwindCSS frontend
│ └── api/ # Express + TypeScript backend
└── packages/
└── shared/ # Shared types, constants, algorithm weights
All shared types and constants live here. Both apps import from it:
types/- PostAnalysis, EngagementScores, ContentMetrics, Suggestion, Warning, Template, Timingconstants/weights.ts- Scoring weights based on X algorithm (ENGAGEMENT_WEIGHTS, CONTENT_WEIGHTS, OPTIMAL_LENGTH, LIMITS)constants/algorithm.ts- Algorithm constants
Important: Run pnpm build:shared after modifying shared package before other packages can use changes.
Express server on port 3001 with routes:
POST /api/analyze- Analyze post contentPOST /api/generate- Generate posts via Gemini AIGET /api/templates- Post templatesGET /api/timing/*- Posting time recommendations
Key services:
services/gemini/- Gemini AI integration (gemini-1.5-flash model)services/analyzer/- Post analysis against algorithm signalsservices/scorer.ts- Scoring calculationsservices/optimizer/- Post optimization suggestionsdb/schema.ts- Drizzle PostgreSQL schema (posts, analysisHistory, templates)
React SPA with pages:
/(Home) - Post analyzer/threads- Thread creator/timing- Timing optimizer/templates- Template library
State management:
@tanstack/react-queryfor server statezustandfor client state (stores/post.tswith localStorage persistence)
API client: lib/api.ts - typed fetch wrapper
UI components: Custom components in components/ui/ (no external component library)
- Frontend calls
api.analyze(content)via React Query hooks - API analyzes content against algorithm weights from
@postmaker/shared - Returns
PostAnalysiswith scores, metrics, suggestions, warnings - Frontend displays via Zustand store and UI components
API requires:
DATABASE_URL- PostgreSQL connection stringGEMINI_API_KEY- For AI features (optional, features degrade gracefully)