Generate engaging, clickworthy YouTube video titles (with optional emojis and hashtags) powered by FastAPI, MongoDB Atlas Vector Search, and LLMs.
- Generate optimized YouTube video titles from descriptions.
- Optionally add emojis and relevant hashtags.
- Ingest PDF data and create embeddings for vector search.
- Uses MongoDB Atlas vector search index with cosine similarity.
- FastAPI backend with auto-generated API docs.
.
├── app
│ ├── config.py # Configuration and environment variables
│ ├── **init**.py
│ └── main.py # FastAPI entrypoint
├── create_vector_index.py # MongoDB Atlas vector index creation
├── generate_response.py # LLM response generation
├── get_embeddings.py # Embedding generation helper
├── get_query_results.py # Query MongoDB Atlas with embeddings
├── ingest_data.py # Ingest & chunk PDF data
├── requirements.txt # Python dependencies
└── README.md # Project documentation
git clone https://github.com/your-username/youtube-title-generator.git
cd youtube-title-generatorpython3 -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windowspip install -r requirements.txtCreate a .env file in the root directory:
# Application Settings
APP_NAME="FastAPI App"
APP_VERSION="0.1.0"
DEBUG=True
# Server Settings
HOST="127.0.0.1"
PORT=8000
# Database Settings
ATLAS_CONNECTION_STRING="mongodb+srv://<username>:<password>@cluster0.xjslrno.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0"
# API Settings
API_PREFIX="/api/v1"
# Secret keys
HUGGING_FACE_ACCESS_TOKEN="***"
python3 ingest_data.pypython3 create_vector_index.pypython3 generate_response.pyOr run the FastAPI app:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Root health check |
| GET | /info |
Show app info from env |
| GET | /ingest-data |
Ingest & chunk PDF into embeddings |
| GET | /create-index |
Create MongoDB Atlas vector index |
| POST | /prompt |
Generate YouTube title & hashtags |
{
"video_title": "How to Learn",
"description": "You need to manage time, prioritize tasks, and take notes",
"include_emojis": "yes",
"video_type": ".mp4",
"generate_hashtags": "yes"
}{
"message": "Prompt generated successfully!",
"output": [
{
"title": "📅 Master Time Management: Prioritize Tasks & Take Notes",
"hashtags": ["#TimeManagement", "#Productivity", "#YouTubeTips"]
},
{
"title": "📝 Learn the Secrets to Effective Note-Taking",
"hashtags": ["#Notetaking", "#StudyTips", "#YouTubeTutorial"]
},
{
"title": "🎯 Boost Your Productivity: Prioritize & Organize Your Tasks",
"hashtags": ["#ProductivityHacks", "#TaskManagement", "#YouTubeLifeHacks"]
}
]
}Interactive API documentation is available and auto-generated:
-
Swagger UI: http://localhost:8000/docs
Explore and test all endpoints with an intuitive interface. -
ReDoc: http://localhost:8000/redoc
Browse comprehensive, well-structured API reference documentation.
- Runs on FastAPI + Uvicorn.
- Requires MongoDB Atlas with vector index support.
- Uses HuggingFace LLMs for text generation.
- Extendable for custom embeddings and retrieval-augmented generation (RAG).
MIT License. Feel free to use and modify.
Developed by Robiul Hossain