Skip to content

Chatelo/freview

Repository files navigation

πŸ” FReview

Comprehensive Code Review Tool for Flask Projects

Python Flask License

A comprehensive code review tool for Flask applications that analyzes project structure, SQLAlchemy models, API patterns, and database configurations to ensure best practices and identify potential issues.

✨ Features

Analysis Area Purpose Status
πŸ—οΈ Project Structure Validates Flask project organization, required files, and configuration βœ…
🧠 SQLAlchemy Models Deep analysis of model definitions, relationships, constraints, and best practices βœ…
🌐 API Patterns Reviews Flask routes, blueprints, REST conventions, authentication, and error handling βœ…
πŸ—„οΈ Database Analysis Examines migrations, configurations, query patterns, and performance optimizations βœ…
πŸ“ Multiple Reports Console output with optional Markdown/JSON reports for documentation βœ…
🎨 Rich Terminal UI Beautiful, colored output with emojis and professional formatting βœ…

πŸ” Detailed Analysis Capabilities

πŸ—οΈ Project Structure Analysis

  • βœ… Entry point validation (app.py, main.py, etc.)
  • βœ… Directory organization (models/, views/, templates/, static/)
  • βœ… Configuration management (config.py, .env files)
  • βœ… Blueprint structure detection
  • βœ… Testing setup validation
  • βœ… Documentation presence

🧠 SQLAlchemy Model Analysis

  • βœ… Model class structure and naming conventions
  • βœ… Table naming and column definitions
  • βœ… Primary key and foreign key validation
  • βœ… Relationship definitions and circular dependency detection
  • βœ… Model methods (__repr__, __str__) validation
  • βœ… Model inheritance and mixins analysis

🌐 API Pattern Analysis

  • βœ… Route detection and Blueprint organization
  • βœ… REST API convention compliance
  • βœ… HTTP method usage patterns
  • βœ… Authentication and authorization checks
  • βœ… Input validation and error handling
  • βœ… API versioning and documentation
  • βœ… Security vulnerability detection

πŸ—„οΈ Database Analysis

  • βœ… Migration setup (Alembic/Flask-Migrate)
  • βœ… Database configuration validation
  • βœ… Connection pooling and performance settings
  • βœ… Query pattern analysis and N+1 detection
  • βœ… Index usage and optimization suggestions
  • βœ… Security (hardcoded credentials detection)

πŸš€ Installation

FReview installs globally on your machine, making the freview command available from any directory. Choose the installation method that works best for your setup:

🎯 Method 1: One-Line Installation (Recommended)

curl -sSL https://raw.githubusercontent.com/Chatelo/freview/main/install_freview.sh | bash

This script automatically detects the best installation method and installs FReview globally.

⚑ Method 2: Using uv (Fast & Modern)

uv tool install git+https://github.com/Chatelo/freview.git

Global Installation: Makes freview command available system-wide

πŸ”§ Method 3: Using pipx (Recommended for CLI tools)

pipx install git+https://github.com/Chatelo/freview.git

Global Installation: Isolated dependencies with global freview command access

πŸ“¦ Method 4: Using pip

pip install --user git+https://github.com/Chatelo/freview.git

Global Installation: Traditional Python package installation with global access Note: Currently installs from source. PyPI package (pip install freview) coming soon!

πŸ› οΈ Method 5: Manual Installation Script

Download and run the installation script with specific method:

# Download the script
curl -O https://raw.githubusercontent.com/Chatelo/freview/main/install_freview.sh
chmod +x install_freview.sh

# Install with specific method
./install_freview.sh pipx    # Using pipx
./install_freview.sh uv      # Using uv  
./install_freview.sh pip     # Using pip
./install_freview.sh auto    # Auto-detect (default)

πŸ§ͺ Method 6: Development Installation

For contributors or testing:

git clone https://github.com/Chatelo/freview.git
cd freview
pip install -e .

βœ… Verify Installation

After installation, verify that FReview is working globally:

# Check version (works from any directory)
freview --version

# Show help (works from any directory)  
freview --help

# Test on a project (run from anywhere)
freview review /path/to/your/flask/project

πŸ’» Usage

Basic Usage

freview review path_to_flask_project

Advanced Options

# Generate reports in multiple formats
freview review myproject --markdown --json --output-dir reports/

# Skip specific analysis areas
freview review myproject --skip-api --skip-db

# Verbose output for debugging
freview review myproject --verbose

# Analyze only specific components
freview review myproject --skip-structure --skip-models  # API & DB only

Available Options

  • --markdown, -m: Generate Markdown report
  • --json, -j: Generate JSON report
  • --output-dir, -o: Specify output directory for reports
  • --verbose, -v: Enable verbose output
  • --skip-structure: Skip project structure analysis
  • --skip-models: Skip SQLAlchemy model analysis
  • --skip-api: Skip API pattern analysis
  • --skip-db: Skip database analysis

What FReview Analyzes:

β€’ πŸ—οΈ Project Structure: Entry points, organization, configuration β€’ 🧠 SQLAlchemy Models: Definitions, relationships, best practices
β€’ 🌐 API Patterns: Routes, blueprints, REST conventions, security β€’ �️ Database: Migrations, configurations, query patterns β€’ πŸ“Š Comprehensive Reports: Actionable insights and recommendations

πŸ“Š Report Output

After scanning, you'll find detailed analysis results in your terminal with color-coded insights:

πŸ” Reviewing Flask Project
πŸ“ Project Path: /home/user/my-flask-app

πŸ—οΈ Project Structure Analysis
βœ… Structure looks good
βœ… Found app.py entry point
βœ… Configuration management detected

🧠 SQLAlchemy Model Analysis

πŸ“„ models/user.py
βœ… User: Core model requirements satisfied
βœ… User: Uses foreign key constraints (2 found)
βœ… User: Defines relationships (3 found)
ℹ️  User: Consider adding __repr__ method for better debugging

πŸ“„ models/post.py
❌ Post: Missing __tablename__ attribute
⚠️  Post: Class name should be PascalCase
πŸ” Post: Consider adding input validation

🌐 API Pattern Analysis

πŸ“„ views/auth.py
βœ… Found 5 route(s) in auth.py
βœ… Good: Project uses 3 blueprint(s)
⚠️  Route 'delete_user' should include error handling
πŸ” Route 'admin_panel' may need authentication

πŸ—„οΈ Database Analysis

πŸ“„ MIGRATIONS
βœ… Found 12 migration file(s)
βœ… Alembic configuration file present
⚠️  Migration 003_add_indexes.py contains potentially dangerous operation

πŸ“„ config.py
βœ… Database URI configuration present
πŸ” Warning: Potential hardcoded database credentials
πŸ’‘ Use environment variables: os.environ.get('DATABASE_URL')

πŸ“ Saved Markdown report: review_report.md
πŸ“„ Saved JSON report: review_report.json

Report Formats

Console Output

  • Rich terminal display with colors and emojis
  • Real-time progress indicators
  • Categorized findings by analysis area

Markdown Report (--markdown)

  • Structured documentation with sections for each analysis area
  • Actionable recommendations and best practices
  • Code examples and implementation guides
  • Priority-based issue categorization

JSON Report (--json)

  • Machine-readable format for CI/CD integration
  • Detailed metadata for each finding
  • Programmatic access to analysis results
  • Custom tooling integration support

οΏ½ What's New in v2.0

🌐 API Pattern Analysis

  • Route Detection: Automatically finds Flask routes and blueprints
  • REST Compliance: Validates REST API conventions and best practices
  • Security Review: Checks authentication, input validation, and error handling
  • Architecture Analysis: Reviews API versioning, blueprint organization

πŸ—„οΈ Database Analysis

  • Migration Management: Validates Alembic/Flask-Migrate setup
  • Configuration Security: Detects hardcoded credentials and security issues
  • Performance Optimization: Identifies N+1 queries and indexing opportunities
  • Connection Analysis: Reviews database pooling and connection settings

πŸ“ˆ Enhanced Reporting

  • Multi-format Output: Console, Markdown, and JSON reports
  • Actionable Insights: Specific recommendations with implementation guides
  • Priority Classification: Error, warning, and informational categorization
  • Cross-component Analysis: Identifies relationships between different areas

οΏ½πŸ› οΈ Exception Handling

FReview gracefully handles various scenarios:

β€’ ❌ Missing Dependencies: Continues analysis when optional components are unavailable β€’ πŸ“ Invalid Structure: Provides guidance for incomplete or non-standard project layouts
β€’ πŸ”§ Flexible Analysis: Individual analysis components can be skipped via CLI options β€’ 🚨 Error Recovery: Detailed error reporting with suggestions for resolution

πŸ“ Important Notes

⚠️ Disclaimer: FReview is designed for code reviews and educational purposes, not as a definitive standard for production readiness.

πŸ’‘ Purpose: It serves as a helpful starting point for evaluating code quality and establishing best practices in your team's codebase.

οΏ½ Continuous Improvement: Regular updates include new analysis patterns and enhanced detection capabilities.

πŸŽ‰ Happy Reviewing!

Found this helpful? Give it a ⭐ on GitHub!

πŸ”§ Installation Troubleshooting

If you encounter issues during installation:

Command not found after installation:

# Restart your terminal or reload your shell configuration
source ~/.bashrc    # For bash
source ~/.zshrc     # For zsh

Permission errors with pip:

# Use --user flag to install in user directory
pip install --user git+https://github.com/Chatelo/freview.git

Python version compatibility:

β€’ Minimum required: Python 3.9+ β€’ Check your version: python --version

For corporate networks:

# If behind proxy, configure git and pip accordingly
git config --global http.proxy http://proxy:port
pip install --proxy http://proxy:port --user git+https://github.com/Chatelo/freview.git

Uninstalling FReview

If you need to remove FReview from your system:

If installed with uv

uv tool uninstall freview

If installed with pipx

pipx uninstall freview

If installed with pip

pip uninstall freview

Clean up shell configuration (optional)

If you want to remove the PATH entries that were automatically added:

# For bash users - edit ~/.bashrc and remove the freview PATH line
nano ~/.bashrc

# For zsh users - edit ~/.zshrc and remove the freview PATH line  
nano ~/.zshrc

# For fish users - edit ~/.config/fish/config.fish
nano ~/.config/fish/config.fish

Look for and remove lines like:

  • export PATH="$HOME/.local/bin:$PATH"
  • export PATH="$HOME/.local/share/uv/tools/bin:$PATH"

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

See CHANGELOG.md for a detailed history of changes and releases.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published