Development Guide
Comprehensive guide for developing with ShipKit
Development Guide
This guide covers everything you need to know about developing applications with ShipKit.
Quick Start
- Clone the repository
- Install dependencies:
pnpm install
- Set up environment variables:
cp .env.example .env.local
- Start the development server:
pnpm dev
Development Environment
Required Tools
- Node.js (v18 or later)
- PNPM (v8 or later)
- PostgreSQL (v15 or later)
- VS Code (recommended)
VS Code Extensions
VS Code Settings
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "biomejs.biome",
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"typescript.preferences.importModuleSpecifier": "non-relative",
"typescript.preferences.importModuleSpecifierEnding": "minimal",
"typescript.preferences.preferTypeOnlyAutoImports": true
}
Code Style
We use Biome for formatting and linting. Our configuration:
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
"noUnusedVariables": "warn",
"noUndeclaredVariables": "error"
},
"suspicious": {
"noExplicitAny": "warn",
"noConsoleLog": "warn"
},
"style": {
"noNonNullAssertion": "warn",
"useNodejsImportProtocol": "warn",
"useTemplate": "error"
}
}
},
"formatter": {
"enabled": true,
"indentStyle": "tab",
"indentWidth": 2,
"lineWidth": 80
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"semicolons": "always"
}
}
}
Project Structure
src/
├── app/ # Next.js app directory
│ ├── (app)/ # App routes
│ ├── (auth)/ # Auth routes
│ └── api/ # API routes
├── components/ # React components
│ ├── ui/ # UI components
│ └── blocks/ # Page blocks
├── lib/ # Utility functions
├── server/ # Server-side code
│ ├── actions/ # Server actions
│ ├── auth/ # Auth configuration
│ └── services/ # Server services
└── styles/ # Global styles
Development Workflow
1. Component Development
- Use server components by default
- Create client components only when needed (interactivity)
- Place components in appropriate directories:
ui/
for reusable UI componentsblocks/
for page-specific componentsapp/(app)/
for route-specific components
2. API Development
- Use server actions for form submissions
- Place API routes in
app/api/
- Use Zod for request validation
- Follow REST principles
- Handle errors consistently
3. Database Operations
- Use Drizzle ORM for database queries
- Place migrations in
drizzle/migrations/
- Run migrations:
pnpm db:migrate
4. Authentication
- Use Auth.js (v5) for authentication
- Configure providers in
server/auth/
- Test with different providers locally
5. Testing
- Write tests in
__tests__
directories - Run tests:
pnpm test
Common Tasks
Adding a New Page
- Create route directory in
app/(app)/
- Add
page.tsx
for the route - Create components in
blocks/
if needed - Update navigation if required
Creating an API Endpoint
- Add route in
app/api/
- Create request validation schema
- Implement error handling
- Add documentation
Adding a Database Table
- Create migration:
pnpm db:migration:create add_table_name
- Define schema in migration file
- Run migration:
pnpm db:migrate
Deployment
Production Checks
- Run type checking:
pnpm typecheck
- Run linting:
pnpm lint
- Run tests:
pnpm test
Deployment Commands
# Build for production
pnpm build
# Start production server
pnpm start