Before starting, ensure you have:
- Python 3.8+ (for venv method)
- Docker (for Docker method)
- LLM API Key - Gemini API key (recommended) or other supported models
- GitHub Token (optional, for private repos or avoiding rate limits)
git clone https://github.com/mhwebdevelopment/PocketFlow-Working-Codebase-Knowledge
cd PocketFlow-Working-Codebase-KnowledgeOn Windows:
# Create virtual environment
python -m venv pocketflow_env
# Activate it
pocketflow_env\Scripts\activateOn macOS/Linux:
# Create virtual environment
python3 -m venv pocketflow_env
# Activate it
source pocketflow_env/bin/activate💡 Pro Tip: You'll see (pocketflow_env) in your terminal prompt when the virtual environment is active.
pip install -r requirements.txtEdit the file utils/call_llm.py and set up your API credentials:
# For Gemini (recommended)
client = genai.Client(
api_key=os.getenv("GEMINI_API_KEY", "your-actual-api-key-here")
)Environment Variable Method (Recommended):
Create a .env file in the project root:
# .env file
GEMINI_API_KEY=your_actual_api_key_here
GITHUB_TOKEN=your_github_token_here # OptionalTest your LLM configuration:
python utils/call_llm.pyIf successful, you should see a response from the LLM.
Analyze a GitHub Repository:
python main.py --repo https://github.com/username/repo --include "*.py" "*.js" --exclude "tests/*" --max-size 50000Analyze a Local Directory:
python main.py --dir /path/to/your/codebase --include "*.py" --exclude "*test*"deactivateDocker provides a cleaner, isolated environment and handles all dependencies automatically.
git clone https://github.com/mhwebdevelopment/PocketFlow-Working-Codebase-Knowledge
cd PocketFlow-Working-Codebase-Knowledgedocker build -t pocketflow-app .💡 Understanding the Build: This creates a containerized version of the application with all dependencies pre-installed.
For Public GitHub Repositories:
docker run -it --rm \
-e GEMINI_API_KEY="your_actual_api_key_here" \
-v "$(pwd)/output_tutorials":/app/output \
pocketflow-app --repo https://github.com/username/repoFor Private Repositories (with GitHub Token):
docker run -it --rm \
-e GEMINI_API_KEY="your_actual_api_key_here" \
-e GITHUB_TOKEN="your_github_token_here" \
-v "$(pwd)/output_tutorials":/app/output \
pocketflow-app --repo https://github.com/username/private-repoFor Local Directory Analysis:
docker run -it --rm \
-e GEMINI_API_KEY="your_actual_api_key_here" \
-v "/path/to/your/local_codebase":/app/code_to_analyze \
-v "$(pwd)/output_tutorials":/app/output \
pocketflow-app --dir /app/code_to_analyze🔍 Docker Flags Explained:
-it: Interactive terminal--rm: Automatically remove container when it exits-e: Set environment variables-v: Mount volumes (link host directories to container)
| Parameter | Description | Example |
|---|---|---|
--repo |
GitHub repository URL | --repo https://github.com/user/repo |
--dir |
Local directory path | --dir /path/to/code |
-n, --name |
Project name (optional) | --name "My Project" |
-o, --output |
Output directory | --output ./my_tutorials |
| Parameter | Description | Example |
|---|---|---|
-i, --include |
File patterns to include | --include "*.py" "*.js" |
-e, --exclude |
File patterns to exclude | --exclude "tests/*" "docs/*" |
-s, --max-size |
Max file size in bytes | --max-size 50000 |
| Parameter | Description | Default |
|---|---|---|
--language |
Tutorial language | english |
--max-abstractions |
Max abstractions to identify | 10 |
--no-cache |
Disable LLM caching | false |
# Virtual Environment
python main.py --repo https://github.com/tiangolo/fastapi \
--include "*.py" \
--exclude "tests/*" "docs/*" \
--max-size 100000 \
--output ./fastapi_tutorial
# Docker
docker run -it --rm \
-e GEMINI_API_KEY="your_key_here" \
-v "$(pwd)/fastapi_tutorial":/app/output \
pocketflow-app --repo https://github.com/tiangolo/fastapi \
--include "*.py" --exclude "tests/*" "docs/*"# Virtual Environment
python main.py --dir ./my-react-app \
--include "*.js" "*.jsx" "*.ts" "*.tsx" \
--exclude "node_modules/*" "build/*" \
--language "english"
# Docker
docker run -it --rm \
-e GEMINI_API_KEY="your_key_here" \
-v "./my-react-app":/app/code_to_analyze \
-v "$(pwd)/react_tutorial":/app/output \
pocketflow-app --dir /app/code_to_analyze \
--include "*.js" "*.jsx" "*.ts" "*.tsx"python main.py --repo https://github.com/user/repo --language "Spanish"1. LLM API Key Issues
# Error: API key not found
# Solution: Verify your API key in utils/call_llm.py or environment variables
export GEMINI_API_KEY="your_actual_key_here"
python utils/call_llm.py # Test the connection2. GitHub Rate Limiting
# Error: GitHub API rate limit exceeded
# Solution: Add GitHub token
export GITHUB_TOKEN="your_github_token_here"3. Large Repository Processing
# Error: Repository too large
# Solution: Use filtering options
python main.py --repo https://github.com/large/repo \
--include "*.py" \
--exclude "tests/*" "vendor/*" "third_party/*" \
--max-size 500004. Docker Volume Issues on Windows
# Use forward slashes and full paths
docker run -it --rm \
-e GEMINI_API_KEY="your_key" \
-v "C:/Users/YourName/output":/app/output \
pocketflow-app --repo https://github.com/user/repo5. Permission Errors (Linux/macOS)
# Fix output directory permissions
sudo chown -R $USER:$USER ./output_tutorialsAfter running the analysis, you'll find:
output_tutorials/
├── tutorial.md # Main tutorial document
├── abstractions/ # Core abstractions identified
├── interactions/ # How components interact
└── visualizations/ # Diagrams and flowcharts
- Always activate your environment before running commands
- Keep requirements.txt updated if you add new dependencies
- Use environment variables for sensitive API keys
- Create separate environments for different projects
- Use volume mounts to persist output data
- Set resource limits for large repository analysis:
docker run --memory=4g --cpus=2 [other options]
- Use Docker Compose for complex setups:
# docker-compose.yml version: '3.8' services: pocketflow: build: . environment: - GEMINI_API_KEY=${GEMINI_API_KEY} - GITHUB_TOKEN=${GITHUB_TOKEN} volumes: - ./output:/app/output
- Filter intelligently - exclude test files, documentation, and vendor code
- Set reasonable file size limits - start with 50KB and adjust as needed
- Use caching - don't use
--no-cacheunless necessary - Limit abstractions - start with default 10, increase only if needed
Once you have the tool running successfully:
- Experiment with different repositories - try analyzing codebases you're learning
- Customize the output language - generate working knowledge in your preferred language
- Integrate into your workflow - use it for code reviews and onboarding
- Contribute back - share interesting tutorials in the project's discussions
This setup gives you a powerful AI-assisted code analysis tool that can transform complex codebases into understandable working knowledge documentation. Whether you choose the virtual environment or Docker approach, you're now equipped to analyze and understand any codebase more effectively.