# Local Setup Native installation for active development with hot reload and debugging. ## Prerequisites Complete [Prerequisites](1-prerequisites.md) first. ## Step 1: Clone Repository ```bash git clone https://git.mosaicstack.dev/mosaic/stack mosaic-stack cd mosaic-stack ``` ## Step 2: Install Dependencies ```bash pnpm install ``` This installs dependencies for: - Root workspace - `apps/api` (NestJS backend) - `apps/web` (Next.js frontend - when implemented) - `packages/shared` (Shared types and utilities) ## Step 3: Configure Environment ```bash # Copy environment template cp .env.example .env # Edit configuration nano .env # or use your preferred editor ``` **Minimum required configuration:** ```bash # Database DATABASE_URL=postgresql://mosaic:mosaic@localhost:5432/mosaic # JWT Session JWT_SECRET=$(openssl rand -base64 32) JWT_EXPIRATION=24h # Application NEXT_PUBLIC_APP_URL=http://localhost:3000 ``` See [Configuration → Environment](../3-configuration/1-environment.md) for complete reference. ## Step 4: Setup PostgreSQL Database ### Create Database and User ```bash sudo -u postgres psql < # Or use different port PORT=3002 pnpm dev:api ``` ### PostgreSQL Connection Failed ```bash # Check if PostgreSQL is running sudo systemctl status postgresql # Test connection psql -U mosaic -d mosaic -h localhost -W # Password: mosaic # Check DATABASE_URL in .env cat .env | grep DATABASE_URL ``` ### Prisma Client Not Generated ```bash cd apps/api pnpm prisma:generate # If still failing, clean and reinstall rm -rf node_modules cd ../.. pnpm install pnpm prisma:generate ``` ### Build Errors ```bash # Clean build cache rm -rf apps/*/dist packages/*/dist # Rebuild pnpm build # Type check pnpm typecheck ``` ## Next Steps 1. **Configure Authentication** — [Authentik Setup](../3-configuration/2-authentik.md) 2. **Learn the Workflow** — [Development → Workflow](../../2-development/1-workflow/1-branching.md) 3. **Explore the Database** — [Development → Database](../../2-development/2-database/1-schema.md) 4. **Review API Docs** — [API → Conventions](../../4-api/1-conventions/1-endpoints.md)