feat: Complete cloud-native CIM Document Processor with full BPCP template

🌐 Cloud-Native Architecture:
- Firebase Functions deployment (no Docker)
- Supabase database (replacing local PostgreSQL)
- Google Cloud Storage integration
- Document AI + Agentic RAG processing pipeline
- Claude-3.5-Sonnet LLM integration

 Full BPCP CIM Review Template (7 sections):
- Deal Overview
- Business Description
- Market & Industry Analysis
- Financial Summary (with historical financials table)
- Management Team Overview
- Preliminary Investment Thesis
- Key Questions & Next Steps

🔧 Cloud Migration Improvements:
- PostgreSQL → Supabase migration complete
- Local storage → Google Cloud Storage
- Docker deployment → Firebase Functions
- Schema mapping fixes (camelCase/snake_case)
- Enhanced error handling and logging
- Vector database with fallback mechanisms

📄 Complete End-to-End Cloud Workflow:
1. Upload PDF → Document AI extraction
2. Agentic RAG processing → Structured CIM data
3. Store in Supabase → Vector embeddings
4. Auto-generate PDF → Full BPCP template
5. Download complete CIM review

🚀 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jon
2025-08-01 17:51:45 -04:00
parent 3d94fcbeb5
commit df079713c4
45 changed files with 2320 additions and 5282 deletions

View File

@@ -0,0 +1,71 @@
const { createClient } = require('@supabase/supabase-js');
require('dotenv').config();
const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_SERVICE_KEY);
async function testChunkInsert() {
console.log('🧪 Testing exact chunk insert that is failing...');
const testChunk = {
document_id: 'test-doc-123',
content: 'This is test content for chunk processing',
chunk_index: 1,
metadata: { test: true },
embedding: new Array(1536).fill(0.1)
};
console.log('📤 Inserting test chunk with select...');
const { data, error } = await supabase
.from('document_chunks')
.insert(testChunk)
.select()
.single();
if (error) {
console.log('❌ Insert with select failed:', error.message);
console.log('Error details:', error);
// Try without select
console.log('🔄 Trying insert without select...');
const { error: insertError } = await supabase
.from('document_chunks')
.insert(testChunk);
if (insertError) {
console.log('❌ Plain insert also failed:', insertError.message);
} else {
console.log('✅ Plain insert worked');
// Now try to select it back
console.log('🔍 Trying to select the inserted record...');
const { data: selectData, error: selectError } = await supabase
.from('document_chunks')
.select('*')
.eq('document_id', 'test-doc-123')
.single();
if (selectError) {
console.log('❌ Select failed:', selectError.message);
} else {
console.log('✅ Select worked');
console.log('📋 Returned columns:', Object.keys(selectData));
console.log('Has chunk_index:', 'chunk_index' in selectData);
console.log('chunk_index value:', selectData.chunk_index);
}
}
} else {
console.log('✅ Insert with select worked!');
console.log('📋 Returned columns:', Object.keys(data));
console.log('Has chunk_index:', 'chunk_index' in data);
console.log('chunk_index value:', data.chunk_index);
}
// Clean up
console.log('🧹 Cleaning up test data...');
await supabase
.from('document_chunks')
.delete()
.eq('document_id', 'test-doc-123');
}
testChunkInsert();