parlo-styring-skill/references/architecture.md

94 lines
3 KiB
Markdown

# Parlo Styring Architecture
## Stack
- **Framework:** Next.js 14.2.5 (App Router)
- **Styling:** Tailwind CSS
- **Language:** TypeScript
- **Deployment:** Docker → Coolify → Traefik
## Data Flow
```
┌─────────────────┐ ┌──────────────────┐
│ Browser/PWA │────▶│ Next.js Server │
└─────────────────┘ └────────┬─────────┘
┌───────────────────────┼───────────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ Ordrestyring │ │ OpenRouter AI │ │ Vector Memory │
│ GraphQL API │ │ (claude-haiku) │ │ (Qdrant+BGE-M3) │
└─────────────────┘ └──────────────────┘ └──────────────────┘
```
## Key Components
### Pages (App Router)
- `/` — Redirect to dashboard
- `/dashboard` — Main overview
- `/sager` — Cases list
- `/sager/[id]` — Case detail
- `/kunder` — Customers list
- `/medarbejdere` — Workers list
- `/tidsplan` — Gantt schedule
### API Routes
- `/api/cases` — Proxy to Ordrestyring cases
- `/api/customers` — Proxy to Ordrestyring customers
- `/api/workers` — Proxy to Ordrestyring workers
- `/api/hours` — Time entries
- `/api/ai/chat` — AI chat with RAG
### Ordrestyring Client
`src/lib/ordrestyring.ts` — TypeScript GraphQL client
```typescript
// Read operations (always enabled)
getCases(limit, page)
getCase(id)
getCustomers(limit, page)
getWorkers(limit, page)
getHours(limit, page)
// Write operations (gated by ENABLE_WRITES)
createCase(data)
updateCase(id, data)
```
## Environment Variables
| Variable | Required | Description |
|----------|----------|-------------|
| `ORDRESTYRING_API_KEY` | Yes | Ordrestyring GraphQL API key |
| `ENABLE_WRITES` | No | Enable write mutations (default: false) |
| `OPENROUTER_API_KEY` | No | AI chat functionality |
| `NEXTAUTH_URL` | Yes | Auth callback URL |
| `NEXTAUTH_SECRET` | Yes | Session encryption |
## Docker
```dockerfile
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:20-alpine AS runner
WORKDIR /app
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
EXPOSE 3000
CMD ["node", "server.js"]
```
## Coolify Config
- **Build:** Dockerfile
- **Port:** 3000
- **Health:** `/api/health`
- **Volume:** `parlo-styring-data:/app/data` (for uploads)