Overview
Featul uses Turborepo to manage a monorepo containing multiple applications and shared packages. This allows for code reuse, consistent tooling, and efficient builds.Package Manager
Featul uses Bun as its primary package manager for development:Workspace Structure
Apps
Applications that can be deployed independently:- Next.js 16 with App Router
- Turbopack for fast dev experience
- Multi-tenant workspace interface
- Feedback boards, roadmaps, changelogs
- Public website and documentation
- Landing pages and pricing
- Blog and changelog feed
Packages
Shared code used across applications:Package Details
@featul/api- jstack-based RPC API
- Router definitions per domain
- Middleware and validators
- Type-safe client exports
- better-auth configuration
- Session management
- OAuth providers setup
- Organization plugin
- Drizzle ORM setup
- Database schemas
- Migration scripts
- Database client singleton
- Tiptap editor configuration
- Custom extensions
- Markdown support
- Mentions and rich formatting
- Radix UI components
- Custom form components
- Tailwind-styled primitives
- Design system tokens
- Base TypeScript configurations
- Shared compiler options
- Path aliases and module resolution
- Shared ESLint rules
- TypeScript linting
- React/Next.js specific rules
Workspace Configuration
Root package.json
Dependency Management
Packages reference each other usingworkspace:* protocol:
Turborepo Configuration
turbo.json
Task Pipeline
build- Depends on dependencies being built first (
^build) - Caches
.next/output (excluding cache directory) - Respects environment variables for builds
- No caching (always runs fresh)
- Persistent task (long-running dev server)
- Runs in parallel across workspaces
- Depends on
transit(package compilation) - Caches results for speed
- TypeScript type checking
- Runs after transit phase
- Parallelized across workspaces
Transit Phase
Thetransit task handles package compilation and preparation:
Development Workflow
Starting Development
Run all apps:app and web in parallel with hot reloading.
Run specific app:
Building for Production
Build all:Type Checking
Check all packages:Linting and Formatting
Lint:Database Operations
All database commands are scoped to the@featul/db package:
Adding New Packages
Create Package Structure
Package Configuration
package.json:Using the Package
Add to consuming app’spackage.json:
Performance Tips
Cache Management
Turbo caches build outputs aggressively. Clear cache if needed:Parallel Execution
Turborepo runs tasks in parallel where possible. Maximize parallelism by:- Keeping packages independent
- Using
^taskfor dependency ordering - Avoiding circular dependencies
Selective Builds
Only build what changed:Troubleshooting
Type Errors in IDE
If TypeScript can’t find workspace packages:Cmd+Shift+P → “TypeScript: Restart TS Server”
Dependency Issues
Clear and reinstall:Build Failures
Check build order. Packages must build before apps that depend on them. VerifydependsOn in turbo.json.
Best Practices
Package Boundaries
- apps/ should consume packages, not provide them
- packages/ should be framework-agnostic where possible
- Avoid circular dependencies between packages
Versioning
All packages use0.0.0 and are private. The monorepo is versioned as a whole.
Code Sharing
Extract shared code to packages:- UI components →
@featul/ui - API utilities →
@featul/api - Database queries →
@featul/db - Type definitions → Appropriate package