Project Structure
Project Structure
Solo Kit uses a modern monorepo architecture with clear separation of concerns, shared packages, and platform-specific applications. This guide explains how everything is organized and why.
ποΈ High-Level Overview
solo-kit/
βββ π± apps/ # Platform-specific applications
β βββ web/ # Next.js web application
β βββ mobile/ # Expo mobile application
βββ π¦ packages/ # Shared packages and libraries
β βββ ui/ # Shared UI components
β βββ utils/ # Platform-agnostic utilities
β βββ database/ # Database schema and operations
β βββ eslint-config/ # Shared ESLint configuration
βββ π οΈ config/ # Project-wide configuration
βββ π docs/ # Documentation files
βββ π§ scripts/ # Utility scripts
βββ π Configuration files
π± Applications (/apps
)
Web Application (/apps/web
)
The Next.js web application following modern App Router patterns.
apps/web/
βββ π¨ app/ # Next.js App Router
β βββ (auth)/ # Route groups for auth pages
β β βββ login/ # Login page
β β βββ signup/ # Sign-up page
β βββ (dashboard)/ # Protected dashboard routes
β β βββ dashboard/ # User dashboard
β β βββ settings/ # User settings
β β βββ admin/ # Admin pages (role-protected)
β βββ api/ # API routes
β β βββ auth/ # Authentication endpoints
β β βββ users/ # User management API
β β βββ webhooks/ # Payment and external webhooks
β βββ documentation/ # Documentation pages (Fumadocs)
β βββ globals.css # Global styles
β βββ layout.tsx # Root layout
β βββ loading.tsx # Global loading UI
β βββ not-found.tsx # 404 page
β βββ page.tsx # Home page
βββ π§© components/ # React components
β βββ ui/ # shadcn/ui components (auto-generated)
β βββ auth/ # Authentication components
β βββ layout/ # Layout components (header, footer, etc.)
β βββ forms/ # Form components
β βββ features/ # Feature-specific components
β β βββ dashboard/ # Dashboard-specific components
β β βββ landing/ # Landing page components
β β βββ admin/ # Admin panel components
β βββ common/ # Reusable common components
βββ π content/ # Content files
β βββ docs/ # Documentation content (MDX)
βββ π£ hooks/ # Custom React hooks
β βββ use-auth.ts # Authentication hooks
β βββ use-theme.ts # Theme management
β βββ use-local-storage.ts # Local storage utilities
βββ π lib/ # Utilities and configurations
β βββ auth.ts # Authentication configuration
β βββ db.ts # Database client
β βββ email.ts # Email service
β βββ payments.ts # Payment processing
β βββ utils.ts # General utilities
β βββ validations.ts # Zod schemas for validation
β βββ constants.ts # Application constants
βββ π¨ styles/ # CSS and styling files
β βββ globals.css # Global styles with Tailwind
βββ π messages/ # Internationalization messages
β βββ en.json # English translations
β βββ es.json # Spanish translations
βββ π§ Configuration files
β βββ next.config.js # Next.js configuration
β βββ tailwind.config.ts # Tailwind CSS configuration
β βββ tsconfig.json # TypeScript configuration
β βββ package.json # Dependencies and scripts
βββ π Other files
βββ .env # Environment defaults
βββ .env.example # Environment documentation
βββ middleware.ts # Next.js middleware
βββ instrumentation.ts # Telemetry and monitoring
Mobile Application (/apps/mobile
)
The Expo React Native application with shared code architecture.
apps/mobile/
βββ π± app/ # Expo Router structure
β βββ (auth)/ # Authentication screens
β β βββ login.tsx # Login screen
β β βββ signup.tsx # Sign-up screen
β βββ (tabs)/ # Tab navigation
β β βββ dashboard.tsx # Dashboard screen
β β βββ profile.tsx # Profile screen
β β βββ settings.tsx # Settings screen
β βββ _layout.tsx # Root layout
β βββ +not-found.tsx # 404 screen
β βββ index.tsx # Landing screen
βββ π§© components/ # Mobile-specific components
β βββ ui/ # Mobile UI components
β βββ navigation/ # Navigation components
β βββ forms/ # Form components
β βββ common/ # Shared components
βββ π£ hooks/ # Mobile-specific hooks
β βββ useAuth.ts # Authentication hooks
β βββ useTheme.ts # Theme management
βββ π lib/ # Mobile utilities
β βββ auth.ts # Authentication client
β βββ storage.ts # Secure storage
β βββ constants.ts # Mobile constants
βββ π¨ styles/ # Styling
β βββ global.ts # Global styles
βββ π§ Configuration files
β βββ app.config.js # Expo configuration
β βββ metro.config.js # Metro bundler config
β βββ tsconfig.json # TypeScript configuration
β βββ package.json # Dependencies and scripts
βββ π Assets
βββ images/ # Image assets
βββ fonts/ # Custom fonts
π¦ Shared Packages (/packages
)
UI Components (/packages/ui
)
Shared UI components that work across web and mobile platforms.
packages/ui/
βββ src/
β βββ components/ # React components
β β βββ button.tsx # Button component
β β βββ card.tsx # Card component
β β βββ input.tsx # Input component
β β βββ modal.tsx # Modal component
β β βββ ... # More shadcn/ui components
β βββ hooks/ # Shared hooks
β β βββ use-toast.tsx # Toast notifications
β β βββ use-media.tsx # Media queries
β βββ utils/ # UI utilities
β β βββ cn.ts # Class name utility
β βββ index.ts # Main exports
β βββ server.ts # Server-only exports
βββ π§ Configuration
β βββ package.json # Package configuration
β βββ tsconfig.json # TypeScript config
β βββ tailwind.config.ts # Tailwind config
β βββ tsup.config.ts # Build configuration
βββ π Other files
βββ components.json # shadcn/ui configuration
Utilities (/packages/utils
)
Platform-agnostic utility functions and helpers.
packages/utils/
βββ src/
β βββ lib/
β β βββ date.ts # Date formatting utilities
β β βββ string.ts # String manipulation
β β βββ number.ts # Number formatting
β β βββ validation.ts # Common validations
β β βββ crypto.ts # Cryptographic utilities
β β βββ format.ts # General formatting
β βββ constants/
β β βββ app.ts # Application constants
β β βββ api.ts # API constants
β β βββ validation.ts # Validation constants
β βββ types/
β β βββ auth.ts # Authentication types
β β βββ user.ts # User types
β β βββ common.ts # Common types
β βββ index.ts # Main exports
βββ π§ Configuration
β βββ package.json # Package dependencies
β βββ tsconfig.json # TypeScript configuration
β βββ tsup.config.ts # Build configuration
βββ π Tests
βββ __tests__/ # Unit tests
βββ date.test.ts # Date utility tests
βββ string.test.ts # String utility tests
Database (/packages/database
)
Database schema, migrations, and query utilities using Drizzle ORM.
packages/database/
βββ src/
β βββ schema/ # Database schema definitions
β β βββ users.ts # User-related tables
β β βββ auth.ts # Authentication tables
β β βββ subscriptions.ts # Payment/subscription tables
β β βββ audit.ts # Audit logging tables
β β βββ index.ts # Schema exports
β βββ lib/
β β βββ db.ts # Database client
β β βββ migrate.ts # Migration utilities
β β βββ seed.ts # Seed data functions
β βββ queries/ # Common database queries
β β βββ users.ts # User queries
β β βββ auth.ts # Auth queries
β β βββ subscriptions.ts # Subscription queries
β βββ index.ts # Main exports
βββ π migrations/ # Database migrations
β βββ 0001_initial.sql # Initial schema
β βββ 0002_add_subscriptions.sql
β βββ meta/ # Migration metadata
βββ π± seed/ # Seed data
β βββ users.ts # User seed data
β βββ subscriptions.ts # Subscription seed data
βββ π§ Configuration
β βββ package.json # Dependencies
β βββ drizzle.config.ts # Drizzle configuration
β βββ tsconfig.json # TypeScript config
β βββ tsup.config.ts # Build config
βββ π Scripts
βββ migrate.ts # Migration script
ESLint Configuration (/packages/eslint-config
)
Shared ESLint configuration for consistent code quality.
packages/eslint-config/
βββ base.js # Base ESLint rules
βββ react.js # React-specific rules
βββ next.js # Next.js-specific rules
βββ react-native.js # React Native rules
βββ package.json # Package configuration
βββ README.md # Configuration documentation
π οΈ Configuration Files
Root Configuration
solo-kit/
βββ π Package Management
β βββ package.json # Root package configuration
β βββ pnpm-workspace.yaml # Workspace configuration
β βββ pnpm-lock.yaml # Lock file
βββ π§ Build System
β βββ turbo.json # Turborepo configuration
β βββ .npmrc # NPM configuration
βββ π Environment
β βββ .env # Safe defaults (committed)
β βββ .env.example # Documentation
β βββ .env.local # Sensitive values (ignored)
βββ π― TypeScript
β βββ tsconfig.json # Root TypeScript config
βββ π¨ Code Quality
β βββ .eslintrc.js # ESLint configuration
β βββ .prettierrc # Prettier configuration
β βββ .editorconfig # Editor configuration
βββ π Version Control
β βββ .gitignore # Git ignore rules
β βββ .gitattributes # Git attributes
βββ π CI/CD
βββ .github/
βββ workflows/ # GitHub Actions
ποΈ File Organization Principles
1. Colocation
Related files are kept close together:
components/
βββ auth/
β βββ login-form.tsx # Component
β βββ login-form.test.tsx # Test
β βββ login-form.stories.tsx # Storybook story
2. Feature-based Structure
Group by features, not by file types:
features/
βββ dashboard/
β βββ components/ # Dashboard components
β βββ hooks/ # Dashboard hooks
β βββ lib/ # Dashboard utilities
β βββ types/ # Dashboard types
3. Clear Naming Conventions
- Routes: kebab-case (
user-profile
,api/auth-callback
) - Components: PascalCase (
UserProfile.tsx
,AuthButton.tsx
) - Utilities: camelCase (
formatDate.ts
,validateEmail.ts
) - Constants: SCREAMING_SNAKE_CASE (
API_ENDPOINTS
,DEFAULT_TIMEOUT
) - Types: PascalCase with descriptive names (
User
,AuthSession
)
4. Import/Export Patterns
Barrel Exports: Use index files for clean imports:
// packages/ui/src/index.ts
export { Button } from './components/button';
export { Card } from './components/card';
export { Input } from './components/input';
// Usage
import { Button, Card, Input } from '@packages/ui';
Absolute Imports: Use path mapping for clean imports:
// Instead of: import { db } from '../../../lib/db'
import { db } from '@/lib/db';
π Data Flow Architecture
Frontend to Backend
π₯οΈ Component
β (uses)
π£ Hook (React Query/SWR)
β (calls)
π API Route/Server Action
β (uses)
ποΈ Database Query (Drizzle ORM)
β (accesses)
π PostgreSQL Database
Shared Code Flow
π¦ packages/utils π¦ packages/ui
β (imported by) β (imported by)
π± apps/mobile π± apps/web
β (shares) β (shares)
π Common Business Logic & UI Components
π― Best Practices
1. Dependency Direction
- Apps can import from packages
- Packages cannot import from apps
- Packages can import from other packages (with care)
2. Component Organization
// β
Good: Clear feature grouping
components/
βββ features/
β βββ auth/
β βββ dashboard/
βββ common/
βββ ui/
βββ layout/
// β Avoid: Generic grouping
components/
βββ buttons/
βββ forms/
βββ modals/
3. File Naming
β
Good names:
- user-profile.tsx (kebab-case routes)
- UserProfile.tsx (PascalCase components)
- formatDate.ts (camelCase utilities)
- AUTH_ENDPOINTS.ts (SCREAMING_SNAKE_CASE constants)
β Avoid:
- userprofile.tsx
- user_profile.tsx
- UserProfile.js (use .tsx for React)
4. Import Organization
// β
Good: Organized imports
// External libraries
import React from 'react';
import { NextRequest, NextResponse } from 'next/server';
// Internal packages
import { Button } from '@packages/ui';
import { formatDate } from '@packages/utils';
// Local imports
import { db } from '@/lib/db';
import { validateUser } from '@/lib/validation';
π Navigation Tips
Finding Files Quickly
VS Code shortcuts:
Cmd/Ctrl + P
- Quick file searchCmd/Ctrl + Shift + F
- Search in filesCmd/Ctrl + T
- Go to symbol
Common file patterns:
- Routes:
app/*/page.tsx
orapp/*/route.ts
- Components:
components/**/*.tsx
- Utilities:
lib/**/*.ts
- Types:
**/*.types.ts
ortypes/**/*.ts
Understanding the Flow
- Start with routes in
app/
directory - Follow imports to understand data flow
- Check components for UI structure
- Review lib files for business logic
- Examine schema for data structure
π Development Workflow
Adding New Features
- Plan the feature - Identify affected areas
- Database changes - Update schema if needed
- API layer - Create routes or server actions
- UI components - Build necessary components
- Pages/screens - Create or update routes
- Testing - Add tests for new functionality
Making Changes
- Identify the layer - Database, API, UI, or routing
- Find the relevant files - Use the structure guide above
- Make changes - Follow established patterns
- Test changes - Run relevant tests
- Update documentation - If adding public APIs
This structure provides a solid foundation for scaling your application while maintaining code quality and developer experience.
π― Next Steps
Now that you understand the project structure:
- Editor Setup - Configure your editor for optimal development
- Development Guide - Learn the development workflow
- Database Guide - Understand the database layer
- API Development - Build robust APIs