- Python 3.9 or higher
- Git
- (Optional) Docker Desktop
git clone https://github.com/Shahinshac/Code-Quality-Analyzer.git
cd Code-Quality-AnalyzerWindows (PowerShell):
python -m venv .venv
.\.venv\Scripts\Activate.ps1Linux/Mac:
python3 -m venv .venv
source .venv/bin/activatepip install --upgrade pip
pip install -r requirements.txtThis installs:
- Flask (web framework)
- scikit-learn, pandas, joblib (ML)
- flake8, pylint, autopep8 (Python linters)
- pytest (testing)
- streamlit (alternative UI)
- gunicorn (production server)
For enhanced multi-language analysis:
JavaScript/TypeScript:
npm install -g eslintJava (Windows - Chocolatey):
choco install checkstyleC/C++ (Windows - Chocolatey):
choco install cppcheckGo:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latestRust:
rustup component add clippyRuby:
gem install rubocopPHP:
composer global require squizlabs/php_codesniffer# Create models directory
New-Item -ItemType Directory -Force -Path models
# Train a demo model
python -m code_quality_analyzer.cli train --dataset datasets/synthetic_dataset.csv --model-out models/code_quality_model.joblibFlask Web App:
python -m code_quality_analyzer.webappAccess at: http://localhost:5000
Streamlit UI:
streamlit run streamlit_app.pyAccess at: http://localhost:8501
CLI Analysis:
# Analyze a Python file
python -m code_quality_analyzer.cli analyze --file examples/bad_example.py --model models/code_quality_model.joblib
# Analyze any supported language file
python -m code_quality_analyzer.cli analyze --file your-code.jspytest tests/docker build -t code-quality-analyzer:latest .# Run with default settings
docker run -d -p 5000:5000 code-quality-analyzer:latest
# Run with custom model path
docker run -d -p 5000:5000 `
-e MODEL_PATH=/app/models/code_quality_model.joblib `
-v ${PWD}/models:/app/models `
code-quality-analyzer:latest
# Run with model from URL
docker run -d -p 5000:5000 `
-e MODEL_URL=https://your-bucket.s3.amazonaws.com/model.joblib `
-e MODEL_PATH=/app/models/model.joblib `
code-quality-analyzer:latest# Check if running
docker ps
# View logs
docker logs <container-id>
# Access the app
Start-Process http://localhost:5000docker-compose up --build- Create Railway account: https://railway.app
- Create new project → "Deploy from GitHub repo"
- Select repository:
Shahinshac/Code-Quality-Analyzer - Railway auto-detects Dockerfile and deploys
- Set environment variables (optional):
MODEL_PATH=/app/models/code_quality_model.joblibMODEL_URL=<your-s3-url>(if using S3)
- Get deployment URL from Railway dashboard
Cost: Free tier available, ~$5/month for basic usage
- Create Render account: https://render.com
- New → Web Service
- Connect GitHub repository
- Configuration:
- Environment:
Docker - Build Command: (auto-detected)
- Start Command: (auto-detected from Dockerfile)
- Environment:
- Environment Variables (optional):
MODEL_PATH=/app/models/code_quality_model.joblib
- Deploy
Cost: Free tier available (sleeps after inactivity), $7/month for always-on
- Install Fly CLI:
powershell -Command "iwr https://fly.io/install.ps1 -useb | iex"- Login and Launch:
fly auth login
fly launch-
Follow prompts:
- App name:
code-quality-analyzer - Region: Choose closest to you
- Postgres/Redis: No
- App name:
-
Deploy:
fly deploy- Set secrets (optional):
fly secrets set MODEL_URL=your-s3-urlCost: Free tier available, ~$3/month for basic app
-
Install Google Cloud SDK: https://cloud.google.com/sdk/docs/install
-
Authenticate:
gcloud auth login
gcloud config set project YOUR_PROJECT_ID- Build and push to Google Container Registry:
gcloud builds submit --tag gcr.io/YOUR_PROJECT_ID/code-quality-analyzer- Deploy to Cloud Run:
gcloud run deploy code-quality-analyzer `
--image gcr.io/YOUR_PROJECT_ID/code-quality-analyzer `
--platform managed `
--region us-central1 `
--allow-unauthenticatedCost: Pay-per-use, free tier includes 2 million requests/month
-
Install AWS CLI: https://aws.amazon.com/cli/
-
Authenticate:
aws configure- Create ECR repository:
aws ecr create-repository --repository-name code-quality-analyzer- Build and push:
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin YOUR_ACCOUNT.dkr.ecr.us-east-1.amazonaws.com
docker build -t code-quality-analyzer .
docker tag code-quality-analyzer:latest YOUR_ACCOUNT.dkr.ecr.us-east-1.amazonaws.com/code-quality-analyzer:latest
docker push YOUR_ACCOUNT.dkr.ecr.us-east-1.amazonaws.com/code-quality-analyzer:latest- Deploy via ECS Console or use AWS Copilot:
copilot init
copilot deployCost: Varies, typically $10-30/month for small app
Every push to main automatically builds and publishes to GHCR!
# Pull the latest pre-built image
docker pull ghcr.io/shahinshac/code-quality-analyzer:latest
# Run it
docker run -d -p 5000:5000 ghcr.io/shahinshac/code-quality-analyzer:latestUse this image on any platform that supports Docker:
- Railway: Deploy from Docker registry
- Render: Deploy from Docker registry
- Azure Container Instances
- Digital Ocean App Platform
The repository includes .github/workflows/docker-publish-ghcr.yml which automatically:
- ✅ Builds Docker image on every push to
main - ✅ Pushes to GitHub Container Registry (GHCR)
- ✅ Supports multi-architecture (amd64, arm64)
- ✅ Uses build cache for faster builds
- ⚙️ Optionally uploads models to S3
- Go to repository Settings → Actions → General
- Workflow permissions → Select Read and write permissions
- Save
-
Create S3 bucket for model storage
-
Add GitHub Secrets:
- Go to repository Settings → Secrets and variables → Actions
- Click New repository secret
- Add:
AWS_ACCESS_KEY_ID→ Your AWS access keyAWS_SECRET_ACCESS_KEY→ Your AWS secret key
-
Add GitHub Variables:
- Click Variables tab → New repository variable
- Add:
AWS_REGION→us-east-1(or your region)AWS_S3_BUCKET→ Your bucket name
-
Push to main → Workflow automatically uploads model to S3
- Actions tab: https://github.com/Shahinshac/Code-Quality-Analyzer/actions
- Packages tab: https://github.com/Shahinshac?tab=packages
| Variable | Description | Required | Default |
|---|---|---|---|
MODEL_PATH |
Path to ML model file | No | /app/models/code_quality_model.joblib |
MODEL_URL |
URL to download model at startup | No | - |
PORT |
Port for Flask app | No | 5000 |
FLASK_ENV |
Flask environment | No | production |
Solution: Ensure virtual environment is activated and dependencies installed:
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txtSolution: Change port or kill existing process:
# Find process on port 5000
netstat -ano | findstr :5000
# Kill process
taskkill /PID <PID> /FSolution: Ensure Docker Desktop is running and you have enough disk space:
docker system prune -aSolution:
- Check Actions tab for error details
- Ensure workflow permissions are set to "Read and write"
- Verify secrets are correctly configured
Solution:
- Train a model locally:
python -m code_quality_analyzer.cli train --dataset datasets/synthetic_dataset.csv --model-out models/code_quality_model.joblib - Or set
MODEL_URLto download from S3 - Or run without ML (detection still works)
- Clone repository
- Create virtual environment
- Install dependencies (
pip install -r requirements.txt) - (Optional) Train ML model
- Run locally (
python -m code_quality_analyzer.webapp) - Test at http://localhost:5000
- Choose deployment platform (Railway/Render/Fly.io/etc.)
- Push to GitHub (auto-builds to GHCR)
- Deploy using GHCR image
- Issues: https://github.com/Shahinshac/Code-Quality-Analyzer/issues
- Discussions: https://github.com/Shahinshac/Code-Quality-Analyzer/discussions
- Documentation: See README.md for detailed features
Last Updated: December 2025