Development Guide
This guide covers how to set up your development environment and contribute to Sigmagit.
Prerequisites
- Bun 1.3.5 or higher (JavaScript runtime and package manager)
- Node.js 18+ (for some tooling)
- PostgreSQL 15+ (for local development)
- Redis 7+ (optional, for caching and webhooks)
- Git (for version control)
Getting Started
- Clone the repository:bash
git clone https://git.sigmagaming.net/SigmaGaming/SimgaGit-v2
.git cd sigmagit
2. Install dependencies:
```bash
bun installSet up environment variables:
bashcp .env.example .env # Edit .env with your configurationInitialize the database:
bashbun run db:pushStart the development servers:
bash# Start web app + API server (ports 3000, 3001) bun run dev:web # Or start mobile app + API server (ports 8081, 3001) bun run dev:mobile
Development Workflow
Running Tests
bash
# Run all tests
cd apps/web && bun run test
# Run specific test pattern
cd apps/web && bunx vitest run <pattern>
# Watch mode for development
cd apps/web && bunx vitest watchLinting and Type Checking
bash
# Lint all packages
bun run lint
# Or via turbo
turbo lint
# Type check (package-specific)
cd apps/web && bun run typecheckBuilding
bash
# Build all applications
bun run build
# Build all via turbo
turbo buildDatabase Operations
Schema Changes
- Modify
packages/db/src/schema.ts - Generate migrations:bash
bun run db:generate - Apply migrations:bash
bun run db:migrate
Database Studio
bash
bun run db:studioPackage Scripts
Root Package
bun install- Install all dependenciesbun run dev:web- Start web app + APIbun run dev:mobile- Start mobile app + APIbun run build- Build all appsbun run lint- Lint all packagesbun run db:push- Push schema to databasebun run db:generate- Generate Drizzle migrationsbun run db:migrate- Apply migrationsbun run db:studio- Open Drizzle Studio
Web App (apps/web)
bun run dev- Start development serverbun run build- Build for productionbun run test- Run testsbun run lint- Lint codebun run typecheck- TypeScript type check
API (apps/api)
bun run dev- Start API serverbun run build- Build for productionbun run lint- Lint codebun run typecheck- TypeScript type check
Discord Bot (apps/discord-bot)
bun run dev- Start bot in watch modebun run start- Start bot normallybun run register- Register slash commands
Database Package (packages/db)
bun run push- Push schema changesbun run generate- Generate migrationsbun run migrate- Apply migrationsbun run studio- Open Drizzle Studio
Code Style
We use Prettier for code formatting with the following conventions:
- Line width: 100 characters
- Indentation: 2 spaces (no tabs)
- Semicolons: required
- Quotes: single quotes
- Imports are auto-sorted
To format code:
bash
bunx prettier --write .Project Structure
sigmagit/
├── apps/
│ ├── web/ # TanStack Start web application
│ ├── mobile/ # Expo React Native app
│ ├── api/ # Hono API server
│ └── discord-bot/ # Discord.js bot
├── packages/
│ ├── db/ # Drizzle ORM schema
│ ├── lib/ # Shared utilities
│ └── hooks/ # React Query hooks
├── docs/ # Documentation
└── AGENTS.md # Agent development guidelinesAdding New Features
- Define types in relevant package
- Add database schema if needed
- Create API routes in
apps/api/src/routes/ - Add React Query hooks in
packages/hooks/src/ - Build UI components in
apps/web/ - Write tests for new functionality
- Update documentation
Troubleshooting
Port Already in Use
If ports 3000, 3001, or 8081 are already in use:
- Kill the process:
lsof -ti:3000 | xargs kill - Or change ports in environment variables
Database Connection Issues
- Ensure PostgreSQL is running
- Check
DATABASE_URLin.env - Verify database exists:
psql -U postgres -l
Import/Export Issues
- Clear node_modules:
rm -rf node_modules && bun install - Rebuild packages:
turbo build
Getting Help
- Check existing documentation in
docs/ - Review
AGENTS.mdfor agent-specific guidelines - Look at existing code for patterns and conventions