Files
schuettgo/docs/ARCHITEKTUR.md
FluxKit 76443e6351 docs: Planungsdokumente erstellen
- Marktanalyse (Wettbewerber, Lücken, USPs)
- Anforderungskatalog (Must-Have, Should-Have, Nice-to-Have)
- MVP Definition (Features, Datenmodell, Zeitplan)
- Technische Architektur (Stack, API, DB-Schema)
- Waagen-Integration (Hersteller, Protokolle, Strategie)
2026-02-19 20:21:08 +00:00

292 lines
8.8 KiB
Markdown

# SchüttGo - Technische Architektur
## 1. Tech-Stack Übersicht
```
┌─────────────────────────────────────────────────────────────┐
│ FRONTEND │
│ Vue 3 + FluxKit UI + TailwindCSS + TypeScript │
└─────────────────────────────────────────────────────────────┘
│ HTTPS / REST API
┌─────────────────────────────────────────────────────────────┐
│ BACKEND │
│ Deno + Oak + TypeScript │
│ ├── Auth (JWT) │
│ ├── REST API │
│ ├── PDF Generator │
│ └── Waagen-Service (optional) │
└─────────────────────────────────────────────────────────────┘
│ SQL
┌─────────────────────────────────────────────────────────────┐
│ DATABASE │
│ PostgreSQL 16 │
└─────────────────────────────────────────────────────────────┘
```
## 2. Frontend
### 2.1 Technologie
| Komponente | Technologie | Begründung |
|------------|-------------|------------|
| Framework | Vue 3 | Reaktiv, performant, gute DX |
| UI Library | FluxKit UI | Eigene Komponenten, einheitlich |
| Styling | TailwindCSS | Utility-first, schnell |
| State | Pinia | Offiziell, einfach |
| HTTP | Axios | Standard, Interceptors |
| Routing | Vue Router | Standard |
| Build | Vite | Schnell, modern |
### 2.2 Projektstruktur
```
schuettgo-frontend/
├── src/
│ ├── components/ # Wiederverwendbare Komponenten
│ │ ├── WeighingForm.vue
│ │ ├── CustomerSelect.vue
│ │ └── ...
│ ├── views/ # Seiten
│ │ ├── Dashboard.vue
│ │ ├── Weighing.vue
│ │ ├── Customers.vue
│ │ └── ...
│ ├── stores/ # Pinia Stores
│ │ ├── auth.ts
│ │ ├── weighing.ts
│ │ └── ...
│ ├── api/ # API Client
│ ├── router/ # Routing
│ └── utils/ # Hilfsfunktionen
├── public/
└── package.json
```
## 3. Backend
### 3.1 Technologie
| Komponente | Technologie | Begründung |
|------------|-------------|------------|
| Runtime | Deno 2.x | Sicher, TS native, modern |
| Framework | Oak | Express-ähnlich, stabil |
| ORM | Drizzle ORM | Type-safe, performant |
| Auth | JWT | Stateless, skalierbar |
| Validation | Zod | Schema-basiert |
| PDF | @pdfme/generator | Vorlagen-basiert |
### 3.2 Projektstruktur
```
schuettgo-backend/
├── src/
│ ├── routes/ # API Endpoints
│ │ ├── auth.ts
│ │ ├── customers.ts
│ │ ├── materials.ts
│ │ ├── vehicles.ts
│ │ ├── weighings.ts
│ │ └── invoices.ts
│ ├── services/ # Business Logic
│ │ ├── weighing.service.ts
│ │ ├── invoice.service.ts
│ │ └── pdf.service.ts
│ ├── db/ # Datenbank
│ │ ├── schema.ts # Drizzle Schema
│ │ ├── migrations/
│ │ └── seed.ts
│ ├── middleware/ # Auth, CORS, etc.
│ └── utils/
├── deno.json
└── .env
```
### 3.3 API Design
```
POST /api/auth/login
POST /api/auth/logout
GET /api/auth/me
GET /api/customers
POST /api/customers
GET /api/customers/:id
PUT /api/customers/:id
DELETE /api/customers/:id
GET /api/materials
POST /api/materials
...
GET /api/vehicles
POST /api/vehicles
GET /api/vehicles/search?plate=...
GET /api/weighings
POST /api/weighings/entry # Einfahrt
PUT /api/weighings/:id/exit # Ausfahrt
GET /api/weighings/:id
GET /api/delivery-notes
GET /api/delivery-notes/:id/pdf
GET /api/invoices
POST /api/invoices
GET /api/invoices/:id/pdf
```
## 4. Datenbank
### 4.1 PostgreSQL Schema
```sql
-- Benutzer
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email VARCHAR(255) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
name VARCHAR(255) NOT NULL,
role VARCHAR(50) NOT NULL DEFAULT 'operator',
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW()
);
-- Kunden
CREATE TABLE customers (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name VARCHAR(255) NOT NULL,
address TEXT,
city VARCHAR(100),
postal_code VARCHAR(20),
contact_name VARCHAR(255),
contact_email VARCHAR(255),
contact_phone VARCHAR(50),
notes TEXT,
created_at TIMESTAMP DEFAULT NOW()
);
-- Kundenpreise
CREATE TABLE customer_prices (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
customer_id UUID REFERENCES customers(id),
material_id UUID REFERENCES materials(id),
price DECIMAL(10,2) NOT NULL,
valid_from DATE,
valid_until DATE,
UNIQUE(customer_id, material_id, valid_from)
);
-- Materialien
CREATE TABLE materials (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name VARCHAR(255) NOT NULL,
category VARCHAR(100),
unit VARCHAR(20) DEFAULT 't',
default_price DECIMAL(10,2),
created_at TIMESTAMP DEFAULT NOW()
);
-- Fahrzeuge
CREATE TABLE vehicles (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
license_plate VARCHAR(20) UNIQUE NOT NULL,
type VARCHAR(100),
tara_weight DECIMAL(10,2),
customer_id UUID REFERENCES customers(id),
notes TEXT,
created_at TIMESTAMP DEFAULT NOW()
);
-- Wiegungen
CREATE TABLE weighings (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
vehicle_id UUID REFERENCES vehicles(id),
customer_id UUID REFERENCES customers(id),
material_id UUID REFERENCES materials(id),
gross_weight DECIMAL(10,2),
tare_weight DECIMAL(10,2),
net_weight DECIMAL(10,2),
entry_time TIMESTAMP NOT NULL DEFAULT NOW(),
exit_time TIMESTAMP,
status VARCHAR(20) DEFAULT 'open',
operator_id UUID REFERENCES users(id),
notes TEXT
);
-- Lieferscheine
CREATE TABLE delivery_notes (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
number SERIAL,
weighing_id UUID REFERENCES weighings(id),
customer_id UUID REFERENCES customers(id),
created_at TIMESTAMP DEFAULT NOW(),
printed_at TIMESTAMP,
emailed_at TIMESTAMP
);
-- Rechnungen
CREATE TABLE invoices (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
number SERIAL,
customer_id UUID REFERENCES customers(id),
total_net DECIMAL(10,2),
total_vat DECIMAL(10,2),
total_gross DECIMAL(10,2),
status VARCHAR(20) DEFAULT 'draft',
created_at TIMESTAMP DEFAULT NOW(),
due_date DATE
);
-- Rechnungspositionen
CREATE TABLE invoice_items (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
invoice_id UUID REFERENCES invoices(id),
delivery_note_id UUID REFERENCES delivery_notes(id),
description TEXT,
quantity DECIMAL(10,3),
unit VARCHAR(20),
unit_price DECIMAL(10,2),
amount DECIMAL(10,2)
);
```
## 5. Deployment
### 5.1 Docker Setup
```yaml
# docker-compose.yml
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_DB: schuettgo
POSTGRES_USER: schuettgo
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "127.0.0.1:5433:5432"
backend:
build: ./schuettgo-backend
environment:
DATABASE_URL: postgres://schuettgo:${DB_PASSWORD}@postgres:5432/schuettgo
JWT_SECRET: ${JWT_SECRET}
ports:
- "127.0.0.1:8003:8000"
depends_on:
- postgres
frontend:
build: ./schuettgo-frontend
ports:
- "127.0.0.1:3005:80"
depends_on:
- backend
```
### 5.2 URLs
- Frontend: https://schuettgo.kronos-soulution.de
- API: https://api.schuettgo.kronos-soulution.de
---
*Erstellt: 2026-02-19*