← All projectsProject · SaaS · AIDeskwise
A private, multi-tenant AI knowledge base for organizations. Bring your own documents, ask questions in plain language, and get grounded answers with citations — only from what the asking user is actually allowed to see.
The problem
Companies sit on hundreds of documents — HR policies, contracts, SOPs, reports. Finding an answer usually means digging through folders or interrupting a colleague. Public AI chatbots are not an option: company data would leave the tenant boundary, answers are not traceable to a source, and there is no per-document or per-person access control.
Deskwise is a self-hostable answer to that. It is a document repository where every question is answered only from documents the asking user may see, with citations, audit trails, and per-company feature control.
What it does
Permission-aware RAG chat
Hybrid retrieval — 70% dense pgvector cosine, 30% BM25 keyword with stemming — scoped to the documents the caller is allowed to see. Answers stream with exact citations, and the assistant says plainly when the documents do not contain the answer.
Strict multi-tenancy
Every document, chunk, user and audit row carries a company foreign key, and every query filters by it. Cross-tenant leakage is prevented at the database query layer and probed by a dedicated isolation test matrix.
Least-privilege ACLs
Three scopes per document — company, department, or named individuals — plus one-document shares with partner companies, with download control and instant revocation.
Team chat with @DeskWise
Real-time rooms over Django Channels: typing, presence, replies, pins, reactions, attachments and an AI participant that answers from company documents inside the conversation. REST and WebSocket paths share the same permission checks.
Deterministic DocGen
HR forms, leave requests, expense claims and official letters are filled by a rule-based template engine from real profile data — no hallucinated names, dates or amounts — then exported to .docx, .pdf, .md or .txt.
BYO AI, zero-cloud option
Adapters for Amazon Bedrock, Gemini, OpenAI and Anthropic, plus a fully offline local Ollama path. Provider keys are encrypted at rest, custom endpoints pass an SSRF guard, and embedding-model drift flags documents for re-indexing.
How it works
One origin, three ECS services and one Terraform stack. The web and API share a single ALB origin so HttpOnly cookie sessions work without cross-site workarounds.
Route 53 → ALB (TLS 1.3)
├─ /api/* → Django (gunicorn) → RDS PostgreSQL 16 + pgvector
│ → ElastiCache Redis
│ → S3 (versioned, tenant-prefixed)
│ → Bedrock via IAM task role (no API keys)
├─ /* → Next.js standalone (ECS Fargate)
└─ WebSocket → Django Channels (+ channels-redis)
Celery worker: extract → chunk → embed (1024-d) → pgvector
EventBridge nightly: pg_dump → encrypted backups bucket
- Ingestion. Browser uploads land in S3 under a tenant-prefixed key; a Celery worker extracts (PDF, DOCX, PPTX, TXT, MD, CSV, with OCR fallback), chunks, embeds at 1024 dimensions and writes vectors into PostgreSQL.
- Retrieval. A question is embedded, matched with pgvector KNN over the caller’s allowed documents, reranked with BM25, and streamed back as NDJSON — sources first, then tokens.
- Keyless AI on AWS. Model calls authenticate with the ECS task role, scoped to specific Bedrock model ARNs. There are no model API keys in the application.
- Deploys. GitHub Actions authenticates to AWS through OIDC, stages first, and separates build, plan and apply roles. Infrastructure is linted with tflint and scanned with Checkov (258 checks passing).
Security & correctness
- HttpOnly JWT sessions. 15-minute access plus rotating 7-day refresh cookies; tokens never touch localStorage, and refresh tokens are blacklisted on logout, reset or rotation.
- Rate limiting. Sliding-window limiters backed by Redis protect login, registration, password resets and search.
- Encrypted provider keys. Per-tenant LLM credentials are encrypted at rest with Fernet (AES-128-CBC + HMAC-SHA256) and never returned by the API.
- SSRF guard. Customer-supplied LLM base URLs are validated against private and metadata addresses, https only.
- Tenant isolation. Every retrieval, search and admin query scopes by company at the query layer, not the view layer, with tests that probe direct-ID access across tenants.
- Verified tests. 293 backend tests cover isolation, ACL edge cases, feature guards, billing failure paths, MFA, crypto and pgvector behaviour; 20 frontend Vitest tests cover the client.
Measured performance
Load-tested locally with k6 against a ~1,000-chunk corpus and a simulated 150 ms model latency, measuring the retrieval and streaming pipeline itself:
- 15 ms median time-to-first-byte for a single user, and 172 ms median at 5–15 concurrent users. This is retrieval time; real model latency adds on top.
- 0% errors across 176 streamed asks at 15 concurrent users; authenticated browse endpoints stayed under 1.5 s at p95 with 10 users.
These numbers come from a local Docker host with SQLite and a fake provider. They compare the application’s own retrieval and streaming cost, not AWS capacity — the launch shape is one API task at 0.5 vCPU / 1 GiB, scaling on CPU.
Engineering decisions I’d highlight
- Tenancy is a query invariant, not a conventionIsolation lives in the database query layer with a dedicated test matrix, so a developer cannot forget a filter and leak another tenant's document.
- Deterministic documents next to generative chatAnything that becomes an official HR or legal document is filled by rules from profile data. Chat stays generative where that is the right tool; paperwork does not.
- Fail-safe legal featuresAttendance discipline ships warn-only. The system records and flags, and a human decides — the worst automation failure in HR is an account locked by a bug.
- Streaming as a contractThe first stream event carries the cited sources, so users see retrieval working before the first token, and pipeline latency stays measurable separately from model latency.
- Feature flags per tenantThe same deployment serves document-search-only companies and full HR suites; toggles hide the UI and return 403 at the API, so the boundary is enforced once.
Status & links
Deskwise is live and proprietary, built end to end by me: design, Django and DRF backend, Next.js frontend, Terraform infrastructure, tests and documentation. Local setup is one command; the same stack runs on Docker Compose or the AWS Terraform modules.