This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Environment-specific development:
npm run start:local- Run bot in local development mode with auto-restartnpm run start:staging- Run bot in staging environmentnpm run start:production- Run bot in production environmentnpm run build- Compile TypeScript to JavaScriptnpm run sync- Run synchronization script
Database operations:
npm run deploy:staging- Deploy Prisma migrations to staging databasenpm run pull:staging- Pull database schema from staging to update Prisma schemanpm run update-statuses- Run status update script (local)npm run update-statuses:staging- Run status update script on stagingnpm run update-format- Run format update script (local)npm run update-format:staging- Run format update script on staging
This is a Telegram bot built with Node.js, TypeScript, and Telegraf that manages a voting/vouching system for Twitter users. The bot operates as a community moderation tool.
Core Architecture:
- Telegraf Framework: Main bot framework handling Telegram API interactions
- Prisma ORM: Database access layer with PostgreSQL backend
- Command-based Architecture: Individual command handlers in
src/commands/ - Middleware System: Authentication and logging middleware
- Admin Access Control: Specific user IDs have admin privileges via ACL
Key Components:
src/index.ts- Main bot initialization and command registrationsrc/commands/- Individual command handlers (vouch, vote, settings, etc.)src/middleware/- Authentication and logging middlewaresrc/composers/adminComposer.ts- Admin-only command handlingsrc/utils.ts- Core utilities including Twitter profile image fetchingprisma/schema.prisma- Database schema defining Vote and Settings models
Database Schema:
- Vote model: Tracks vouch requests with upvoter/downvoter arrays, status, and metadata
- Settings model: Configurable thresholds for required up/down votes
- Uses PostgreSQL with Prisma migrations
Environment Configuration:
- Multi-environment support (local, staging, production)
- Environment-specific .env files (
.env.local,.env.staging) - Required:
BOT_TOKEN,DATABASE_URL,ALLOWED_GROUP_ID(production) - Development mode bypasses group restrictions
Authentication:
- Group-based access control - bot only responds in configured group
- Admin ACL with hardcoded user IDs for admin commands
- Development mode bypasses authentication
Key Features:
- Twitter username/URL parsing and validation
- Profile image fetching with error handling
- Inline keyboard voting system
- Message cleanup and management
- Status tracking (pending/approved/rejected)