A scalable Python backend service that automatically generates slides from PDF documents or structured JSON data using AI.
- FastAPI built with FastAPI for presentation generation
- PDF Text Extraction to analyze uploaded documents
- AI-Powered Content Generation using OpenAI to create slides from PDFs
- Asynchronous Processing with Celery for improved scalability
- Multiple Slide Types including title slides, content, bullet points, two-column, and image layouts
- Task Tracking to monitor the status of your presentation generation
- Containerized with Docker and Docker Compose for easy deployment
- Python 3.12+
- Redis (for Celery message broker)
- Docker and Docker Compose (for containerized deployment)
- OpenAI API key (for AI-powered content generation)
-
Clone the repository:
git clone https://github.com/yourusername/ai-presentation-generator.git cd ai-presentation-generator
-
Create a
.env
file with your OpenAI API key:APP_NAME=Presentation Generator REDIS_URL=redis://redis:6379/0 RESULT_BACKEND=redis://redis:6379/0 STORAGE_PATH=/app/storage OPENAI_API_KEY=your_openai_api_key_here
-
Build and run the containers:
docker-compose up --build
The service will be available at http://localhost:8000.
-
Clone the repository:
git clone https://github.com/yourusername/ai-presentation-generator.git cd ai-presentation-generator
-
Create a virtual environment and install dependencies:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt
-
Set up your environment variables (create a
.env
file):APP_NAME=Presentation Generator REDIS_URL=redis://localhost:6379/0 RESULT_BACKEND=redis://localhost:6379/0 STORAGE_PATH=./storage OPENAI_API_KEY=your_openai_api_key_here
-
Make sure Redis is running locally or update the configuration in
app/config.py
. -
Run the FastAPI application:
uvicorn app.main:app --reload
-
In a separate terminal, start the Celery worker:
celery -A celery_app worker --loglevel=info
curl -X POST http://localhost:8000/api/presentations \
-H "Content-Type: application/json" \
-d '{
"title": "Quarterly Report",
"author": "Your Team",
"slides": [
{
"type": "title",
"title": "Q2 Performance Review",
"content": "Finance Department"
},
{
"type": "bullet_points",
"title": "Key Achievements",
"bullet_points": [
"Revenue increased by 15%",
"New client acquisition up 22%",
"Operational costs reduced by 8%"
]
}
]
}'
Response:
{
"task_id": "b8f5e56a-915b-4c44-a784-2f86c1f0e3e9",
"status": "pending"
}
curl -X POST http://localhost:8000/api/presentations/from-pdf \
-F "pdf_file=@/path/to/your/document.pdf" \
-F "title=AI Generated Presentation" \
-F "author=Your Name" \
-F "num_slides=7"
Response:
{
"task_id": "c7e4f45b-826a-4b33-a991-4f75d2f7e4a8",
"status": "pending"
}
curl http://localhost:8000/api/presentations/{task_id}
Response:
{
"task_id": "c7e4f45b-826a-4b33-a991-4f75d2f7e4a8",
"status": "completed",
"file_url": "/download/f6e8d971-3841-4b2a-9e39-3e5fc3c8340b.pptx",
"message": "Presentation generated successfully"
}
curl -O http://localhost:8000/api/download/{file_id}
Type | Description |
---|---|
title |
Title slide with subtitle |
content |
Standard content slide with title and body text |
bullet_points |
Slide with title and bulleted points |
two_column |
Two-column layout for comparing content |
image |
Image slide with a title |
presentation_generator/
βββ app/
β βββ __init__.py
β βββ main.py # FastAPI application
β βββ models.py # Pydantic models
β βββ config.py # Configuration
β βββ ppt_generator.py # PowerPoint generation logic
β βββ pdf_processor.py # PDF processing and OpenAI integration
βββ celery_app/
β βββ __init__.py
β βββ tasks.py # Celery tasks
β βββ celery_config.py # Celery configuration
βββ requirements.txt
βββ docker-compose.yml
Configuration is managed through environment variables and defaults:
Variable | Default | Description |
---|---|---|
APP_NAME |
"Presentation Generator" | Application name |
REDIS_URL |
"redis://redis:6379/0" | Redis URL for Celery broker |
RESULT_BACKEND |
"redis://redis:6379/0" | Result backend for Celery |
STORAGE_PATH |
"/app/storage" | Path for storing generated presentations |
OPENAI_API_KEY |
"" | Your OpenAI API key |
- Upload PDF: User uploads a PDF file via the API
- Text Extraction: System extracts text content using PyPDF2
- AI Analysis: OpenAI processes the text and identifies key points
- Content Generation: AI generates slide content based on the analysis
- Presentation Creation: System creates PowerPoint slides using python-pptx
- Notification: User can check task status and download the presentation
- Add authentication for API endpoints
- Support for custom PowerPoint templates
- Chart generation from data in PDFs
- Image extraction and inclusion from PDFs
- Web interface for easier usage
- Cloud storage integration (S3, GCS)
- Support for more file formats (Word, HTML, Markdown)
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
For more detailed documentation, see the API Documentation when the service is running.