Monorepo struktura
Turborepo workspace, balíčky, aplikace a graf závislostí
Projekt Turtor používá Turborepo s pnpm workspaces pro správu monorepa. Všechny aplikace a balíčky sdílejí společnou konfiguraci a mohou na sebe navzájem odkazovat.
Adresářová struktura
turtor/
├── apps/
│ ├── api/ # NestJS backend (port 4405)
│ │ ├── src/modules/ # Feature moduly (auth, users, courses, ...)
│ │ ├── src/common/ # Guardy, dekorátory, filtry, pipes
│ │ └── src/database/ # Migrace a seedy
│ ├── admin/ # React dashboard (port 3000)
│ │ ├── app/routes/ # TanStack Router file-based routes
│ │ ├── app/hooks/ # Feature-organizované React Query hooky
│ │ └── app/components/
│ └── web/ # Veřejný web (port 3002)
│ ├── app/routes/ # Veřejné stránky, checkout, profil
│ └── app/hooks/ # Hooky (auth, checkout, courses, geolocation)
├── packages/
│ ├── api-types/ # Orval-generované API hooky + Axios klient
│ ├── shared/ # Sdílené konstanty, utility, labely
│ ├── ui/ # shadcn/ui knihovna komponent
│ └── config/ # ESLint, TypeScript konfigurace
├── docker/ # Docker Compose soubory (dev, prod, e2e, test)
├── e2e/ # Playwright E2E testy
├── scripts/ # Deploy a utility skripty
└── turbo.json # Turborepo pipeline konfiguraceAplikace (apps/)
API (apps/api/)
NestJS backend s REST API a WebSocket gateway.
| Položka | Cesta |
|---|---|
| Vstupní bod | src/main.ts |
| App modul | src/app.module.ts |
| Feature moduly | src/modules/ |
| Sdílené (guardy, dekorátory) | src/common/ |
| Migrace | src/database/migrations/ |
| Seedy | src/database/seeds/ |
| Data source (CLI) | data-source.ts |
Admin (apps/admin/)
React 19 dashboard pro autentizované uživatele -- správa kurzů, instruktorů, firem, sales pipeline.
| Položka | Cesta |
|---|---|
| Vstupní bod | app/main.tsx |
| Router | app/router.tsx |
| Routes | app/routes/ |
| Hooky | app/hooks/ |
| Komponenty | app/components/ |
| Kontexty | app/contexts/ |
Web (apps/web/)
Veřejný marketing web -- výpis kurzů, checkout, registrace, profil uživatele.
| Položka | Cesta |
|---|---|
| Vstupní bod | app/main.tsx |
| Routes | app/routes/ |
| Hooky | app/hooks/ |
| Auth komponenty | app/components/auth/ |
| Checkout komponenty | app/components/checkout/ |
Balíčky (packages/)
@turtor/api-types
Automaticky generované API typy a React Query hooky z OpenAPI specifikace pomocí nástroje Orval.
packages/api-types/
├── src/
│ ├── client/ # Axios klient, custom instance, HttpError
│ │ ├── client.ts # Singleton apiClient
│ │ ├── axios-instance.ts # Orval mutátor (customInstance)
│ │ └── index.ts # Exporty
│ └── generated/ # Orval výstup (negenerovat ručně!)
│ ├── models/ # TypeScript typy z OpenAPI schématu
│ └── [controller]/ # React Query hooky per controller
└── orval.config.ts # Konfigurace Orval generátoruImport vzory:
// Hooky -- z @turtor/api-types/[controller]
import { useCoursesControllerFindAllApiV1 } from '@turtor/api-types/courses';
// Typy -- z @turtor/api-types/models
import type { Course, Instructor } from '@turtor/api-types/models';
// Klient -- z @turtor/api-types/client
import { apiClient, HttpError } from '@turtor/api-types/client';@turtor/shared
Sdílené konstanty, utility funkce a labely používané jak backendem, tak frontendem.
packages/shared/src/
├── constants/
│ └── labels.ts # COURSE_STATUS_LABELS, BOOKING_STATUS_LABELS, ...
├── types/
│ └── enums.ts # UserRole, CourseStatus, BookingStatus, ...
├── utils/
│ └── index.ts # getInitials, formatCurrency, getErrorMessage, ...
└── index.ts # Barrel export@turtor/ui
Knihovna UI komponent postavená na shadcn/ui s Tailwind CSS v4.
packages/ui/src/
├── components/
│ ├── button.tsx, input.tsx, ... # Základní shadcn komponenty
│ ├── field.tsx # Field, FieldGroup, FieldLabel, FieldError
│ ├── form/ # FormInput, FormSelect, FormDatePicker
│ ├── data-table/ # DataTable, filtry, paginace
│ ├── feedback/ # StatusBadge, EmptyState, PageSkeleton
│ ├── layout/ # PageHeader, StatsCard, KanbanBoard
│ ├── calendar/ # WeeklyCalendar, MiniMonthCalendar
│ └── display/ # PriceDisplay, CompactPriceDisplay
├── styles/
│ └── globals.css # Tailwind v4 CSS-first konfigurace
└── index.ts # Barrel export@turtor/config
Sdílené ESLint a TypeScript konfigurace pro všechny aplikace a balíčky.
Graf závislostí
apps/admin ──┬── @turtor/ui
├── @turtor/api-types
├── @turtor/shared
└── @turtor/config
apps/web ────┬── @turtor/ui
├── @turtor/api-types
├── @turtor/shared
└── @turtor/config
apps/api ────┬── @turtor/shared
└── @turtor/config
@turtor/ui ──┬── @turtor/shared
└── @turtor/config
@turtor/api-types ── @turtor/configTurborepo pipeline
Turborepo definuje task pipeline v turbo.json:
- build -- sestaví všechny balíčky s cache (závisí na
^build-- nejdřív závislosti) - dev -- spustí dev server (persistent task, bez cache)
- lint -- lint s cache
- typecheck -- type check s cache
- test -- unit testy
# Spuštění všech aplikací
pnpm dev
# Spuštění konkrétní aplikace
pnpm dev:api # Pouze API
pnpm dev:admin # Pouze admin
pnpm dev:web # Pouze web
pnpm dev:apps # Admin + web (bez API)
# Build
pnpm build # Sestaví všechny balíčkyDocker služby pro vývoj
Infrastrukturní služby běží v Docker kontejnerech:
pnpm docker:up # Spustit služby
pnpm docker:down # Zastavit služby| Služba | Port | Účel |
|---|---|---|
| PostgreSQL | 5433 | Databáze |
| Redis | 6380 | Cache + BullMQ fronty |
| MinIO | 9002 (konzole 9003) | S3-kompatibilní úložiště |
| MailHog | 1026 (SMTP), 8026 (UI) | Zachytávání e-mailů |
Porty jsou záměrně posunuté (5433 místo 5432 atd.), aby nedocházelo ke kolizím s jinými projekty.