SourcebookLM
An AI-powered interactive notebook application that helps you create, organize, and analyze content from various sources. SourcebookLM combines document processing, AI-generated insights, and interactive learning tools to transform your documents, URLs, and YouTube videos into structured knowledge.
Features
Prerequisites
- Python 3.8 or higher
- MongoDB database (local or cloud-based like MongoDB Atlas)
- Google Gemini API key
Installation
Clone the repository
git clone https://github.com/truepushkar/SourcebookLM.git
cd SourcebookLM
Create a virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Install dependencies
pip install -r requirements.txt
Set up environment variables
Create a .env file in the root directory based on sample.env:
cp sample.env .env
Edit .env and add your credentials:
MONGO_URI=mongodb://localhost:27017/ # Or your MongoDB Atlas connection string
GEMINI_API_KEY=your_gemini_api_key_here
Configuration
MongoDB Setup
- Local MongoDB: Install MongoDB locally and use
mongodb://localhost:27017/
- MongoDB Atlas: Create a free cluster at mongodb.com/cloud/atlas and use the provided connection string
Gemini API Key
- Visit Google AI Studio
- Create a new API key
- Add it to your
.env file
Usage
Start the application
python app.py
Access the application
Open your web browser and navigate to:
http://localhost:5000
Create a notebook
- Click "New Notebook" from the dashboard
- Add sources by uploading files, entering URLs, or YouTube video links
- Use the AI tools to analyze and transform your content
Interact with your content
- Chat with the AI about your sources
- Generate mind maps to visualize concepts
- Create reports and summaries
- Build flashcards for study sessions
- Generate quizzes to test your knowledge
Project Structure
SourcebookLM/
├── app.py # Main Flask application
├── generative.py # AI/Gemini integration
├── upload_text.py # Document and content extraction
├── requirements.txt # Python dependencies
├── sample.env # Environment variables template
├── templates/ # HTML templates
│ ├── dashboard.html # Main dashboard
│ └── notebook.html # Notebook interface
└── static/ # Static assets
├── styles.css # Stylesheets
├── app.js # Main application logic
├── dashboard.js # Dashboard functionality
├── mindmap.js # Mind map visualization
├── report.js # Report generation
├── flashcards.js # Flashcard interface
└── quiz.js # Quiz functionality
API Endpoints
Notebook Management
GET /api/notebooks - List all notebooks
POST /api/notebooks - Create or update a notebook
GET /api/notebooks/<id> - Load a specific notebook
DELETE /api/notebooks/<id> - Delete a notebook
Content Processing
POST /api/upload - Upload and extract text from files
POST /api/extract_url - Extract content from a URL
POST /api/extract_youtube - Extract YouTube video transcript
AI Tools
POST /api/chat - Chat with AI assistant
POST /api/tool_action - Generate content with AI tools (mindmap, reports, flashcards, quiz, slides)
Technologies Used
- Backend: Flask (Python web framework)
- Database: MongoDB (document storage)
- AI: Google Gemini API (generative AI)
- Document Processing: PyMuPDF, python-docx, mammoth
- Web Scraping: BeautifulSoup4, requests
- YouTube: youtube-transcript-api
- Frontend: HTML, CSS, JavaScript
License
This project is licensed under the MIT License. See the LICENSE file for details.
Author
Pushkar Singh
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
If you encounter any issues or have questions, please open an issue on the GitHub repository.
Acknowledgments
- Google Gemini API for AI capabilities
- MongoDB for database solutions
- The open-source community for the excellent libraries used in this project