heatmap / scripts /README.md
Ndg07's picture
Feat: 24-hour cleanup for local SQLite
c293f7c

πŸ› οΈ Scripts Usage Guide

This folder contains useful development, testing, and deployment scripts for the Enhanced Fake News Detection System.

πŸ“‹ Available Scripts

πŸ” Verification & Testing

verify_project.py

Purpose: Comprehensive project verification before deployment

python scripts/verify_project.py

What it checks:

  • βœ… Project structure completeness
  • βœ… Python syntax validation
  • βœ… Documentation completeness
  • βœ… Docker configuration
  • βœ… Git repository status

final_verification.py

Purpose: Final deployment readiness check with Docker testing

python scripts/final_verification.py

What it checks:

  • βœ… All project verification checks
  • βœ… Docker build testing
  • βœ… Docker Compose validation
  • βœ… System requirements
  • βœ… Deployment summary

health_check.py

Purpose: Application health monitoring and status checks

python scripts/health_check.py
# Or with custom URL
python scripts/health_check.py --url http://localhost:8080

What it monitors:

  • βœ… API endpoint health
  • βœ… Database connectivity
  • βœ… Service response times
  • βœ… System resource usage

performance_benchmark.py

Purpose: Performance testing and benchmarking

python scripts/performance_benchmark.py

What it tests:

  • βœ… API response times
  • βœ… Throughput testing
  • βœ… Memory usage analysis
  • βœ… Concurrent request handling

validate_environment.py

Purpose: Environment setup validation

python scripts/validate_environment.py

What it validates:

  • βœ… Python dependencies
  • βœ… Environment variables
  • βœ… System requirements
  • βœ… Configuration files

🐳 Docker Management

docker-dev.sh

Purpose: Docker development environment management

# Make executable (Linux/Mac)
chmod +x scripts/docker-dev.sh

# Start development environment
./scripts/docker-dev.sh start

# Stop development environment
./scripts/docker-dev.sh stop

# Rebuild and restart
./scripts/docker-dev.sh restart

# View logs
./scripts/docker-dev.sh logs

# Clean up
./scripts/docker-dev.sh clean

docker-prod.sh

Purpose: Docker production environment management

# Make executable (Linux/Mac)
chmod +x scripts/docker-prod.sh

# Deploy to production
./scripts/docker-prod.sh deploy

# Stop production
./scripts/docker-prod.sh stop

# Update production
./scripts/docker-prod.sh update

# View production logs
./scripts/docker-prod.sh logs

πŸš€ Local Development

run_local.sh (Linux/Mac)

Purpose: Local development environment setup

# Make executable
chmod +x scripts/run_local.sh

# Start local development
./scripts/run_local.sh

# Start with specific mode
./scripts/run_local.sh --mode development

# Skip dependency installation
./scripts/run_local.sh --skip-deps

# Run in background
./scripts/run_local.sh --detached

run_local.ps1 (Windows)

Purpose: Windows local development setup

# Run in PowerShell
.\scripts\run_local.ps1

# With parameters
.\scripts\run_local.ps1 -Mode development -SkipDeps

run_tests.sh

Purpose: Test execution and validation

# Make executable
chmod +x scripts/run_tests.sh

# Run all tests
./scripts/run_tests.sh

# Run specific test suite
./scripts/run_tests.sh --suite unit
./scripts/run_tests.sh --suite integration
./scripts/run_tests.sh --suite e2e

# Run with coverage
./scripts/run_tests.sh --coverage

# Run in verbose mode
./scripts/run_tests.sh --verbose

🎯 Common Workflows

1. New Developer Setup

# 1. Verify project setup
python scripts/verify_project.py

# 2. Validate environment
python scripts/validate_environment.py

# 3. Start local development
./scripts/run_local.sh

# 4. Run tests to ensure everything works
./scripts/run_tests.sh

2. Before Deployment

# 1. Run comprehensive verification
python scripts/final_verification.py

# 2. Performance benchmark
python scripts/performance_benchmark.py

# 3. Deploy with Docker
./scripts/docker-prod.sh deploy

3. Health Monitoring

# Check application health
python scripts/health_check.py

# Continuous monitoring (every 30 seconds)
watch -n 30 python scripts/health_check.py

4. Development Workflow

# Start development environment
./scripts/docker-dev.sh start

# Make changes to code...

# Run tests
./scripts/run_tests.sh

# Restart with changes
./scripts/docker-dev.sh restart

# Check health
python scripts/health_check.py

πŸ”§ Script Requirements

Python Scripts

  • Python 3.8+
  • Dependencies from requirements.txt
  • Some scripts may need additional packages (specified in script headers)

Shell Scripts

  • Linux/Mac: Bash shell
  • Windows: PowerShell 5.0+
  • Docker and Docker Compose installed
  • Git (for some verification scripts)

πŸ“Š Script Output Examples

Verification Success

πŸ” Enhanced Fake News Detection System - Project Verification
======================================================================
βœ… PASS     Project Structure
βœ… PASS     Python Dependencies  
βœ… PASS     Documentation
βœ… PASS     Docker Availability
βœ… PASS     Docker Build
βœ… PASS     Docker Compose
βœ… PASS     Git Status

Score: 7/7 checks passed
πŸŽ‰ ALL CHECKS PASSED!

Health Check Success

πŸ₯ Application Health Check
======================================================================
βœ… API Health: HEALTHY (200ms)
βœ… Database: CONNECTED
βœ… Memory Usage: 45% (2.1GB/4.0GB)
βœ… CPU Usage: 12%
βœ… Disk Space: 78% available

Overall Status: HEALTHY 🟒

🚨 Troubleshooting

Permission Issues (Linux/Mac)

# Make scripts executable
chmod +x scripts/*.sh

PowerShell Execution Policy (Windows)

# Allow script execution
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Docker Issues

# Ensure Docker is running
docker --version
docker-compose --version

# Check Docker daemon
docker ps

πŸ“ Adding New Scripts

When adding new scripts to this folder:

  1. Follow naming convention: action_description.py or action_description.sh
  2. Add documentation: Include usage instructions in script header
  3. Update this README: Add the new script to the appropriate section
  4. Make executable: chmod +x scripts/new_script.sh
  5. Test thoroughly: Ensure script works in different environments

πŸ› οΈ These scripts help streamline development, testing, and deployment workflows for the Enhanced Fake News Detection System.