# Project Structure

# Project Structure

## Monorepo Layout

The Plock monorepo uses Turborepo for frontend orchestration and Gradle for the Kotlin backend.

**Root folders:**

- **backend/** — Kotlin/Ktor backend (Gradle). Namespace: no.alai.plock
  - Application.kt — Ktor entry point
  - plugins/ — Routing, serialization, auth, CORS
  - routes/ — API routes by domain (auth, inventory, orders, picking, carriers, ai)
  - models/ — Data classes + Exposed table definitions
  - services/ — Business logic
  - integrations/ — Fortnox, PostNord, DHL, Instabee

- **frontend/** — Micro-Frontend apps (Vite + Module Federation)
  - shell/ — Shell MFE: layout, nav, auth, routing (always deployed)
  - mfe-inventory/ — Inventory management (independently deployable)
  - mfe-orders/ — Order management (independently deployable)
  - mfe-picking/ — Picking + wave management (independently deployable)
  - mfe-settings/ — Settings + users (independently deployable)
  - mfe-ai/ — AI Chat + analytics (independently deployable)

- **packages/** — Shared libraries
  - ui/ — @plock/ui: shadcn/ui base + Plock custom components, Tailwind CSS 4 design tokens
  - types/ — @plock/types: shared TypeScript types (API contracts)
  - utils/ — @plock/utils: shared utilities

- **docs/** — All documentation (mirrors BookStack)
- **brand/** — Brand assets (colours, logo, typography)
- **design/** — Figma exports, wireframes (via frontend-design skill — ZAKON #3)
- **infrastructure/** — Docker Compose, CI/CD, K8s manifests
- **legal/** — Swedish regulatory compliance (GDPR, moms, Intrastat)
- **marketing/** — GTM materials

---

## Key Conventions

| Convention | Detail |
|------------|--------|
| Package names | @plock/ui, @plock/types, @plock/utils |
| Backend namespace | no.alai.plock |
| Environment secrets | .env.local — never committed to git |
| API base URL | api.plock.se (production), localhost:8080 (local) |
| Frontend URL | plock.se (shell), MFEs on sub-paths or CDN |
| Test coverage target | 80%+ for services layer |
| DB migrations | Exposed schema + migration scripts in backend/src/main/resources/migrations/ |

---

## Root Config Files

| File | Purpose |
|------|---------|
| docker-compose.yml | Local dev services: PostgreSQL, Redis, backend, shell |
| turbo.json | Turborepo pipeline: build, dev, test, lint |
| build.gradle.kts | Kotlin backend build config |
| CLAUDE.md | Project handbook (AI director instructions) |
| PIPELINE.md | 8-gate pipeline tracker |