CoolFace
Apppublic

SameerInfinity/AI_DD

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
README.md273 linesDownload Raw Back to root
1---2title: ABYSS AI DD3emoji: ๐ŸŒŠ4colorFrom: blue5colorTo: indigo6sdk: docker7pinned: false8---9 10# ABYSS โ€” AI-Powered M&A Due Diligence Virtual Data Room11 12A multi-party Virtual Data Room (VDR) platform for mergers & acquisitions due diligence. Upload documents, get perspective-specific AI analysis with structured findings, risk scores, and source citations. Supports Buy Side, Sell Side, and Admin workflows with role-based access, request lists, audit trails, and Human-in-the-Loop review.13 14**Live:** [Frontend (Vercel)](https://abyss-ai-dd.vercel.app) | [Backend (HF Spaces)](https://sameerinfinity-ai-dd.hf.space)15 16## Architecture17 18```19โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”20โ”‚                FRONTEND (React 18 + TypeScript + Vite 8)        โ”‚21โ”‚  Auth โ†’ Perspective โ†’ Projects โ†’ Data Room / Q&A / Audit       โ”‚22โ”‚  UI: shadcn/ui + Tailwind  |  State: Zustand + React Query     โ”‚23โ”‚  Theme: Ocean dark + Sunny light  |  Code-split (React.lazy)   โ”‚24โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜25                          โ”‚ REST API (JWT Auth)26โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”27โ”‚                   BACKEND (FastAPI + async)                      โ”‚28โ”‚                                                                  โ”‚29โ”‚  Auth โ”€ Projects โ”€ Teams โ”€ Documents โ”€ Requests โ”€ Queries       โ”‚30โ”‚  Folders โ”€ DD Tests โ”€ Routines โ”€ Planning โ”€ Finance โ”€ Export    โ”‚31โ”‚  Knowledge โ”€ Self-Improvement โ”€ VDR Security                    โ”‚32โ”‚                                                                  โ”‚33โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚34โ”‚  โ”‚         OCR โ†’ Chunker โ†’ Embeddings โ†’ Vector Store          โ”‚  โ”‚35โ”‚  โ”‚    (PyMuPDF / Tesseract โ†’ Semantic Split โ†’ Pinecone EU)    โ”‚  โ”‚36โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚37โ”‚                                                                  โ”‚38โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚39โ”‚  โ”‚              AI PIPELINE (8-Step State Machine)             โ”‚  โ”‚40โ”‚  โ”‚  Rewrite โ†’ Classify โ†’ Retrieve โ†’ Completeness              โ”‚  โ”‚41โ”‚  โ”‚  โ†’ Think (Groq) โ†’ Audit โ†’ Structure โ†’ Done                 โ”‚  โ”‚42โ”‚  โ”‚  + Review feedback injected into system prompt              โ”‚  โ”‚43โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚44โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜45         โ”‚                โ”‚                 โ”‚46   โ”Œโ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”47   โ”‚ Supabase   โ”‚  โ”‚   Pinecone   โ”‚  โ”‚ Supabase       โ”‚48   โ”‚ PostgreSQL โ”‚  โ”‚  (vectors)   โ”‚  โ”‚ Storage (files) โ”‚49   โ”‚  (EU)      โ”‚  โ”‚  (EU)        โ”‚  โ”‚  (EU)          โ”‚50   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜51```52 53## Tech Stack54 55| Layer | Technology |56|-------|-----------|57| **Frontend** | React 18.3 + TypeScript + Vite 8 (SWC), code-split via React.lazy |58| **UI** | shadcn/ui + Tailwind CSS + Radix UI + Framer Motion |59| **State** | Zustand 5 + TanStack React Query 5 (5-min staleTime cache) |60| **Forms** | React Hook Form 7 + Zod validation |61| **Theme** | Dark (ocean abyss) + Light (sunny ocean) with smooth 400ms transition |62| **Export** | jsPDF + html2canvas (PDF), python-docx (DOCX), openpyxl (XLSX) |63| **Backend** | FastAPI 0.115 + Uvicorn (fully async) |64| **Database** | Supabase PostgreSQL EU (SQLAlchemy AsyncSession + asyncpg) |65| **File Storage** | Supabase Storage EU (with local fallback) |66| **LLM** | Groq โ€” Llama 3.3 70B Versatile |67| **Embeddings** | sentence-transformers (all-MiniLM-L6-v2), 384-dim, local |68| **Vector DB** | Pinecone serverless EU (local in-memory fallback) |69| **OCR** | PyMuPDF + Tesseract (digital + scanned PDFs, images) |70| **Auth** | JWT (python-jose) + bcrypt + Google OAuth + email verification |71| **Email** | Brevo (verification, password reset, project invitations) |72 73## All 11 Modules74 75### 1. Auth Module76- Register, login, Google OAuth, email verification (Brevo), password reset77- 8 analyst perspectives (set once, changeable from sidebar)78- 5 project roles: Admin, Buy Side (Legal/Tax/Commercial), Sell Side79- Email-based project invitations (admin sends, user accepts/declines)80- Session management with global 401 redirect81 82### 2. Project Module83- Create, rename, delete projects with extended fields (legal form, deal type, country, employees, revenue, deal value)84- Email invitation system (replaced invite codes)85- Team management with role badges and activity feed86- VDR security settings (watermarks, download restrictions per role)87 88### 3. DMS Module (Data Room)89- Upload PDFs, DOCX, XLSX, CSV, images, plain text90- Nested folder structure with directory upload91- Document versioning, AI auto-tagging, full-text search92- Professional list-view file manager93- Language detection (AI responds in document language)94- Document watermarks (username + date overlay, configurable)95 96### 4. OCR Module97- PyMuPDF for digital PDFs, Tesseract for scanned documents98- python-docx for Word, pandas + openpyxl for Excel/CSV99- Semantic chunking (1200 chars, 150 overlap) โ†’ Pinecone indexing100- Reprocess-all endpoint for failed documents101 102### 5. Agent Module (AI Pipeline)103- 8-step pipeline: Rewrite โ†’ Classify โ†’ Retrieve โ†’ Completeness โ†’ Think โ†’ Audit โ†’ Structure โ†’ Complete104- 8 perspective-specific system prompts105- Citation enforcement, confidence scoring, red flag detection106- Human-in-the-Loop review (Approve/Edit/Reject) on all AI outputs107- Review feedback injected into system prompt (AI learns from corrections)108 109### 6. Planning Module110- Interactive AI-guided audit planning dialog111- AI analyzes project profile, asks 4-6 targeted risk questions112- Auto-generates DD request list by workstream113- Sessions persisted โ€” visible to all team members114- Past sessions viewable in read-only mode115 116### 7. Finance Module117- Upload accounting data (Excel/CSV), auto-detect SKR 03/SKR 04118- Range-based account mapping (100+ German standard account ranges)119- Journal entry format support (debit/credit per row)120- Balance sheet items excluded from P&L automatically121- Variance analysis: Month-over-Month, Year-over-Year, anomaly detection (>30%)122- Key metrics: EBITDA margin, gross margin, net margin, personnel ratio, equity ratio, ROA123 124### 8. Report Module125- PDF export: Q&A analysis with structured findings, TOC, confidence bars126- DOCX export: Full DD report with request list, test results, Q&A summary127- XLSX export: Workstream sheets with status, scores, findings128- Editable executive summary (write or AI-generate before export)129- Download restrictions enforceable per role130 131### 9. Knowledge Module132- 20 built-in IDW/M&A standards (Legal, Tax, Commercial, General)133- Auto-seeded on first access, filterable by category134- AI-generated cross-project insights ("Generate Insights" button)135- User-level, accessible from Projects page136 137### 10. Audit Module138- Completeness audit: AI cross-checks documents against request list139- Per-field DD tests with pass/fail/warning scoring140- Custom test routines with user-defined prompts141- Results persisted โ€” load on revisit, shows "Last run by [name]"142- Activity log: human-readable action labels, user/IP tracking143- Cookie consent + GDPR privacy policy144 145### 11. Self-Improvement Module146- Usage analytics: projects, queries, uploads, tests, reviews147- 30-day activity heatmap148- AI review patterns: approve/edit/reject rates with contextual messages149- Actionable recommendations: missing docs, open requests, unrun audits150- User-level, accessible from Projects page151 152## Performance153 154| Optimization | Effect |155|-------------|--------|156| **Route-based code splitting** | Main bundle 970KB โ†’ 361KB (63% smaller). Each page loads on-demand. |157| **Hover preloading** | Page chunks preload on sidebar hover โ€” zero blink on first visit. |158| **React Query cache** | 5-min staleTime, no refetch on tab switch. Data survives page navigation. |159| **Splash skip** | Repeat visits within session skip 4s splash animation. |160| **Smart polling** | Exponential backoff (2s โ†’ 30s), stops when idle. Zero requests when nothing processing. |161| **Theme transition** | Temporary 400ms CSS transition class โ€” only color/bg/border, no layout cost. |162 163## Pages (21 total)164 165| Page | Route | Description |166|------|-------|-------------|167| Sign In | `/signin` | Email/password + Google OAuth |168| Sign Up | `/signup` | Registration with password strength checklist |169| Verify Pending | `/verify-pending` | Email verification waiting page with resend |170| Verify Email | `/verify-email` | Token verification from email link |171| Forgot Password | `/forgot-password` | Request password reset email |172| Reset Password | `/reset-password` | Set new password with strength checklist |173| Perspective | `/role` | 8 analyst perspectives (shown once after signup) |174| Projects | `/projects` | Create projects, accept/decline invitations |175| Knowledge | `/knowledge` | DD standards + AI cross-project insights |176| Insights | `/insights` | Usage analytics + AI review patterns |177| Q&A | `/dashboard` | AI query interface with branching conversations |178| Planning | `/planning` | Interactive audit planning with session history |179| Requests | `/requests` | Request list with workstream tabs + per-item upload |180| Data Room | `/dataroom` | File manager with folders, search, versions, watermarks |181| Finance | `/finance` | Accounting import, variance analysis, key metrics |182| Audit | `/audit` | Completeness audit, field tests, custom routines |183| Upload | `/upload` | Drag & drop upload with progress tracking |184| Activity | `/activity` | Full audit trail with human-readable actions |185| Team | `/team` | Members, invitations, VDR security settings, activity feed |186| Privacy | `/privacy` | GDPR privacy policy |187| 404 | `*` | Not found page |188 189## Database Schema (19 Tables)190 191| Table | Purpose |192|-------|---------|193| **users** | Accounts with perspective (8 types), email verification |194| **projects** | Deal containers with extended fields, VDR security settings |195| **project_members** | Per-project role assignments (admin/buy/sell) |196| **project_invites** | Email invitations with accept/decline status |197| **documents** | Files with versioning, tags, language, OCR status |198| **chunks** | Indexed text segments with Pinecone IDs + page numbers |199| **folders** | Nested folder structure for data room |200| **conversations** | Chat thread branches per project/user |201| **queries** | Questions + pipeline state + Human-in-the-Loop review |202| **pipeline_steps** | Step-by-step tracking with I/O + duration |203| **request_items** | DD request list items with workstream + status |204| **dd_test_results** | Due diligence test results with findings |205| **test_routines** | User-defined custom test prompts |206| **audit_logs** | Full activity trail: who, what, when, IP |207| **audit_results** | Saved completeness audit results with history |208| **planning_sessions** | Persisted planning conversations |209| **financial_datasets** | Uploaded accounting files metadata |210| **financial_entries** | Parsed accounting line items |211| **knowledge_entries** | DD standards + AI-generated insights |212 213**Enums:** `UserRole` (5), `Perspective` (8), `Workstream` (4), `InviteStatus` (4), `DocStatus` (4), `QueryStatus` (9), `RequestStatus` (5), `Severity` (5)214 215## Environment Variables216 217| Variable | Required | Description |218|----------|----------|-------------|219| `DATABASE_URL` | Yes | PostgreSQL connection (async: `postgresql+asyncpg://...`) |220| `JWT_SECRET` | Yes | Secret key for JWT tokens |221| `GROQ_API_KEY` | Yes | Groq API key for Llama 3.3 70B |222| `SUPABASE_URL` | Yes | Supabase project URL |223| `SUPABASE_SERVICE_KEY` | Yes | Supabase service role key |224| `BREVO_API_KEY` | Yes | Brevo API key for transactional emails |225| `BREVO_FROM_EMAIL` | Yes | Verified sender email address |226| `FRONTEND_URL` | Yes | Frontend URL for email links |227| `PINECONE_API_KEY` | No | Pinecone API key (falls back to local) |228| `PINECONE_REGION` | No | Pinecone region (default: `eu-west-1`) |229| `GOOGLE_CLIENT_ID` | No | Google OAuth client ID |230| `EMBEDDING_MODEL` | No | Embedding model (default: `all-MiniLM-L6-v2`) |231 232## Quick Start233 234```bash235# 1. Clone236git clone https://github.com/SameerInfinity/AI-Due-Diligence.git237cd AI-Due-Diligence238 239# 2. Backend240python -m venv .venv241source .venv/bin/activate        # Windows: .venv\Scripts\activate242pip install -r requirements.txt243 244# 3. Frontend245cd frontend && npm install && cd ..246 247# 4. Configure248cp .env.example .env249# Edit .env with your keys250 251# 5. Run backend252uvicorn backend.main:app --reload --port 8000253 254# 6. Run frontend (new terminal)255cd frontend && npm run dev256```257 258## Deployment259 260| Service | Platform | Region |261|---------|----------|--------|262| Backend | HuggingFace Spaces (Docker) | EU |263| Frontend | Vercel (Edge CDN) | Global |264| Database | Supabase PostgreSQL | EU West (Paris) |265| File Storage | Supabase Storage | EU |266| Vector DB | Pinecone | EU West (Ireland) |267| Email | Brevo | Global |268| Redis | Upstash | EU |269 270## License271 272Private โ€” All rights reserved.273