How ksaxena-233/lecturepacketengine works
Project Type and Purpose
• This is an open-source Python tool (LecturePacketEngine) for AI-driven educational content generation.
• Core purpose: take a user prompt → generate structured lecture packets (PDFs, slides, videos) with AI text, LaTeX equations, images, and optionally adapt to cognitive state inputs (EEG).
File Structure Analysis
• Top-level modules:
• lecture_packet_engine.py – central orchestration class
• gemini_utils.py – wrapper for Google Gemini API
• pdf_generator.py – ReportLab-based PDF assembly
• manim_slides.py / revolutionary_slides.py / presentation.py – slide abstractions
• video_generator.py – video assembly pipeline
• cognitive_state_widget.py + eeg_* modules – sensor/ML feedback loop
• app.py – CLI/web entrypoint
• examples/ – usage scripts and demos
• requirements.txt – Python dependencies and external APIs
README Insights
• Three main feature domains:
a. AI-Powered Text & Equation Generation via Gemini
b. Smart Image Search (DuckDuckGo + PIL validation + retry/backoff)
c. Professional Output (PDF formatting, custom fonts, LaTeX, cover pages)
• Mentions ReportLab, Pillow, requests, duckduckgo_search, matplotlib, numpy.
Main Components
A. User Interface Layer
• app.py or CLI/Script (examples/basic_usage.py)
B. Core Engine
• LecturePacketEngine
C. External Services
• Google Gemini API (text/equation)
• DuckDuckGo Search API (images)
D. Processing Modules
• gemini_utils.py
• pdf_generator.py
• image_processor (PIL validation, resizing)
• slide_generators (manim_slides.py, presentation.py)
• video_generator.py
E. Adaptation / Feedback Module
• cognitive_state_widget.py
• eeg_dataset_processor.py → eeg_ml_pipeline.py → eeg_ml_classifier.py
F. Outputs
• Generated PDF (output/*.pdf)
• Slides (output/*.html or video)
• Video (output/*.mp4)
Relationships & Data Flow
1. UI → Engine: user prompt
2. Engine → Gemini API: request text + equations
3. Engine → DuckDuckGo: image queries → PIL validation → back to Engine
4. Engine → PDF Generator: assemble text, equations, images → PDF
5. Engine → Slide Generator(s): produce slide assets
6. Engine → Video Generator: combine slides, narrations (optional)
7. (Optional) Engine ↔ Cognitive Module: EEG data → ML pipeline → real-time feedback → adapt content
8. All outputs saved under output/
Architectural Patterns & Design Principles
• Modular “Pipeline” pattern: each stage (text, image, PDF, slides, video) is a pluggable module
• Single Responsibility: separate classes for API wrappers, generators, ML pipelines
• Retry/Backoff strategy for external calls (image search)
• Dependency Injection: Engine orchestrates modules via constructors
Technologies & Frameworks
• Python 3.9+
• Google Gemini API (via requests in gemini_utils.py)
• ReportLab (pdf_generator.py)
• PIL/Pillow (image validation, resizing)
• duckduckgo_search (image lookup)
• Manim (slide animations)
• matplotlib, numpy (figures)
• scikit-learn / custom ML for EEG (eeg_ml_classifier.py)
Summary
• The central role of LecturePacketEngine as orchestrator
• Pluggable modules for each content-generation stage
• External dependencies and retry logic
• Optional adaptive feedback via EEG modules
• Final outputs (PDF, slides, video)
By decomposing into these components and layering them clearly, even new contributors can grasp the architecture at a glance.