A Flask application that interacts with Reddit and Gemini Flash to summarize posts and comments. Users can fetch the latest, hot, or top posts from a subreddit and get summaries.
- Fetch Reddit Posts: Retrieve new, hot, or top posts from any subreddit.
-
Summarize Posts and Comments: Get AI-generated summaries of posts and their comments.
-
Chat Interface: Interact with the bot to ask questions about Reddit posts.
-
Overview function that does a general summary of the entirety of what is being discussed on an entire subreddit
Fixed a bug, where posts with with more than 200 comments would only extract up to 200 posts. Now the app extracts anad analyzes all comments, including all nested levels and the more comments api. It can handle ALL comments provided by the different Reddit api's. Switched from OpenAI to Gemini 2.0 Flash - very fast, with a very big context, essential for an app like this that handles huge amounts of text.
- Flask: Web framework for Python.
- PRAW: Python Reddit API Wrapper.
- Gemini API: For generating summaries using GPT models.
- Flask-Session: Manage user sessions.
- ** Implements LRU cache to avoid unnecessary repeated API calls.
git clone https://github.com/Joaov41/reddit-chatbot.git cd reddit-chatbotpip install -r requirements.txtCreate a .env file from the example:
cp .env.example .envEdit .env and add your API credentials:
- Reddit Client ID and Secret (get from https://www.reddit.com/prefs/apps)
- Gemini API Key (get from https://makersuite.google.com/app/apikey)
python app.pyThe codebase has been significantly improved with:
- API credentials now stored in environment variables (not hardcoded)
- Input validation and sanitization for all user inputs
- Rate limiting to prevent API abuse
- Secure session management
- Thread-safe LRU cache with TTL (time-to-live) support
- Concurrent API calls for fetching multiple posts
- Optimized memory usage
- Modular architecture with separate services, models, and utilities
- Type hints for better IDE support
- Comprehensive error handling with specific exceptions
- Clean separation of concerns
- Health check endpoint (
/health) - Better error messages with proper HTTP status codes
- Enhanced caching strategy
- Configurable rate limits
For users upgrading from an older version, please see the Migration Guide.



