Juriqa AI

Multi-Tenant AI-Powered Law Firm Intelligence Platform
Market: UAE Law Firms Languages: Arabic + English Status: Phase 7 Complete — All Pages Live Started: 2026-04-03
The Idea

Law firms in the UAE operate in a bilingual legal environment with strict data privacy requirements. Existing AI tools are cloud-based (violating privilege), expensive ($500+/seat/month), and English-only.

Juriqa AI gives every lawyer in a firm their own suite of autonomous AI agents — for research, document review, deadline tracking, billing, and compliance — all running on the firm's own infrastructure with open-source models. Arabic-first. Self-hosted. Private.

Product Flow — How It Works

1 — Firm Onboarding

Managing Partner visits app.juriqa.com/register │ ├── Enters firm name: "Al-Rashid & Partners" ├── Creates admin account (name, email, password) └── Selects default language: العربية │ ▼ System provisions in seconds: ├── Tenant schema created: firm_al_rashid_partners ├── 6 OpenClaw agents initialized (research, document, calendar, comms, billing, compliance) ├── Workspace dirs created with Arabic SOUL.md system prompts └── Admin lands on dashboard → invites team via email

2 — A Lawyer's Day

08:00 — Morning Briefing

  • Opens dashboard → sees 3 deadlines approaching (red/yellow badges)
  • Calendar Agent already sent daily digest: "DIFC filing due tomorrow"
  • Activity terminal shows overnight work: compliance scan complete, 2 documents auto-summarized

09:00 — Contract Review

  • Uploads Arabic NDA from client (عقد عدم إفصاح)
  • Document Agent processes: OCR → Jais-30B analyzes → risk flags in 2 min
  • Flags: "Non-compete clause exceeds UAE Labor Law Art. 127 limit"
  • Lawyer reviews, approves with one click

10:30 — Legal Research

  • Asks Research Agent in Arabic: "ابحث عن سوابق لخرق اتفاقية عدم الإفصاح"
  • Agent detects Arabic → routes to Jais-30B
  • Returns 3 UAE court precedents with case numbers and articles
  • Lawyer asks follow-up in English → auto-routes to Qwen-2.5-32B

12:00 — Client Communication

  • Client Comms Agent drafts bilingual status update for Al Habtoor Group
  • Arabic formal letter + English summary attached
  • Flagged for lawyer review → lawyer edits → marks approved
  • Auto-logged 0.5h to case billing

14:00 — Case Work

  • Opens case #2024-0847 → sees timeline of all agent activity
  • 3 documents reviewed, 5 precedents found, 2 deadlines tracked
  • Asks Document Agent to draft response to opposing counsel
  • Agent pulls from case context + precedents → generates draft

17:00 — End of Day

  • Billing Agent auto-generated today's entries: 6.5 billable hours
  • Compliance Agent ran evening scan: no issues found
  • Calendar Agent queued tomorrow's reminders
  • All activity logged in audit trail

3 — Firm Admin View

Admin opens /analytics │ ├── Workload Distribution │ ├── Ahmed: 142h / 5 cases ████████████████░░░ 85% │ ├── Sara: 128h / 4 cases ██████████████░░░░░ 76% │ ├── Fatima: 112h / 4 cases ████████████░░░░░░░ 67% │ └── Omar: 100h / 3 cases ██████████░░░░░░░░░ 60% │ ├── Agent Performance │ ├── Research: 312 tasks, 94% success, 12s avg │ ├── Document: 189 tasks, 97% success, 45s avg │ ├── Billing: 1240 tasks, 99% success, 2s avg │ └── Compliance: 34 tasks, 88% success, 18s avg │ ├── vLLM Usage │ ├── Jais-30B: 2,840 requests / 4.2M tokens / 890ms avg │ └── Qwen-2.5-32B: 1,560 requests / 6.8M tokens / 1.2s avg │ └── Revenue: AED 347,800 this month (AED 47,250 unbilled)

4 — How Data Flows

Lawyer types message in Chat │ ▼ Next.js Dashboard ──Socket.io──► Agent Service │ ├── Detect language (Arabic? English?) ├── Select agent (research / document / etc.) ├── Build OpenClaw config for this user │ ▼ runEmbeddedPiAgent() │ ├── Load session (conversation memory) ├── Load SOUL.md (system prompt) ├── Call vLLM ──────────────────► GPU Server │ ├── Arabic → Jais-30B │ │ └── English → Qwen-2.5-32B │ │ │ ├── Execute tools (if needed) │ │ ├── Read case files │ │ ├── Search documents │ │ └── Create deadlines │ │ │ ├── Stream response back │ │ │ ▼ │ Callbacks fire: │ ├── onPartialReply → chat stream │ ├── onToolResult → activity feed │ └── onAgentEvent → agent status │ │ │ ▼ │ Socket.io → Dashboard │ │ │ ├── Chat bubble appears (streaming) │ ├── Activity terminal updates │ ├── Agent status badge changes │ └── Time entry auto-logged │ │ All data stays on firm's VPS ◄───────────┘ (never leaves their infrastructure)
Architecture — Separated Deployment
┌─────────────────────────────────────┐ ┌───────────────────────────────┐ │ APP VPS ($30-80/mo) │ │ GPU SERVER ($580-1800/mo) │ │ No GPU needed │ │ Vast.ai / Lambda / RunPod │ │ │ │ │ │ Nginx + TLS │ │ vLLM — Jais-30B (:8000) │ │ Next.js 15 Dashboard (:3000) │ ──► │ vLLM — Qwen-2.5-32B(:8001) │ │ Agent Service + OpenClaw (:3001) │ │ bge-m3 Embeddings (:8002) │ │ PostgreSQL 17 + pgvector │ │ │ │ Redis 7 │ │ Secured via API key │ │ MinIO (documents) │ │ + Tailscale/WireGuard VPN │ │ │ │ │ │ Can serve 1-5 firms / 50 users │ │ Can serve multiple App VPSes │ └─────────────────────────────────────┘ └───────────────────────────────┘
Key Decisions

LLM Serving

  • vLLM (not Ollama) — 2-4x throughput, OpenAI-compatible API
  • Jais-2-70B — UAE-built (MBZUAI/G42), #1 Arabic model (70.7% AraGen)
  • 3 tiers: UAE Sovereign / Balanced / Max Performance
  • Admin-selectable per firm — separated GPU server, independently scalable

Multi-Tenancy

  • Schema-per-tenant PostgreSQL — strongest data isolation
  • Each firm gets own DB schema (firm_*)
  • Row-level impossible to leak across tenants
  • Easy per-firm backup/restore

Arabic Support

  • RTL-first design, not a bolt-on translation
  • CSS Logical Properties throughout
  • Surya + EasyOCR for Arabic document scanning
  • bge-m3 embeddings with Arabic morphology support
  • CAMeL Tools for tokenization/normalization

Agent Architecture

  • Built on OpenClaw — 5,400+ community skills
  • 6 agents per lawyer, isolated instances
  • Language-aware routing: Arabic → Jais, English → Qwen
  • All actions logged to audit trail
Tech Stack
Layer Technology Purpose
FrontendNext.js 15 + Tailwind 4 + shadcn/uiDashboard app
i18nnext-intlArabic + English, RTL/LTR toggle
BackendNext.js API routes + tRPCType-safe API
DatabasePostgreSQL 17 + pgvector + DrizzleMulti-tenant data + vector search
AuthBetter AuthSelf-hosted, multi-tenant
Real-timeSocket.io + Redis Pub/SubLive agent feed
LLM ServingvLLMOpenAI-compatible, PagedAttention
Arabic LLMJais-2-70B (MBZUAI/G42)#1 Arabic model — Gulf Arabic legal reasoning
Reasoning LLMQwen3.5-35B-A3B (default) / Llama 3.3-70B / Qwen3.5-122B-A10B3 tiers, admin-selectable per firm
Embeddingsbge-m3Arabic vector search (dense + sparse)
Arabic OCRSurya + EasyOCRScanned Arabic legal documents
Arabic NLPCAMeL ToolsTokenization, normalization
Agent RuntimeOpenClaw 3.22+Autonomous agent execution
File StorageMinIOS3-compatible document store
Reverse ProxyNginx + CertbotTLS, WebSocket routing
DeploymentDocker Compose (split: app + gpu)Single-command deploy
MonorepoTurborepoBuild caching, workspace management
6 Agents Per Lawyer

Research Agent

Case law lookup, statute search, precedent analysis. Searches UAE Federal Law, DIFC/ADGM regulations.

Document Agent

Contract review, drafting, summarization, risk flagging, key clause extraction. Arabic + English OCR.

Calendar Agent

Court dates, filing deadlines, statute of limitations tracking. Auto-scans documents for dates.

Client Comms Agent

Intake forms, follow-up scheduling, status updates. Manages client communication pipeline.

Billing Agent

Auto-tracks time from agent activity, categorizes by case, generates invoice data.

Compliance Agent

Flags potential ethical issues, monitors regulatory updates, filing deadline reminders.

Build Progress
Phase Tasks Status Details
1. Scaffold 2 Done Turborepo monorepo, Docker Compose (app + gpu split), Dockerfiles
2. DB & Auth 3 Done Drizzle ORM, schema-per-tenant, Better Auth, RBAC middleware
3. Dashboard Shell 4 Done i18n/RTL, sidebar, header, activity terminal, 6-panel home, auth pages
4. Core Features 5 Done Cases table + filters, Deadlines with urgency colors, Documents with AI summaries + risk flags, Billing with AED tracking, Agent Chat with mock conversations, Agents status cards
5. Agent Integration 5 Done OpenClaw runEmbeddedPiAgent(), vLLM client (Jais+Qwen), 6 agent configs with Arabic system prompts, Socket.io event wiring, language-aware routing
6. Analytics & Admin 3 Done Firm-wide metrics, workload distribution bars, agent performance table, vLLM model usage, admin settings (members, language, agent toggle)
7. Deployment 3 Done Docker Compose split (app + gpu), Nginx + Certbot TLS, CLAUDE.md, dev server verified — all 11 pages live
Live Pages (All Rendering — Mock Data)

Dashboard Pages

  • / — 6-panel grid (agents, deadlines, cases, docs, billing, activity)
  • /cases — Filterable table with UAE law firm cases
  • /deadlines — Color-coded urgency (DIFC filings, SOL)
  • /documents — Upload zone, AI summaries, risk flags
  • /billing — AED tracking, time entries with agent attribution

Agent & Admin Pages

  • /chat — Agent selector + legal research conversations
  • /agents — 6 agent cards with start/pause/restart
  • /analytics — Firm metrics, workload bars, vLLM usage
  • /settings — Members, language toggle, agent config
  • /login + /register — Auth with AR/EN switcher

Dev server: http://localhost:3000  |  Auth bypassed in dev mode  |  All data is mock — wire to DB next

OpenClaw Integration
Dashboard (Next.js) │ Socket.io ▼ Agent Service (Node.js) │ runEmbeddedPiAgent() ← openclaw/extension-api │ ├── Per-user OpenClaw instances │ ├── sessionId: juriqa-{userId}-{agentType} │ ├── workspaceDir: /workspaces/{firmId}/{userId}/{type}/ │ ├── SOUL.md: Arabic/English system prompt per agent type │ └── config: vLLM providers (jais + qwen) │ ├── Callbacks → Socket.io → Dashboard │ ├── onPartialReply → chat:response (streaming) │ ├── onToolResult → agent:event (tool use) │ └── onAgentEvent → agent:event (lifecycle) │ └── Language-aware routing ├── Arabic input → vllm-jais/jais-30b └── English input → vllm-qwen/qwen-2.5-32b
Project Structure
juriqa-ai/ ├── apps/ │ ├── web/ # Next.js 15 dashboard │ │ ├── src/ │ │ │ ├── app/ │ │ │ │ ├── (dashboard)/ # Sidebar layout + pages │ │ │ │ ├── (auth)/ # Login, Register │ │ │ │ └── api/ # Auth, Firms, Locale, Cases, Deadlines, Documents, Billing │ │ │ ├── components/ │ │ │ │ ├── layout/ # Sidebar, Header, Terminal │ │ │ │ └── ui/ # shadcn/ui components │ │ │ ├── i18n/ # next-intl config │ │ │ ├── hooks/ # useAgentEvents (real-time) │ │ │ └── lib/ # Auth, Tenant, DB, Socket.io │ │ └── messages/ # ar.json, en.json │ │ │ └── agent-service/ # Node.js agent orchestrator │ └── src/ │ ├── agents/ # orchestrator.ts, openclaw-config.ts │ ├── llm/ # vLLM client (Jais + Qwen) │ ├── events/ # Socket.io event emitter │ └── types/ # openclaw.d.ts declarations │ ├── packages/ │ ├── shared/ # Types, constants │ ├── db/ # Drizzle ORM, tenant provisioning │ ├── auth/ # Better Auth config │ └── agents/ # OpenClaw agent configs │ ├── docker/ │ ├── docker-compose.app.yml # App stack (no GPU) │ ├── docker-compose.gpu.yml # vLLM inference (GPU) │ ├── docker-compose.dev.yml # Local dev (infra only) │ ├── nginx.conf # Reverse proxy + TLS │ ├── Dockerfile.web │ └── Dockerfile.agent │ ├── specs/ │ └── platform-foundation/ │ ├── requirements.md # Approved │ ├── design.md # Approved │ └── tasks.md # 25 tasks, 7 phases │ └── DASHBOARD.html # ← You are here
Model Tiers — Admin-Selectable Per Firm
Model Origin Arabic English VRAM (4-bit) Context License
Jais-2-70BUAE (MBZUAI/G42)Best (70.7%)Moderate (78.9%)~38 GB8KApache 2.0
Llama 3.3-70BUS (Meta)Weak (63.1%)Best (92.1%)~38 GB128KLlama Community
Qwen3.5-35B-A3BChina (Alibaba)GoodGood~20 GB128KApache 2.0
Qwen3.5-122B-A10BChina (Alibaba)StrongExcellent~35 GB128KApache 2.0
bge-m3China (BAAI)StrongStrong~1 GBMIT

Tier 1 — "UAE Sovereign"

Safest compliance story. No Chinese or US model dependencies.

  • Jais-2-70B — Arabic + English (38 GB)
  • Llama 3.3-70B — English reasoning (38 GB)
  • bge-m3 — Embeddings (1 GB)

Total: ~77 GB — tight on 1x A100, comfortable on 2x GPUs
Sell: "Your AI is UAE-built and US-backed. Zero Chinese tech."

Tier 2 — "Balanced" ★ Recommended

Best Arabic + strong reasoning. Fits one GPU.

  • Jais-2-70B — Arabic everything (38 GB)
  • Qwen3.5-35B-A3B — English reasoning, MoE (20 GB)
  • bge-m3 — Embeddings (1 GB)

Total: ~59 GB — comfortable on 1x A100 80GB
Sell: "Best Arabic AI on the market + fast English reasoning."

Tier 3 — "Maximum Performance"

Strongest reasoning. For firms that want the best, origin aside.

  • Jais-2-70B — Arabic everything (38 GB)
  • Qwen3.5-122B-A10B — Top-tier reasoning (35 GB)
  • bge-m3 — Embeddings (1 GB)

Total: ~74 GB — fits 1x A100 80GB
Sell: "Most powerful legal AI available. Period."

Arabic benchmarks: AraGen-12-24 (3C3H Score)  |  English benchmarks: IFEval Strict 0-shot  |  Jais-2-70B outperforms Qwen & Llama on Arabic by 8-10%  |  Admin selects tier in Settings → applies to all firm agents

Cost Estimate

App VPS

  • Hetzner CX32: $15/mo (8 vCPU, 32GB)
  • DigitalOcean: $48/mo (8 vCPU, 16GB)
  • No GPU required
  • Handles 50 users / 3-5 firms

GPU Server

  • Vast.ai A100: ~$580/mo
  • Lambda A100: ~$800/mo
  • RunPod A100: ~$1,200/mo
  • Shared across all App VPSes

Break-Even

  • Enterprise AI: $500+/seat/month
  • Juriqa total: ~$600-1,200/mo
  • Pays for itself with 2-3 lawyers
  • Free after that — pure margin
Compound Engineering — Learnings
2026-04-03
Monorepo + Next.js Package Resolution
Use extensionless imports in workspace packages when transpiled by Next.js. DB client must be lazy-initialized — no top-level process.env reads at build time. shadcn/ui sidebar uses render prop, not asChild.
2026-04-03
postgres.js unsafe() Type Safety
sql.unsafe() expects typed params, not unknown[]. Use as any for dynamic query params — acceptable since we're already in unsafe territory.
2026-04-03
OpenClaw Real Integration
Import runEmbeddedPiAgent from openclaw/extension-api (NOT plugin-sdk). No .d.ts shipped — manual type declarations needed. Per-user isolation via separate workspace dirs and session files. SOUL.md in workspace acts as system prompt. Config built dynamically per user with vLLM providers.
2026-04-03
Google Fonts + Tailwind CSS
Don't use @import url() in CSS with Tailwind — Tailwind's processing pushes it below other rules. Use <link> tags in layout.tsx <head> instead for Arabic fonts (Noto Naskh/Kufi Arabic).
Specifications Summary

Requirements

  • 11 user stories (admin, lawyer, paralegal)
  • 8 functional requirement groups
  • 5 non-functional requirements
  • UAE Federal, DIFC, ADGM jurisdictions
  • Arabic + English from v1

Design

  • 6 architecture decisions
  • 9 tables per tenant + 1 shared
  • Full REST + WebSocket API contracts
  • Sequence diagrams for all flows
  • Dashboard layout wireframe

Tasks

  • 25 tasks across 7 phases
  • Each with acceptance criteria
  • Complexity rated S/M/L
  • Dependency graph defined
  • 25 of 25 complete
Database Schema (Per Tenant)
public.firms ──────────────────── Tenant registry (id, name, slug, schema_name, locale) │ └── firm_{slug}.* ────────── One schema per firm: ├── users id, firm_id, email, name, role, locale ├── agents id, user_id, type (6 types), status, model ├── cases id, title, case_number, status, assigned_to ├── deadlines id, case_id, due_date, type, urgency (computed) ├── documents id, case_id, filename, ai_summary, risk_flags ├── agent_events id, agent_id, event_type, title, detail ← live feed ├── time_entries id, user_id, case_id, duration_min, billable ├── messages id, user_id, agent_id, role, content └── embeddings id, document_id, chunk_text, vector(1024) ← pgvector