Skip to content

Getting Started

This guide will help you set up and run Catto v2.x locally for development.

Prerequisites

  • Node.js v20 or higher
  • pnpm v10+
  • Docker and Docker Compose (recommended)
  • Rust (optional, for watermark microservice)

Installation

1. Clone the Repository

bash
git clone https://github.com/cattxdev/catto.v2.git
cd catto

2. Install Dependencies

bash
pnpm install

3. Build Watermark Service (Optional)

For faster evidence image processing, build the Rust watermark microservice:

bash
cd services/watermark-rs
cargo build --release
cd ../..

If not built, the bot will use Sharp-based watermarking as a fallback.

4. Configure Environment

Copy the example environment file:

bash
cp .env.example .env

Fill in the required values:

VariableDescriptionRequired
DISCORD_TOKENYour Discord bot tokenYes
CLIENT_IDDiscord application client IDYes
CLIENT_SECRETDiscord application client secretYes
DATABASE_URLPostgreSQL connection stringYes
REDIS_HOSTRedis server hostYes
REDIS_PORTRedis server portYes
REDIS_PASSWORDRedis password (if any)No
REDIS_DBRedis database numberNo
OWNER_IDSComma-separated owner user IDsNo
DEFAULT_PREFIXDefault command prefixNo
API_PORTHTTP API port (default: 4000)No
API_PREFIXAPI route prefixNo
API_ORIGINOAuth2 origin URLNo
API_REDIRECTOAuth2 redirect URLNo
B2_ENDPOINTBackblaze B2 S3 endpoint (e.g. https://s3.us-west-004.backblazeb2.com)No
B2_REGIONB2 region (e.g. us-west-004)No
B2_KEY_IDB2 application key ID (not master key)No
B2_APP_KEYB2 application key secretNo
B2_BUCKET_NAMEB2 bucket nameNo
B2_BUCKET_IDB2 bucket IDNo
EVIDENCE_HMAC_SECRETSecret for evidence HMAC signing (min 32 chars)No
DASHBOARD_URLModerator dashboard URL (default: http://localhost:3000)No
WATERMARK_SERVICE_URLWatermark microservice URL (default: http://localhost:3847)No
WATERMARK_MAX_UPLOAD_SIZEMax watermark upload size (default: 1gb)No

Running the Bot

This starts temporary PostgreSQL and Redis instances in RAM:

bash
pnpm dev:env

The script will:

  • Start PostgreSQL and Redis containers
  • Update .env with ephemeral DATABASE_URL and REDIS_* values (dev-only)
  • Start the watermark microservice (if built)
  • Apply migrations and seed the database
  • Start the bot in watch mode

Option 2: Persistent Database

Use Docker Compose for persistent storage:

bash
# Start PostgreSQL and Redis
docker-compose up -d

# Run migrations
pnpm prisma:migrate

# Start the bot in development mode
pnpm dev

Available Scripts

ScriptDescription
pnpm devStart bot in watch mode
pnpm dev:envStart with ephemeral database + update .env
pnpm buildCompile TypeScript
pnpm startRun compiled bot
pnpm lintRun ESLint
pnpm lint:fixFix ESLint issues
pnpm formatFormat code with Prettier
pnpm typecheckType-check without emitting
pnpm testRun tests
pnpm test:watchRun tests in watch mode
pnpm docs:allServe documentation locally

Prisma Scripts

ScriptDescription
pnpm prisma:generateGenerate Prisma client
pnpm prisma:migrateRun migrations
pnpm prisma:studioOpen Prisma Studio
pnpm prisma:pushPush schema changes
pnpm prisma:seedSeed the database
pnpm prisma:resetReset the database

Project Structure

catto/
├── src/
│   ├── index.ts              # Entry point
│   ├── config.ts             # Environment validation
│   ├── structures/           # BotClient and core structures
│   ├── commands/             # Slash commands
│   ├── listeners/            # Event handlers
│   ├── routes/               # REST API endpoints
│   ├── modules/              # Business logic modules
│   ├── lib/                  # Utilities and helpers
│   │   ├── storage/          # B2 storage and signing services
│   │   └── validation/       # Gate, permissions, rate limiting
│   ├── preconditions/        # Permission checks
│   └── interactions/         # Button/modal handlers
├── dashboard/                # Next.js moderator dashboard
│   ├── app/mod/              # Mod dashboard pages
│   ├── components/mod/       # Evidence gallery, viewer, upload
│   └── lib/                  # Services and types
├── services/
│   └── watermark-rs/         # Rust watermark microservice
├── prisma/
│   ├── schema.prisma         # Database schema
│   └── seed.ts               # Database seeder
├── languages/                # i18n translations
├── docs/                     # Documentation (you are here)
└── docker-compose.yml        # Docker services

Next Steps

CATTO v2.x