How harsh2b/reddit-persona-generator works
Project Type & Purpose
• This is a Python-based tool offering two user interfaces:
a. A Command-Line Interface (CLI) script (persona_generator.py)
b. A Streamlit-based web app (app.py)
• Both interfaces share the same core pipeline: scrape Reddit data, send it to an LLM, then format and save the “persona” output.
File Structure & Key Components
• .devcontainer/ → Development environment configuration
• app.py → Streamlit UI entry point
• persona_generator.py → Core orchestrator: coordinates scraping and LLM calls
• reddit_scraper.py → Encapsulates PRAW-based Reddit data retrieval
• requirements.txt → Python dependencies (e.g., praw, groq, streamlit)
• kojied_persona.txt → Example output
• README.md → Setup & usage instructions
Core Architectural Elements
a. User Interfaces
• CLI (persona_generator.py)
• Web UI (app.py via Streamlit)
b. Core Service Layer
• PersonaGenerator module (in persona_generator.py)
c. Data Retrieval
• RedditScraper module (in reddit_scraper.py) using PRAW
d. External LLM Service
• Groq API (via HTTP calls)
e. Persistence
• Local filesystem (saves .txt files)
f. Configuration
• .env for CLI secrets
• .streamlit/secrets.toml for web secrets
Component Relationships & Data Flow
1. User → CLI (persona_generator.py) or User → Browser → Web UI (app.py)
2. Interface → PersonaGenerator
3. PersonaGenerator → RedditScraper → Reddit API
4. PersonaGenerator → Groq API (send aggregated comments/posts)
5. Groq API → PersonaGenerator (persona text)
6. PersonaGenerator → Filesystem (write <username>_persona.txt)
7. Web UI → displays response & offers download
Architectural Patterns & Principles
• Single Responsibility: each Python module has one role (scraping, orchestration, UI)
• Layered design: UI layer delegates to service layer, which depends on external services
• Configuration isolation: secrets are not checked into code but loaded via .env or secrets.toml