From a57f5f095191284ed73b897a4d092ab73d82c81b Mon Sep 17 00:00:00 2001 From: Anais Saraiva Date: Tue, 22 Sep 2026 09:00:19 +0200 Subject: [PATCH] Now can be powered by postgres sql --- .env.example | 3 + AGENTS.md | 5 +- README.md | 9 +- docs/ARCHITECTURE.md | 22 ++- docs/OPERATIONS.md | 31 ++- module.nix | 11 ++ src/access.ts | 137 +++++++------ src/auth.ts | 28 ++- src/config.ts | 5 + src/db.ts | 311 +++++++++++------------------ src/db/client.ts | 445 ++++++++++++++++++++++++++++++++++++++++++ src/index.ts | 287 ++++++++++++++------------- src/modelPolicy.ts | 59 +++--- src/reports.ts | 97 ++++----- src/tools/ocr.ts | 10 +- src/tools/registry.ts | 16 +- src/tools/types.ts | 7 +- src/totp.ts | 57 +++--- src/userProviders.ts | 39 ++-- 19 files changed, 1026 insertions(+), 553 deletions(-) create mode 100644 src/db/client.ts diff --git a/.env.example b/.env.example index 5462678..0ca80ec 100644 --- a/.env.example +++ b/.env.example @@ -11,6 +11,9 @@ APP_PASSWORD=change-me SESSION_TTL_HOURS=720 # Data dir: holds kisassistant.db (SQLite: users, sessions, chats, shares) DATA_DIR=./data +# Postgres fallback (typically a docker container). Empty = local SQLite. +# Example: POSTGRESQL_URL=postgres://kisassistant:secret@localhost:5432/kisassistant +POSTGRESQL_URL= # Local file CDN (avatars). NixOS module points it under the state dir. CDN_DIR=./cdn # Local file CDN (avatars today, more namespaces tomorrow). diff --git a/AGENTS.md b/AGENTS.md index ecc84f1..ea90c16 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -6,7 +6,8 @@ Read this before touching the code. Docs live in `docs/` (English). KisAssistant — private ChatGPT-like assistant. Bun backend (single process, serves API + static frontend), React 18 + Vite + Tailwind 3 + lucide-react -frontend, SQLite persistence via Bun's native `bun:sqlite` driver. +frontend, SQLite persistence by default via Bun's native `bun:sqlite` driver +(Postgres fallback via native `bun:sql` when `POSTGRESQL_URL` is set). ## Commands (run from repo root unless noted) @@ -45,7 +46,7 @@ flake.nix/module.nix NixOS packaging + service module - Frontend styling: Tailwind only, emerald accent, `rounded-2xl/3xl` everywhere, `dark:` variants on every surface. Inter Variable font (self-hosted, no CDN). - Icons: lucide-react only. **Never use native `