Commit graph

4 commits

Author SHA1 Message Date
Vadym Samoilenko
2822e9cb99 fix: pricing engine unit keys and google→vertex_ai provider alias
- compute_total_cost: read token_input/token_output/char (new keys)
  with fallback to old input_tokens/output_tokens/chars for compat
- _PROVIDER_ALIAS: google/gemini → vertex_ai-language-models
- _infer_provider: gemini → vertex_ai-language-models

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 14:41:14 +01:00
Vadym Samoilenko
954e7c21eb fix: audit log ObjectId serialization, add user PATCH/DELETE endpoints
- _str_id now recursively converts ObjectId in nested before/after fields
- PATCH /admin/users/:id — edit email, full_name, role, workspace_id
- DELETE /admin/users/:id — remove user mirror record
- Users frontend: inline edit form + delete button

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 14:22:06 +01:00
Vadym Samoilenko
53d0367b94 feat: dev login + optical-dev deploy setup
Backend:
- routes_auth: POST /v1/auth/dev-login — bypass Azure AD (disabled in production),
  creates admin in DB and sets JWT cookie; takes email + full_name
- routes_auth: use settings.frontend_callback_url instead of parsing CORS origins
  for SSO post-login redirect — configurable per environment
- config: add frontend_callback_url setting
- dependencies: fix get_current_admin — was querying _id as string (ObjectId bug)
  and filtering is_active:True (never set by SSO flow)

Frontend:
- Login.tsx: dev login form shown in non-production builds below SSO button
- api.ts: use import.meta.env.BASE_URL so API paths work under any subpath prefix
- main.tsx: pass BASE_URL as BrowserRouter basename for correct SPA routing
- vite.config.ts: read VITE_BASE_PATH env var to set Vite base (default /)
- nginx.conf: serve app at /cost-tracker/ prefix, proxy API routes internally
- Dockerfile: accept VITE_BASE_PATH build arg, copy build to /cost-tracker/ subdir

Infra:
- docker-compose.yml: API host port 8003 (8001 taken by ppt-tool on optical-dev)
- infra/deploy/apache-cost-tracker.conf: Apache include for optical-dev routing
- infra/deploy/deploy.sh: one-shot deploy script (clone/pull, build, Apache config)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 12:05:42 +01:00
Vadym Samoilenko
2f070ce503 feat: initial implementation of Oliver AI Cost Tracker
Complete Phase 1 implementation:

Backend (FastAPI + MongoDB + Celery):
- Core: config, DB with indexes, JWT security, API key auth middleware
- Models: org hierarchy (workspace/team/project), user mirror, pricing,
  usage events/rollups, budgets, alert log, audit log
- Services: pricing engine (LiteLLM/YAML/override priority), budget check
  with preflight, email alerts at 50/80/100%, analytics aggregations,
  audit logger
- API routes: public (preflight/record/upsert), admin CRUD, pricing
  management, budget management, analytics (summary/timeseries/breakdown/pivot),
  Microsoft SSO auth
- Celery tasks: daily LiteLLM price sync with change notifications,
  daily rollup aggregation, 5-minute alert evaluator
- Pricing catalogue: ElevenLabs + Google Cloud TTS in models.yaml

SDK (oliver-cost-tracker Python package):
- CostTracker client with httpx + exponential backoff (3 retries)
- SQLite outbox with 30s background flusher (never blocks AI pipeline)
- Estimators: token/char estimation per provider
- BudgetExceeded / CostTrackerUnavailable exceptions

Frontend (React 18 + Vite + TypeScript):
- Dashboard with KPI cards, daily cost timeseries, top-model/top-user charts
- Pivot Explorer with multi-dim row/col selection + stacked bar chart + table
- Admin pages: Workspaces, Pricing (with LiteLLM sync + override), Budgets
  (with live spend bar), API Keys (show-once), Users (mirror), Audit Log
- Microsoft SSO login flow

Infra: docker-compose.yml (mongo + redis + api + celery worker + beat + frontend)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 11:26:08 +01:00