brackeys.community

Brackeys Community Web

A modern full-stack web application for the Brackeys Discord community, built with TanStack Start, React 19, and a self-hosted backend stack.

πŸ—οΈ Stack

πŸš€ Quick Start

# 1. Install dependencies
bun install

# 2. Build SpacetimeDB module (first time only)
cd spacetime-db
cargo build --release --target wasm32-unknown-unknown
cd ..

# 3. Configure environment
cp .env.example .env
# Edit .env with your Clerk keys

# 4. Start backend services (requires Docker)
docker-compose up -d

# 5. Start development server
bun run dev

Visit http://localhost:3000 to see your app!

πŸ“ Project Structure

brackeys/
β”œβ”€β”€ hasura/                  # Hasura GraphQL metadata & migrations
β”œβ”€β”€ spacetime-db/            # SpacetimeDB Rust module (WASM)
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ routes/              # File-based routes (TanStack Router)
β”‚   β”‚   β”œβ”€β”€ index.tsx        # Home page
β”‚   β”‚   β”œβ”€β”€ login.tsx        # Login page
β”‚   β”‚   β”œβ”€β”€ profile.tsx      # User profile
β”‚   β”‚   β”œβ”€β”€ sandbox.tsx      # Real-time canvas
β”‚   β”‚   β”œβ”€β”€ resources.tsx    # Games & tools
β”‚   β”‚   β”œβ”€β”€ collaborations/  # Collaboration marketplace
β”‚   β”‚   β”œβ”€β”€ auth/            # Auth flow pages
β”‚   β”‚   └── api/             # API routes (webhooks, etc.)
β”‚   β”œβ”€β”€ components/          # React components
β”‚   β”‚   β”œβ”€β”€ auth/            # Auth guards, login button
β”‚   β”‚   β”œβ”€β”€ collaborations/  # Collab cards, filters
β”‚   β”‚   β”œβ”€β”€ games/           # Games (Snake, etc.)
β”‚   β”‚   β”œβ”€β”€ home/            # Hero, features, CTA
β”‚   β”‚   β”œβ”€β”€ layout/          # Header, footer, main layout
β”‚   β”‚   β”œβ”€β”€ resources/       # Resource cards, filters
β”‚   β”‚   β”œβ”€β”€ sandbox/         # Canvas, cursors, messages
β”‚   β”‚   └── ui/              # Reusable UI (Button, Input, Modal)
β”‚   β”œβ”€β”€ context/             # React Context providers
β”‚   β”œβ”€β”€ hooks/               # Custom React hooks
β”‚   β”œβ”€β”€ lib/                 # Utilities & configurations
β”‚   β”œβ”€β”€ server/              # Server functions
β”‚   β”‚   β”œβ”€β”€ auth/            # Discord sync
β”‚   β”‚   β”œβ”€β”€ webhooks/        # Clerk webhooks
β”‚   β”‚   └── graphql/         # GraphQL wrappers
β”‚   └── styles.css           # Global styles
β”œβ”€β”€ docs/                    # Comprehensive documentation
β”œβ”€β”€ .storybook/              # Storybook configuration
└── mise.toml                # Development tooling

🎨 Key Features

1. Real-Time Multiplayer Sandbox

2. Collaboration Marketplace

3. Discord-Native Authentication

4. Games & Tools Directory

βš™οΈ SSR Configuration

TanStack Start supports flexible server-side rendering. Routes use Full SSR by default.

Full SSR (Default)

Everything rendered server-side for best SEO and initial load:

export const Route = createFileRoute('/my-route')({
  component: MyComponent,
});

Data-Only SSR

Server fetches data, client renders UI (hybrid approach):

export const Route = createFileRoute('/my-route')({
  ssr: 'data-only',
  component: MyComponent,
  loader: async () => {
    return await fetchDataServerSide();
  },
});

SPA Mode

Fully client-side rendering (like traditional React):

export const Route = createFileRoute('/my-route')({
  ssr: false,
  component: MyComponent,
});

πŸ” Authentication Flow

  1. User clicks β€œSign in with Discord”
  2. Clerk handles OAuth with Discord
  3. Webhook fires on user.created or session.created
  4. Server fetches Discord guild member data
  5. Maps Discord roles β†’ Hasura roles (admin, staff, moderator, brackeys, user)
  6. Updates Clerk metadata with Hasura claims
  7. User redirected to /auth/entry for guild validation
  8. If in guild β†’ redirect to app; if not β†’ show error

See docs/AUTH_FLOW.md for details.

πŸ› οΈ Development Commands

All development tasks are managed through mise or bun scripts:

# Core Development
mise run dev              # Start all services (Hasura + Frontend)
mise run dev-frontend     # Frontend only
mise run dev-hasura       # Hasura only

# Code Quality
bun run lint              # Run linting
bun run lint:fix          # Fix linting issues
bun run format            # Format code
bun run format:check      # Check formatting
bun run check             # Run all checks

# Building & Generation
bun run build             # Production build
bun run graphql-codegen   # Generate GraphQL types
bun run storybook         # Component documentation

# Versioning & Commits
bun run commit            # Commitizen (conventional commits)
bun run release           # Create version release
mise run pre-commit       # Run all pre-commit checks

# Utilities
mise run check            # Verify tool installation
mise run doctor           # Health check
mise run clean            # Clean generated files
mise tasks                # List all available tasks

πŸ“š Documentation

🌍 Environment Variables

Create a .env file based on .env.example:

# Clerk Authentication
VITE_CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_...
CLERK_WEBHOOK_SECRET=whsec_...

# Hasura GraphQL
VITE_HASURA_GRAPHQL_URL=http://localhost:3280/graphql
HASURA_GRAPHQL_ADMIN_SECRET=your_secret
HASURA_GRAPHQL_JWT_SECRET=your_jwt_secret

# SpacetimeDB
VITE_SPACETIME_HOST=wss://localhost:3000
VITE_SPACETIME_MODULE=brackeys-sandbox

# Discord
VITE_BRACKEYS_GUILD_ID=240491168985399296
DISCORD_GUILD_ID=240491168985399296

πŸ§ͺ Testing

# Run tests
bun run test

# Type check
bunx tsc --noEmit

# Storybook (visual testing)
bun run storybook

# E2E tests (Playwright)
bunx playwright test

πŸ”§ Troubleshooting

β€œDocker is not running”

β€œmise: command not found”

curl https://mise.run | sh
echo 'eval "$(mise activate bash)"' >> ~/.bashrc
source ~/.bashrc

β€œPort already in use”

# Find and kill process using port 3000
lsof -i :3000        # macOS/Linux
netstat -ano | findstr :3000  # Windows

SpacetimeDB connection fails

# Rebuild the Rust module
cd spacetime-db
cargo clean
cargo build --release --target wasm32-unknown-unknown
cd ..

See docs/DEVELOPMENT_SETUP.md for more troubleshooting.

πŸ“¦ Backend Services

All managed via Docker Compose:

🎨 Design System

Color Palette

Custom Utilities

🚒 Deployment

Frontend (Vercel)

bun run build
# Deploy to Vercel

Backend (Hasura Cloud)

cd hasura
ddn supergraph build create

Storybook (GitHub Pages)

bun run build-storybook
# Auto-deployed via GitHub Actions

🀝 Contributing

# 1. Create a feature branch
git checkout -b feature/my-feature

# 2. Make changes
# ...

# 3. Commit with Commitizen
bun run commit

# 4. Push and create PR
git push origin feature/my-feature

πŸ“„ License

MIT License - see LICENSE file for details.


Built with ❀️ by the Brackeys Community