sandbox-notebookllamalm/ENTERPRISE_SETUP.md
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

5.2 KiB

NotebookLlaMa Enterprise Setup

This document describes the enterprise features and setup for NotebookLlaMa.

New Features

🔐 User Authentication

  • User registration and login system
  • Secure password hashing with bcrypt
  • Session-based authentication
  • Per-user document isolation

📚 Document Management

  • All processed documents are saved to database
  • View document library with all your processed notebooks
  • Persistent storage of summaries, Q&A, highlights, and mind maps
  • Document access control

💬 Persistent Chat History

  • Chat sessions are saved per document
  • Load previous conversations
  • Multiple chat sessions per document
  • Search through chat history

🤝 Document Sharing

  • Share documents with other users
  • Granular permissions (Read/Write/Admin)
  • View documents shared with you
  • Manage who has access to your documents

🎯 Multi-tenancy

  • Complete data isolation per user
  • User-specific pipelines (future enhancement)
  • Secure access controls

Setup Instructions

1. Database Setup

The application now requires PostgreSQL. Make sure Docker is running:

```bash

Start PostgreSQL and other services

docker compose up -d

Initialize the database schema

uv run src/notebookllama/init_database.py ```

2. Environment Variables

Update your .env file with the correct database credentials:

```bash

Database Configuration

pgql_db=postgres pgql_user=postgres pgql_psw=admin

API Keys (existing)

OPENAI_API_KEY="your-key" LLAMACLOUD_API_KEY="your-key" ELEVENLABS_API_KEY="your-key" EXTRACT_AGENT_ID="your-id" LLAMACLOUD_PIPELINE_ID="your-id" ```

3. Install Dependencies

```bash uv sync ```

4. Run the Application

Start the MCP server (in one terminal):

```bash uv run src/notebookllama/server.py ```

Start the Streamlit app (in another terminal):

```bash streamlit run src/notebookllama/App.py ```

5. First Time Setup

  1. Navigate to http://localhost:8501
  2. Click on "Sign Up" tab
  3. Create your account
  4. Start using the application!

Architecture

Database Schema

  • users: User accounts
  • documents: Uploaded documents
  • notebooks: Processed notebook data (summaries, Q&A, highlights)
  • chat_sessions: Chat conversation sessions
  • chat_messages: Individual chat messages
  • document_shares: Document sharing permissions

Application Structure

  • App.py: Main entry point with authentication
  • pages/1_Process_Document.py: Document upload and processing
  • pages/2_Document_Chat.py: Chat interface with persistence
  • pages/3_My_Documents.py: User's document library
  • pages/4_Shared_Documents.py: Documents shared with user
  • auth.py: Authentication and user management
  • database.py: Database models and ORM
  • document_manager.py: Document CRUD operations
  • instrumentation_init.py: Global instrumentation (fixes TracerProvider warning)

Bug Fixes

MCP Server 500 Error

  • Added proper error handling in server.py
  • Checks for required environment variables
  • Graceful degradation when services unavailable
  • Detailed logging for debugging

TracerProvider Override Warning

  • Moved instrumentation to global singleton
  • Initializes once on application start
  • Prevents multiple TracerProvider registrations

PostgreSQL Connection Issues

  • Fixed environment variable configuration
  • Proper database connection pooling
  • Connection cleanup

Performance Improvements

Implemented

  • Database connection pooling (pool_size=10, max_overflow=20)
  • Proper async handling for MCP client
  • Efficient query patterns with SQLAlchemy
  • Session state management

Future Enhancements

  • Redis caching layer for frequent queries
  • Background job queue for long-running tasks
  • Rate limiting per user
  • CDN for static assets
  • Horizontal scaling with load balancer

Security

  • Passwords hashed with bcrypt
  • SQL injection protection via SQLAlchemy ORM
  • Session-based authentication
  • Document access controls
  • Per-user data isolation

Troubleshooting

Database Connection Issues

If you see "role does not exist" errors:

  1. Stop any local PostgreSQL instances: ```bash brew services stop postgresql@14 killall postgres ```

  2. Recreate Docker volumes: ```bash docker compose down -v docker compose up -d ```

  3. Re-initialize database: ```bash uv run src/notebookllama/init_database.py ```

MCP Server Not Responding

  1. Check if server is running: ```bash lsof -i :8000 ```

  2. Check server logs: ```bash tail -f server.log ```

  3. Restart server: ```bash killall -9 python uv run src/notebookllama/server.py ```

Migration from Old Version

If you were using the old version without authentication:

  1. All existing data will be lost (no migration path)
  2. You'll need to re-process documents
  3. Create a new user account
  4. Re-upload and process your PDF files

Next Steps

Future enhancements planned:

  • Per-document LlamaCloud pipelines
  • Advanced search across all documents
  • Team/organization support
  • API access with tokens
  • Webhook notifications
  • Document versioning
  • Export functionality
  • Advanced analytics dashboard