31 Commits

Author SHA1 Message Date
Oliver Hofmann
280b3b0762 Add open: true to Vite dev server config 2026-04-29 17:13:14 +02:00
Oliver Hofmann
89661dafcc Update README: new endpoints, Docker Hub, streaming, PyCharm config, port 8001 security 2026-04-29 10:19:31 +02:00
Oliver Hofmann
3ccc7f325d Explain port 8001 security model in docs 2026-04-29 10:17:59 +02:00
Oliver Hofmann
25f19b6ada Show reset date below quota progress bars in admin UI 0.9.2 2026-04-29 09:55:25 +02:00
Oliver Hofmann
5b97ed0ef7 Expose port 8001 on 127.0.0.1 only, explain why in docs 2026-04-29 09:52:13 +02:00
Oliver Hofmann
222b204d4b build_push.sh: show current tag, offer to set new one before build 0.9.1 2026-04-29 09:36:50 +02:00
Oliver Hofmann
9910e6e062 Exclude .claude from Docker build context 2026-04-29 09:35:17 +02:00
Oliver Hofmann
6e704da86b Expand .dockerignore with standard entries 2026-04-29 09:34:19 +02:00
Oliver Hofmann
bd0dc0478f Add local docker-compose pulling from DockerHub with SQLite and .env 2026-04-29 09:33:04 +02:00
Oliver Hofmann
92fd66381f Add English version of DockerHub README 2026-04-29 09:19:28 +02:00
Oliver Hofmann
c46c1c2b12 Clarify that Ollama can run remotely, not just on Docker host 0.9.0 2026-04-29 08:51:23 +02:00
Oliver Hofmann
d243523906 Split host-Ollama compose into SQLite and PostgreSQL variants 2026-04-29 08:47:40 +02:00
Oliver Hofmann
2319434b0f Add host-Ollama compose variant, fix leftover port 8001 exposure 2026-04-29 08:43:54 +02:00
Oliver Hofmann
7912431ffb Remove ALLOWED_ORIGINS from DockerHub docs (dev-only setting) 2026-04-29 08:38:38 +02:00
Oliver Hofmann
114c45dc7e Remove port 8001 exposure from all Docker examples 2026-04-29 08:36:59 +02:00
Oliver Hofmann
6f67f29f68 Fix depends_on syntax in PostgreSQL compose example 2026-04-29 08:31:25 +02:00
Oliver Hofmann
3b7c88bf2c Install psycopg2-binary in Dockerfile only, not in dev requirements 2026-04-29 08:30:16 +02:00
Oliver Hofmann
03712fe401 Add DockerHub README with usage, env vars and compose examples 2026-04-29 08:26:47 +02:00
Oliver Hofmann
a0512b3b2b Replace build_push.py with build_push.sh, use shell script run config 2026-04-29 08:23:07 +02:00
Oliver Hofmann
511e85ea79 Add Docker build/push run config for arm64 2026-04-29 08:20:15 +02:00
Oliver Hofmann
cdaec894d8 Add PyCharm Dev run config and dev runner script
- run_dev.py: starts proxy, admin and frontend together with colored
  output per process; handles SIGTERM from PyCharm Stop button
- .idea/runConfigurations/Dev.xml: PyCharm Python run config
- .gitignore: allow Dev.xml via layered negation pattern
- vite.config.js: open browser automatically on dev server start
2026-04-29 08:14:33 +02:00
Oliver Hofmann
dd8f69ecb6 Proxy fixes, streaming support, Admin-UI overhaul
Backend:
- Fix Content-Length mismatch by not forwarding client headers to Ollama
- Proxy /v1/chat/completions directly to Ollama's OpenAI-compatible endpoint
  (eliminates manual Ollama↔OpenAI format conversion, fixes tool use)
- Add streaming support via SSE passthrough
- Fix ollama_url /v1 suffix stripped on save
- Replace BaseHTTPMiddleware with FastAPI global dependency (fixes double logging)
- Add rotating usage log (8 KB, logs key name + model + token estimate + prompt preview)
- Add httpx timeout 300s
- Add activate and delete endpoints for API keys
- Return usage data (tokens/requests) in GET /api/api-keys

Frontend:
- Admin table: remove ID column, status as icon, icon-only action buttons with CSS tooltips
- Add activate + delete buttons; edit available for inactive keys too
- Quota columns: fixed equal width, progress bars with k-unit formatting
- Create form: structured layout matching edit form style
- Edit form: token inputs in k units (÷1000 display, ×1000 on save)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-29 07:48:10 +02:00
Oliver Hofmann
c62cafc202 Store key_prefix for readable key display instead of masked hash
The last-4 of the SHA-256 hash was meaningless for identification.
Now storing the first 12 chars of the plaintext key as key_prefix,
displayed as 'sk-aBcDeFgH••••••••' — consistent with what the user
sees at creation time and how GitHub/OpenAI handle it.
2026-04-28 10:23:37 +02:00
Oliver Hofmann
94368670b7 Reload Ollama models on URL change, pre-select current model
- /api/ollama-models accepts optional url query param to query a different endpoint
- Frontend fetches models on load and on Ollama URL blur
- Keeps current model selected if available, otherwise selects first in list
- Shows loading indicator while fetching
2026-04-28 09:07:53 +02:00
Oliver Hofmann
f22bad6496 Clarify Docker port binding and SSH tunnel for admin access
Use 127.0.0.1:8001:8001 to bind admin port locally only.
Explain Docker's 0.0.0.0 vs 127.0.0.1 distinction and add
SSH tunnel diagram showing how admin UI is accessed remotely.
2026-04-28 08:52:26 +02:00
Oliver Hofmann
ff5c88ecfd Remove admin port binding from docker run example
Port 8001 should not be exposed to the host directly.
Add nginx reverse proxy and SSH tunnel examples instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-28 08:41:18 +02:00
Oliver Hofmann
317c7f0340 Add Docker production build and update README
- Multi-stage Dockerfile: builds frontend, packages with Python backend
- admin.py serves frontend/dist as StaticFiles in production
- docker-entrypoint.sh runs proxy + admin-api, exits cleanly if either dies
- .dockerignore excludes .env, venv, tests, node_modules
- Split requirements.txt (prod) / requirements-dev.txt (dev+test)
- aiofiles added for StaticFiles support
- start.sh: port checks before startup, venv auto-activation, trap cleanup
- vite.config.js: clearScreen disabled
- README rewritten to reflect current architecture

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-28 08:34:45 +02:00
Oliver Hofmann
c8235ec274 Refactor to flat APIKey model with quota, admin UI, .env config, and Berlin timezone
- Remove User/Quota models; quota fields now live directly on APIKey
- Admin UI: login, API key management, settings (Ollama URL/model), proxy info display
- .env/.env.example: ADMIN_PASSWORD, PROXY_HOST/PORT, DATABASE_URL, APP_TZ
- Admin API runs on 127.0.0.1 only; proxy host/port configurable
- API keys support optional expires_at; verified against Europe/Berlin timezone
- Daily/monthly quota resets use Europe/Berlin midnight boundary
- Fix all tests to use new flat model; add expiry tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-28 08:21:42 +02:00
Oliver Hofmann
cfa874a4c3 Fix medium/low priority review items; update README
Medium:
- Frontend: Error-Handling in fetchUsers/fetchApiKeys (try/catch)
- Frontend: Loading-Race behoben (Promise.all + .finally)
- Frontend: API-Keys maskiert (nur letzte 4 Zeichen sichtbar)
- Tests: Setup-Code aus test_auth.py in conftest.py konsolidiert
- Tests: Fixture-Scope vereinheitlicht (function statt session)

Low:
- bare except in database.py → except Exception
- datetime.utcnow → datetime.now(timezone.utc) durchgängig
- DateTime(timezone=True) in allen Modell-Spalten
- .gitignore hinzugefügt (.env, *.db, __pycache__, .idea, node_modules)

Docs:
- README aktualisiert (Sicherheit, Konfiguration, Projektstruktur, Tests)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 21:48:26 +02:00
Oliver Hofmann
bf694b79e2 Fix critical/high security and correctness issues from code review
Critical (all fixed):
- bcrypt statt SHA-256 für Passwörter
- API-Keys gehasht in DB, Plaintext nur einmalig zurückgegeben
- DB-Session-Leak behoben (SessionLocal + try/finally, Depends(get_db))
- Admin-Check via is_admin-Spalte statt Hardcoded-Username
- CORS: konfigurierbare Origins via ALLOWED_ORIGINS, kein Wildcard mit Credentials

High (all fixed):
- TOCTOU-Race: check_and_increment_quota mit SELECT FOR UPDATE atomar
- Getrennte Tages-/Monatszähler in Usage + automatische Reset-Logik
- Token-Zählung mit tiktoken (cl100k_base) statt .split()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 21:34:17 +02:00
Oliver Hofmann
562f6ecd9c Init 2026-04-27 18:54:27 +02:00