- Added the Universal CSV Import module, including the `UNIVERSAL_CSV_IMPORT_AGENT_GUIDE.md` for guidelines on new import modules, executors, and templates. - Updated relevant rules in `ARCHITECTURE.md` and `CODING_RULES.md` to include references to the new import module and its requirements. - Revised the Gitea Issues Index to reflect the latest updates and added context for ongoing issues related to the CSV import functionality. - Enhanced the README files to provide clearer navigation and documentation for the Universal CSV Import features.
2.5 KiB
2.5 KiB
Coding Rules – Mitai Jinkendo
Diese Regeln IMMER befolgen. Sie basieren auf Erfahrungen aus der Entwicklung.
Backend
1. Auth auf jeden Endpoint
# Jeder neue Endpoint braucht Auth:
@router.get("/neuer-endpoint")
def neuer_endpoint(session: dict = Depends(require_auth)):
pid = session['profile_id']
2. Profile-ID aus Session – nie aus Header
pid = session['profile_id'] # ✅
# Nicht: request.headers.get('X-Profile-Id') ❌
3. bcrypt für Passwörter
from auth import hash_pin, verify_pin
hashed = hash_pin(plain_password) # ✅
# Nicht: hashlib.sha256(...) ❌
4. PostgreSQL-Syntax
cur.execute("SELECT * FROM t WHERE id = %s AND active = true", (id,))
# Nicht: ? und active = 1 (SQLite-Syntax)
5. Rate Limiting für sensitive Endpoints
from slowapi import Limiter
@router.post("/sensitive")
@limiter.limit("5/minute")
def sensitive(request: Request, ...):
6. Universal CSV Import / Admin-Vorlagen
Neues Import-Zielmodul, Änderungen an csv_parser, Executor, DB-source/CHECK, oder System-CSV-Vorlagen:
- Pflichtlektüre und Checkliste:
.claude/docs/technical/UNIVERSAL_CSV_IMPORT_AGENT_GUIDE.md - Keine zweite DB-Connection im Importpfad; Zeilenfehler ohne „aborted transaction“ (SAVEPOINT-Muster wo nötig)
- Admin Create/Update von Systemvorlagen: Validierung über
validate_csv_templatenicht umgehen
Frontend
1. api.js für alle API-Calls
await api.listWeight() // ✅
await fetch('/api/weight') // ❌ kein Token
2. Fehlerbehandlung in async Funktionen
try {
const data = await api.meinEndpoint()
} catch(e) {
setError(e.message) // api.js wirft bereits Error mit detail-Text
}
3. Kein TypeScript
Das Projekt nutzt bewusst kein TypeScript – keine .ts/.tsx Dateien erstellen.
4. Keine neuen npm-Pakete ohne Absprache
Erst fragen, dann installieren.
5. CSS-Variablen statt Hardcoded-Farben
// ✅ Richtig:
style={{color: 'var(--accent)'}}
// ❌ Falsch:
style={{color: '#1D9E75'}}
Git & Deployment
1. Nie direkt auf main pushen
Immer über Pull Request in Gitea: develop → main
2. develop Branch nie löschen
Er ist permanent – nicht nach Merge löschen.
3. .env nie committen
Steht in .gitignore – nie entfernen.
4. Commit-Message Format
feat: neues Feature
fix: Bugfix
refactor: Umbau ohne Funktionsänderung
docs: Dokumentation
ci: CI/CD Änderungen
chore: Maintenance