# Dealspace AI - Lovable Prototype Specification > Generated from file tree analysis of Misha's Lovable prototype ## Overview Dealspace AI is a data room platform for M&A transactions with AI-powered diligence assistance. It provides role-based access for sellers and buyers with different views and capabilities. ## Architecture ### Frontend (React/TypeScript) - **Pages**: Analytics, AuditLog, Auth, Contacts, Dashboard, DealRoom, DealRooms, ICMemos, RequestList, Settings, PlatformGuide - **Components**: AppLayout, AppShell, AtlasGlobalChat, AtlasSidebar, DealRequestsPanel, NavLink - **Hooks**: useAuth, useOrganization, useTheme, useUserRole - **Lib**: api, utils - **UI Framework**: Shadcn/UI components (extensive component library) ### Backend (Supabase) - **Database**: PostgreSQL with RLS (Row Level Security) - **Edge Functions**: 5 serverless functions for AI and business logic - **Auth**: Supabase authentication with demo mode ## Database Schema (Inferred) Based on migration files found: 1. `20260214204302_ecf07ab9-408c-4285-aaa7-fa863ab0bf44.sql` 2. `20260214210921_76c3250f-a80f-48c6-811e-bd63c5df73b9.sql` 3. `20260214212128_b9b50ed5-01a1-452c-8980-08cf8f01de07.sql` 4. `20260214222633_87b2d0bd-eb15-4756-8276-688939090180.sql` 5. `20260214224626_6cd97efe-10ea-46f3-9127-62bbc9d89cba.sql` The database likely contains tables for: - Organizations - Users and roles (seller/buyer/admin) - Deals and deal rooms - Documents and folders - Diligence requests - Comments and audit logs - Buyer groups and permissions ## Atlas AI System Edge functions identified: 1. **atlas-chat**: AI chat interface for document questions 2. **compute-deal-score**: Calculate deal risk/completion scores 3. **demo-login**: Demo account creation for testing 4. **folder-summary**: AI-generated folder/document summaries 5. **generate-ic-memo**: Investment Committee memo generation ## User Roles & Features ### Seller (Owner) Role - Full dashboard access - Create and manage deal rooms - Upload documents and organize folders - Manage diligence request lists - View analytics and audit logs - Manage contacts and settings - **No IC Memo access** ### Buyer (Viewer) Role - Limited dashboard (only assigned deals) - View deal rooms they have access to - See only their buyer group's request lists - IC Memo generation tool - Platform guide access - **No analytics, contacts, audit logs, or settings** ## Key Features ### 1. Deal Management - Deal rooms with folder organization - Document upload and management - Deal timelines (IOI, LOI, exclusivity tracking) - Deal status and stage tracking ### 2. Request Lists - Buyer group segmentation - Seller and buyer comment columns - Atlas AI status tracking (fulfilled/partial/missing) - CSV import/export capability - Confidence scoring ### 3. Atlas AI Integration - Document chat interface - Folder summaries - Deal scoring algorithms - IC memo generation - Concise responses with document links ### 4. Role-Based Security - Row-level security in database - Role-based sidebar navigation - Filtered data access per buyer group - Audit logging of all actions ### 5. UI/UX Features - Light/dark mode toggle - Responsive design - Real-time updates - Toast notifications - Modal dialogs and forms ## Authentication System - Supabase auth integration - Demo accounts for testing (separate seller/buyer logins) - Organization-based access control - Session management ## File Structure ``` src/ ├── pages/ # Main application pages ├── components/ # Reusable components ├── hooks/ # Custom React hooks ├── lib/ # Utilities and API layer ├── integrations/ # Supabase client and types └── components/ui/ # Shadcn UI components supabase/ ├── migrations/ # Database schema changes └── functions/ # Edge functions for AI/backend logic ``` ## Technology Stack - **Frontend**: React 18, TypeScript, Vite - **UI**: Tailwind CSS, Shadcn/UI, Lucide Icons - **State**: React hooks, Context API - **Backend**: Supabase (PostgreSQL, Auth, Edge Functions) - **AI**: OpenAI integration via edge functions - **Deployment**: Lovable hosting platform ## Notes This specification was generated from file tree analysis. The actual implementation details, database schema, and API contracts would need to be extracted from the source code for a complete rebuild in Go. Key areas needing deeper investigation: 1. Complete database schema from migration files 2. API endpoint definitions from edge functions 3. Component props and state management patterns 4. Authentication flow and RLS policies 5. AI prompt engineering and model configurations ## Migration Considerations for Go 1. **Database**: Migrate PostgreSQL schema, implement similar RLS patterns 2. **Auth**: Implement JWT-based auth with organization scoping 3. **AI Integration**: Port edge function logic to Go handlers 4. **Role System**: Recreate buyer/seller role distinctions 5. **Real-time**: Consider WebSocket implementation for live updates 6. **File Upload**: Implement document storage and management 7. **Audit**: Create comprehensive audit logging system