Local Development Guide ๐ป โ
This guide covers everything you need to know for developing Shelf.nu locally after completing the Supabase Setup.
Prerequisites โ โ
- โ Node.js (>=22.20.0)
- โ
pnpm (9.15.4+) โ install via
corepack enable && corepack prepare [email protected] --activate - โ Git
- โ Supabase project configured (Setup Guide)
- โ
.envfile with Supabase credentials (place in monorepo root, copy from.env.example)
Monorepo Overview ๐ฆ โ
Shelf.nu is organized as a pnpm + Turborepo monorepo. All commands use pnpm instead of npm.
| Package | Path | Description |
|---|---|---|
@shelf/webapp | apps/webapp/ | Remix web application |
@shelf/docs | apps/docs/ | VitePress documentation site |
@shelf/database | packages/database/ | Prisma client factory and shared types |
@shelf/typescript-config | tooling/typescript/ | Shared TypeScript configurations |
Commands are scoped to specific packages using pnpm --filter <package> or run across the entire monorepo with pnpm turbo <task>.
Convenience shortcuts follow the <app>:<task> pattern and are available at the root:
# Webapp
pnpm webapp:dev # Start webapp dev server
pnpm webapp:build # Build webapp for production
pnpm webapp:test # Run webapp unit tests
pnpm webapp:validate # Run all webapp checks (lint, typecheck, format, tests)
# Docs
pnpm docs:dev # Start docs dev server
pnpm docs:build # Build docs for production
pnpm docs:preview # Preview docs production build
# Database
pnpm webapp:setup # Generate Prisma client and deploy migrations
pnpm db:generate # Generate Prisma client after schema changes
pnpm db:prepare-migration # Create new database migration
pnpm db:deploy-migration # Apply migrations and regenerate client
pnpm db:reset # Reset database (destructive!)Development Setup ๐ โ
1. Clone & Install Dependencies โ
# Clone the repository
git clone https://github.com/Shelf-nu/shelf.nu.git
cd shelf.nu
# Install dependencies (uses pnpm workspaces)
pnpm install2. Setup Local SSL (Optional but Recommended) ๐ โ
Shelf is configured to use HTTPS locally for a better development experience. You can set this up using mkcert:
Install mkcert โ
# macOS
brew install mkcert
# Ubuntu/Debian
sudo apt install libnss3-tools
wget -O mkcert https://github.com/FiloSottile/mkcert/releases/download/v1.4.4/mkcert-v1.4.4-linux-amd64
chmod +x mkcert
sudo mv mkcert /usr/local/bin/
# Windows (using Chocolatey)
choco install mkcertGenerate SSL Certificates โ
# Install local CA
mkcert -install
# Create certificate directory inside the webapp folder
mkdir apps/webapp/.cert
# Generate certificates for localhost
mkcert -key-file apps/webapp/.cert/key.pem -cert-file apps/webapp/.cert/cert.pem localhost 127.0.0.1 ::1Alternative: Disable SSL โ
If you prefer to run without SSL, edit apps/webapp/vite.config.ts and remove these lines:
// Remove or comment out these lines in apps/webapp/vite.config.ts
https: {
key: "./.cert/key.pem",
cert: "./.cert/cert.pem",
},3. Initialize Database โ
This command sets up your database schema and runs initial migrations:
pnpm webapp:setup4. Start Development Server โ
pnpm webapp:devWith SSL enabled: Your app will be available at: https://localhost:3000 ๐
Without SSL: Your app will be available at: http://localhost:3000 ๐
Technology Stack ๐ ๏ธ โ
Understanding Shelf's tech stack will help you develop effectively:
Core Framework โ
- Remix - Full-stack web framework
- React - UI library
- TypeScript - Type safety
Database & Backend โ
- Supabase - Database and authentication
- Prisma - Database ORM
- PostgreSQL - Database
Styling & UI โ
- Tailwind CSS - Utility-first CSS
- Custom Components - Built for asset management
Development Tools โ
Available Scripts ๐ โ
Development โ
pnpm webapp:dev # Start development server
pnpm webapp:build # Build webapp for production
pnpm turbo build # Build all packages for production
pnpm webapp:start # Start production server locally (loads root .env)
pnpm turbo typecheck # Run TypeScript checks (all packages)Database โ
pnpm webapp:setup # Initial database setup
pnpm db:prepare-migration # Create new migration
pnpm db:deploy-migration # Apply migrations and regenerate client
pnpm db:reset # Reset database (careful!)Code Quality โ
pnpm turbo lint # Run ESLint (all packages)
pnpm run format # Format code with Prettier
pnpm webapp:validate # Run all checks (lint, typecheck, format, tests)Testing โ
pnpm webapp:test -- --run # Run unit tests (always use --run flag)
pnpm --filter @shelf/webapp test:e2e # Run end-to-end tests
pnpm --filter @shelf/webapp test:e2e:dev # Run E2E tests in dev mode
pnpm --filter @shelf/webapp test:e2e:install # Install Playwright browsersDevelopment Workflow ๐ โ
Making Database Changes โ
Update Prisma Schema
bash# Edit packages/database/prisma/schema.prismaCreate Migration
bashpnpm db:prepare-migrationApply Migration
bashpnpm db:deploy-migration
Adding New Features โ
Create your feature files in appropriate directories:
apps/webapp/app/routes/- New pages/routesapps/webapp/app/components/- Reusable componentsapps/webapp/app/utils/- Utility functionsapps/webapp/app/modules/- Business logic modules
Follow the established patterns:
- Use TypeScript for type safety
- Follow Remix conventions for data loading
- Use Tailwind for styling
- Add tests for new functionality
Test your changes:
bashpnpm webapp:validate # Check code quality pnpm webapp:test -- --run # Run tests
Project Structure ๐ โ
shelf.nu/
โโโ .env.example # Environment variables template (copy to .env)
โโโ turbo.json # Turborepo pipeline config
โโโ pnpm-workspace.yaml # Workspace package definitions
โโโ pnpm-lock.yaml # Lockfile (committed)
โโโ apps/
โ โโโ webapp/ # @shelf/webapp โ Remix app
โ โ โโโ app/
โ โ โ โโโ components/ # Reusable UI components
โ โ โ โโโ database/ # DB client (re-exports @shelf/database)
โ โ โ โโโ modules/ # Business logic modules
โ โ โ โโโ routes/ # Remix routes (pages)
โ โ โ โโโ utils/ # Utility functions
โ โ โ โโโ root.tsx # App root component
โ โ โโโ package.json
โ โโโ docs/ # @shelf/docs โ VitePress documentation
โโโ packages/
โ โโโ database/ # @shelf/database โ Prisma client + types
โ โโโ prisma/
โ โ โโโ schema.prisma # Database schema
โ โ โโโ migrations/ # Database migrations
โ โโโ src/client.ts # createDatabaseClient() factory
โโโ tooling/
โโโ typescript/ # Shared tsconfig basesKey Directories โ
apps/webapp/app/routes/ - Each file becomes a route in your app:
_index.tsxโ/assets._index.tsxโ/assetsassets.new.tsxโ/assets/new
apps/webapp/app/components/ - Reusable React components:
- Follow atomic design principles
- Include TypeScript props interfaces
- Use Tailwind for styling
apps/webapp/app/modules/ - Business logic organized by domain:
auth/- Authentication logicasset/- Asset managementbooking/- Booking system
Environment Configuration ๐ง โ
Your .env file lives at the monorepo root (not inside apps/webapp/). Copy .env.example to .env and fill in your values.
How env vars are loaded โ
Because the .env lives at the monorepo root but the webapp runs from apps/webapp/, different contexts load env vars differently:
| Context | Command | How env vars are loaded |
|---|---|---|
| Dev server | pnpm webapp:dev | Vite reads from envDir: "../.." (the monorepo root) |
| Local production | pnpm webapp:start | Root script calls start:local which uses dotenv -e ../../.env to inject the root .env before starting the Node server |
| Docker / Fly.io | pnpm run start (inside apps/webapp/) | Env vars are provided by the platform โ no dotenv, no .env file needed |
Why the distinction? The bare
startscript (NODE_ENV=production node ./build/server/index.js) does not load any.envfile. In production (Docker/Fly), the platform injects env vars directly. For local production testing you need thestart:localwrapper (called automatically bypnpm webapp:start) to load the root.env, otherwise required vars likeSESSION_SECRETwill be missing.
Here are the development-specific ones:
# Development server (adjust based on SSL setup)
SERVER_URL="https://localhost:3000" # With SSL
# SERVER_URL="http://localhost:3000" # Without SSL
# Database (from Supabase)
DATABASE_URL="your-supabase-connection-string"
DIRECT_URL="your-supabase-direct-connection"
# Disable premium features for local development
ENABLE_PREMIUM_FEATURES="false"
# Session security
SESSION_SECRET="your-local-session-secret"Database Development ๐๏ธ โ
Working with Prisma โ
View your data:
pnpm --filter @shelf/webapp exec prisma studioThis opens a web interface to browse your database.
Reset database (destructive!):
pnpm db:resetCreating Migrations โ
When you modify packages/database/prisma/schema.prisma:
Prepare migration:
bashpnpm db:prepare-migrationReview the generated SQL in
packages/database/prisma/migrations/Apply migration:
bashpnpm db:deploy-migration
Testing ๐งช โ
Unit Testing with Vitest โ
pnpm webapp:test -- --run # Run all unit testsCreate test files alongside your components:
components/
โโโ Button.tsx
โโโ Button.test.tsxEnd-to-End Testing with Playwright โ
pnpm --filter @shelf/webapp test:e2e:install # Install browsers (first time)
pnpm --filter @shelf/webapp test:e2e:dev # Run tests in developmentE2E tests are in the tests/e2e/ directory.
Debugging ๐ โ
Common Issues โ
Port already in use:
# Kill process on port 3000
lsof -ti:3000 | xargs kill -9SSL Certificate errors:
- Make sure you ran
mkcert -installto install the local CA - Regenerate certificates:
mkcert -key-file .cert/key.pem -cert-file .cert/cert.pem localhost - Or disable SSL by removing the
httpssection fromapps/webapp/vite.config.ts
Database connection errors:
- Check your root
.envdatabase URLs - Verify Supabase project is running
- Ensure you have the correct password
Build errors:
# Clear node modules and reinstall
rm -rf node_modules pnpm-lock.yaml
pnpm installDevelopment Tools โ
Database inspection:
pnpm --filter @shelf/webapp exec prisma studio # Visual database browserType checking:
pnpm turbo typecheck # Check for TypeScript errorsCode formatting:
pnpm run format # Auto-format all codeHot Reloading ๐ฅ โ
The development server includes hot reloading:
- React components - Changes update instantly
- Routes - New routes appear automatically
- Styles - CSS changes apply immediately
- Server code - Remix restarts the server
VS Code Setup ๐ก โ
Recommended extensions:
- Prisma - Syntax highlighting for
.prismafiles - Tailwind CSS IntelliSense - Auto-complete for CSS classes
- TypeScript and JavaScript - Enhanced TS support
- Prettier - Code formatting
- ESLint - Code linting
Workspace Settings โ
Create .vscode/settings.json:
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}Performance Tips ๐ โ
Development Performance โ
- Use TypeScript strict mode for better error catching
- Run tests frequently to catch issues early
- Use Prisma Studio for database inspection instead of raw SQL
- Leverage Remix's built-in optimizations (no need for extra bundlers)
Database Performance โ
- Use database indexes for frequently queried fields
- Limit data in development - Use
.take()to limit results - Use Prisma's
includeandselectto fetch only needed data
Next Steps ๐ฏ โ
Once you're comfortable with local development:
- Explore the codebase - Look at existing routes and components
- Read the other docs - Check out hooks, error handling, etc.
- Join the community - Discord for questions
- Contribute - See CONTRIBUTING.md
- Deploy - Check out Deployment Guide when ready
Getting Help ๐ฌ โ
- ๐ฌ Discord Community - Chat with other developers
- ๐ Documentation - Browse all guides
- ๐ GitHub Issues - Report bugs or request features
- ๐ฆ Twitter - Follow for updates
Happy coding! ๐
