Overview
Cajas is a modern case-opening platform built with Next.js 16, Supabase, and TypeScript. The application provides a provably fair gaming experience where users can open cases to win virtual items.Tech Stack
Frontend
- Next.js 16.0.6 - React framework with App Router
- React 19.2.1 - UI library with React Compiler enabled
- TypeScript 5 - Type safety and developer experience
- Tailwind CSS 4 - Utility-first CSS framework
- Framer Motion 12 - Animation library for smooth transitions
- Lucide React - Icon library
Backend & Database
- Supabase - Backend-as-a-Service providing:
- PostgreSQL database with Row Level Security (RLS)
- Authentication and user management
- Real-time subscriptions
- RESTful API with auto-generated types
- @supabase/supabase-js 2.86.0 - JavaScript client
- @supabase/ssr 0.8.0 - Server-side rendering utilities
Form & Validation
- React Hook Form 7.68.0 - Form state management
- Zod 4.1.13 - Schema validation
- @hookform/resolvers - Integration between form and validation
Styling & UI
- clsx - Conditional className utility
- tailwind-merge - Merge Tailwind classes efficiently
- Custom theme - Yellow primary (#FACC15) and gray secondary (#1F2937)
- Bai Jamjuree font - Custom Google Font
Architecture Patterns
Application Structure
Cajas follows Next.js 16 App Router conventions with a clear separation of concerns:Rendering Strategy
- Server Components (default): Used for data fetching and static content
- Client Components: Used for interactive UI elements with
'use client'directive - Server Actions: Used for form submissions and mutations with
'use server'directive - API Routes: Used for complex business logic like case opening
Folder Structure
Key Design Decisions
Authentication Flow
- Users sign up/login through Supabase Auth
- Session cookies are managed by
@supabase/ssrfor both client and server - User profiles are automatically created via database trigger
- Row Level Security ensures users can only access their own data
Supabase Client Pattern
Two separate client creation functions maintain proper SSR:Server Actions
Server Actions provide type-safe form handling:Type Safety
Supabase automatically generates TypeScript types from the database schema (types/supabase.ts), ensuring compile-time type checking for all database operations.
Performance Optimizations
- React Compiler: Automatic optimization of React components
- Server Components: Reduced JavaScript bundle size
- Image Optimization: Next.js automatic image optimization
- Code Splitting: Automatic route-based code splitting
- Database Indexes: Proper indexing on foreign keys and frequently queried columns
Security Measures
- Row Level Security: All database tables have RLS policies
- Environment Variables: Sensitive keys stored in environment variables
- HTTPS Only: Enforced in production
- CSRF Protection: Built into Next.js
- XSS Prevention: React’s automatic escaping
- SQL Injection Protection: Parameterized queries via Supabase client
Development Workflow
Environment Variables
Related Documentation
- Database Schema - Detailed database structure
- Authentication - Auth implementation details
- Provably Fair System - Fair gaming algorithms
