dotb_ai-platform/stack.md
hungtran24 6577bb74be refactor: simplify scoring service, AI profile revisions and test suite
Phase 2 and 3 of the platform rework.

- Neutral request/response contract: external_id, metadata, X-AI-Key,
  run_id in the response; client-specific fields removed.
- AI profile is a revision table: saving creates an inactive revision,
  activation is separate, try-run does not store a run. One
  chat-completions gateway serves AIHub and OpenAI-compatible profiles.
- Add between and in rule operators.
- Contracts moved to contracts/lead-scoring/ with a score-response fixture.
- Admin Web updated for revisions, runs and the neutral fixture.
- Consolidate tests; remove rewrite_architect.md and the stale handoff doc;
  rewrite spec, CONTEXT and ARCHITECTURE for the current design.

Not verified: live AIHub/OpenAI behavior, Omni/EMS integration.
2026-10-09 08:23:21 +07:00

12 lines
1.7 KiB
Markdown

# Technology Stack
This records adopted rebuild decisions, not proof that deployment or integration has passed. See `docs/specs/ai-platform-lead-scoring.md` for behavior and `ARCHITECTURE.md` for placement.
- Backend: Python 3.13, uv, FastAPI/Pydantic at HTTP boundary, PostgreSQL 16+ with SQLAlchemy async + **asyncpg**, Alembic. Domain uses Python values and pure functions; no transport/ORM models inside it.
- Runtime: one backend process, ephemeral asyncio tasks; PostgreSQL owns run durability, unique idempotency and transactional outbox. Startup terminalizes lost work before readiness. No broker/Redis or distributed leases in v1.
- AIHub: the client supplies its AI key per request in `X-AI-Key` (RAM only). The active AI profile revision chooses AIHub or an OpenAI-compatible endpoint, its URL, model and timeout. The optional server-side OpenAI key is sent only to `AI_PLATFORM_OPENAI_BASE_URL`. Only development permits loopback HTTP; production URLs require HTTPS. Actual provider protocol, model and quotas require sandbox verification.
- Admin Web: SvelteKit 5, TypeScript 5, Bun, adapter-node after runtime verification; generated types from FastAPI OpenAPI, server-only session/backend access. DotB-Omni owns business UI.
- Tooling: pytest, Ruff, Pyright, Import Linter, Alembic lifecycle, Svelte check/Vitest and one browser flow; pre-commit opt-in, GitHub CI authoritative. uv/Bun lockfiles required. Dockerfiles separate for backend and web; Compose local only.
Before production choose hosting, TLS/proxy, secret manager, DB backup/restore and retention, alerts/on-call and deployment verification. Never imply local Compose alone establishes production readiness.