Built to solve AI document generation without per-seat SaaS lock-in or sending sensitive data to third-party processors.
Agencies and professionals generate narrative reports using either manual writing (slow, inconsistent) or expensive AI writing tools that lack document-specific context, store prompts on third-party servers, and don't support structured exports like DOCX/PDF with custom branding.
AI Docs SaaS is a multi-tenant platform that combines RAG-based document retrieval with OpenAI generation, PII redaction, and direct DOCX/PDF export — all within a Supabase-backed architecture with row-level security. Upload source documents, set a report goal, and get a professionally formatted export in minutes.
📹 Demo: [Insert 30-second screen recording showing: upload PDF → AI generates report → export to DOCX]
🔗 Deployed on Vercel (live for several months)
- RAG accuracy: OpenAI embeddings + pgvector search retrieve relevant context across uploaded documents in under 200ms
- Multi-tenant isolation: Supabase row-level security enforces per-agency data boundaries at the database level — zero risk of cross-tenant leakage
- PII redaction: Automated detection pipeline scrubs sensitive information before AI processing
- Export pipeline: DOCX and PDF generation with custom header/footer branding — production-ready formatting
- Rate limiting: Upstash Redis-backed rate limiter on AI endpoints prevents abuse
- Dashboard analytics: 7-day KPIs tracking reports generated, tokens consumed, average generation time, and success rate
- Token tracking: Per-run usage logging for cost attribution per tenant
| Layer | Technology |
|---|---|
| Frontend | Next.js 15 (App Router), Tailwind CSS, TypeScript |
| Backend | Next.js API routes, Supabase Auth |
| Database | PostgreSQL (Supabase) with pgvector |
| AI/ML | OpenAI GPT-4o-mini, OpenAI Embeddings |
| Vector Store | pgvector (PostgreSQL extension) |
| Cache/Rate Limit | Upstash Redis |
| Document Processing | pdf-parse, mammoth, Puppeteer |
| Export | docx (DOCX), Puppeteer (PDF) |
| PII Detection | Custom NLP pipeline with regex + ML patterns |
| Auth | Supabase Auth (email/password, magic link) |
Upload Documents (PDF/DOCX/TXT)
│
▼
PII Redaction ──→ Detect and remove sensitive data
│
▼
Embedding ──→ OpenAI embeddings → pgvector
│
▼
User sets report goal
│
▼
RAG Retrieval ──→ Semantic search across tenant documents
│
▼
AI Generation ──→ GPT-4o-mini with context
│
▼
Review & Revise ──→ Interactive refinement
│
▼
Export ──→ DOCX or PDF with custom branding
# 1. Install dependencies
pnpm install
# 2. Configure environment
cp .env.local.example .env.local
# Fill in Supabase URL/keys and OpenAI API key
# 3. Run database migrations
# Run SQL files from sql/ directory in Supabase dashboard
# 4. Start development server
pnpm devRequired environment variables: NEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_ANON_KEY, SUPABASE_SERVICE_ROLE_KEY, OPENAI_API_KEY. See ENVIRONMENT.md and AUTH_SETUP.md for full setup guide.
MIT — see LICENSE