An iPad-first PWA to help rebuild LEGO sets by checking off parts from an inventory list. Track your collection, manage progress, and sync across devices.
- 🔍 Search Sets - Search and add LEGO sets from Rebrickable
- 📦 Inventory Management - View parts and minifigs for each set
- ✅ Progress Tracking - Track found parts with increment/decrement counters
- 🎨 Filter & Sort - Filter by color, sort by remaining parts, part number, or color
- 📱 Offline Support - Works offline with local IndexedDB cache
- 🔄 Multi-Device Sync - Sync your library and progress across devices
- 🌍 Localization - English and French support
- ♿ Accessible - WCAG 2.1 AA compliant with keyboard navigation support
- Frontend: Next.js 14 (App Router), React, TypeScript
- Styling: Custom SCSS with iOS-like design system
- PWA: Service worker + manifest for offline support
- Backend: Next.js API routes, Vercel Serverless Functions
- Database: Vercel Postgres + Prisma (server), Dexie/IndexedDB (client)
- Auth: NextAuth.js v5 (Auth.js) with Google OAuth
- Localization: next-intl
- Node.js 18+ and npm
- A Rebrickable API key (Get one here)
- Google OAuth credentials (for authentication)
- PostgreSQL database (Vercel Postgres recommended)
-
Clone the repository:
git clone <repository-url> cd BrickByBrick
-
Install dependencies:
npm install
-
Set up environment variables:
cp env.example .env.local
-
Configure
.env.local:# Rebrickable API REBRICKABLE_API_KEY=your_api_key_here # Authentication (NextAuth.js) AUTH_GOOGLE_ID=your_google_client_id AUTH_GOOGLE_SECRET=your_google_client_secret NEXTAUTH_SECRET=generate_with_openssl_rand_base64_32 AUTH_URL=http://localhost:3000 NEXTAUTH_URL=http://localhost:3000 AUTH_TRUST_HOST=true # For local development # Database DATABASE_URL=your_postgres_connection_string PRISMA_DATABASE_URL=your_prisma_accelerate_url # Required in production
-
Set up the database:
# Generate Prisma Client npm run db:generate # Run migrations npm run db:migrate
-
Run the development server:
npm run dev
-
Open http://localhost:3000 in your browser
BrickByBrick/
├── app/ # Next.js App Router
│ ├── [locale]/ # Localized routes (en, fr)
│ │ ├── auth/ # Authentication pages
│ │ └── sets/ # Set detail pages
│ └── api/ # API routes
│ ├── auth/ # Auth endpoints
│ ├── sets/ # Set operations
│ └── health/ # Health checks
├── components/ # React components
│ ├── InventoryList.tsx # Parts list with filters
│ ├── Library.tsx # Sets library view
│ ├── SetCard.tsx # Set card component
│ └── SyncStatus.tsx # Offline/sync indicator
├── db/ # Dexie (IndexedDB) client
│ ├── database.ts # Schema definition
│ ├── queries.ts # Database queries
│ └── sync-queue.ts # Offline sync queue
├── lib/ # Utilities
│ ├── db/ # Prisma DB helpers
│ ├── hooks/ # Custom React hooks
│ └── logger.ts # Logging utilities
├── rebrickable/ # Rebrickable API client
│ ├── client.ts # API client
│ ├── mappers.ts # Data mappers
│ └── types.ts # TypeScript types
├── prisma/ # Prisma schema & migrations
│ └── schema.prisma # Database schema
└── messages/ # i18n translations
├── en.json
└── fr.json
npm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLintnpm run test- Run testsnpm run db:generate- Generate Prisma Clientnpm run db:migrate- Create and apply migrations (dev)npm run db:push- Push schema changes (dev only)npm run db:studio- Open Prisma Studionpm run generate-icons- Generate PWA icons
GET /api/health- Health checkGET /api/sets/search?q=...- Search sets (Rebrickable proxy)GET /api/sets/[setNum]- Get set details (Rebrickable proxy)GET /api/sets/[setNum]/parts- Get set parts (Rebrickable proxy)
POST /api/sets- Add set to libraryDELETE /api/sets/[setNum]- Remove set from libraryGET /api/sets/sync- Sync sets from databaseGET /api/sets/[setNum]/progress- Get progress for a setPOST /api/sets/[setNum]/progress- Save progress for a setPATCH /api/sets/[setNum]/ongoing- Toggle ongoing status
- Proxy routes: 60 requests per minute per IP
- Auth routes: 10 sign-in attempts per 15 minutes per IP
- Search results: 5 minutes cache, 10 minutes stale-while-revalidate
- Set details: 1 hour cache, 2 hours stale-while-revalidate
- Parts inventory: 1 hour cache, 2 hours stale-while-revalidate
-
Link your repository to Vercel
-
Set environment variables in Vercel dashboard
-
Deploy - Vercel will automatically:
- Run
prisma generateduring build - Build the Next.js app
- Run
-
Run migrations (after first deploy):
npx prisma migrate deploy
Ensure all variables from .env.local are set in Vercel, including:
REBRICKABLE_API_KEYAUTH_GOOGLE_IDandAUTH_GOOGLE_SECRETNEXTAUTH_SECRETAUTH_URL(your production URL)DATABASE_URLandPRISMA_DATABASE_URL
- Local Development: Use
AUTH_URL=http://localhost:3000 - iPad Testing: Use your Mac's local IP address (e.g.,
http://192.168.1.100:3000) or deploy to Vercel - Database: Local dev uses
DATABASE_URL, production usesPRISMA_DATABASE_URL(Prisma Accelerate) - Migrations: Always commit migration files with schema changes
AGENTS.md- Comprehensive project documentation and conventionsPROJECT_SCOPE.md- Full project scope and ticket detailsprisma/schema.prisma- Database schema definitiondb/database.ts- Client-side IndexedDB schema
Private project - All rights reserved
For questions, bugs, or feature requests, contact: brickbybrick@tomtom.design