sandbox-notebookllamalm/src/notebookllama/init_database.py
DJP 2292f8a511 Transform NotebookLlaMa to enterprise multi-user NotebookLM clone
Major Changes:
- Implemented notebook-first architecture (multi-document collections)
- Added user authentication and multi-tenancy
- Created comprehensive database schema (7 tables)
- Built complete notebook management system
- Implemented notebook-level chat across multiple documents
- Added podcast generation from notebooks
- Implemented notebook sharing with permissions
- Fixed MCP server crashes by bypassing for document processing
- Added all enterprise features requested

New Features:
- User login/signup with bcrypt password hashing
- Create/edit/delete notebooks
- Upload multiple PDFs to notebooks
- Add documents to existing notebooks
- Chat across all documents in a notebook
- Generate podcasts from entire notebooks
- Share notebooks with other users
- View shared notebooks
- Persistent chat history per notebook
- Document summaries, Q&A, and highlights

Technical Improvements:
- PostgreSQL database with SQLAlchemy ORM
- Connection pooling and proper cleanup
- Bypassed buggy MCP server for document processing
- Direct LlamaCloud API calls for reliability
- Proper CASCADE deletes
- Session management
- Error handling and logging

Documentation:
- ENTERPRISE_SETUP.md - Setup guide
- IMPLEMENTATION_SUMMARY.md - Technical details
- SIMPLIFIED_PLAN.md - Architecture overview
- CURRENT_STATUS.md - Status and known issues
- FINAL_README.md - User guide

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 17:28:06 -04:00

47 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""Initialize the database schema"""
from database import init_db, engine
from sqlalchemy import text
import sys
def check_database_connection():
"""Check if we can connect to the database"""
try:
with engine.connect() as conn:
conn.execute(text("SELECT 1"))
print("✓ Database connection successful")
return True
except Exception as e:
print(f"✗ Database connection failed: {e}")
return False
def main():
print("Initializing NotebookLlaMa database...")
if not check_database_connection():
print("\nPlease ensure:")
print("1. PostgreSQL is running (docker compose up -d)")
print("2. Environment variables are set correctly in .env")
sys.exit(1)
try:
init_db()
print("✓ Database tables created successfully")
print("\nTables created:")
print(" - users")
print(" - documents")
print(" - notebooks")
print(" - chat_sessions")
print(" - chat_messages")
print(" - document_shares")
print("\nDatabase initialization complete!")
except Exception as e:
print(f"✗ Error creating tables: {e}")
sys.exit(1)
if __name__ == "__main__":
main()