Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
env/
venv/
.venv/
ENV/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# IDEs
.vscode/
.idea/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db

# Git
.git/
.gitignore
.gitattributes

# Logs
logs/
*.log

# Environment
.env
.env.local
.env.*.local

# Data
data/
documents/
info/
*.db
*.sqlite
*.csv

# Tests
.pytest_cache/
.coverage
htmlcov/

# Docker
docker-compose.override.yml
107 changes: 107 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# ===========================
# ENVIRONMENT CONFIGURATION
# ===========================

# Environment
ENVIRONMENT=development # development, staging, production

# Database Configuration
DATABASE_URL=postgresql+asyncpg://user:password@localhost:5432/vfs_automation
DATABASE_POOL_SIZE=20
DATABASE_MAX_OVERFLOW=10
DATABASE_ECHO=false

# Redis Cache
REDIS_URL=redis://localhost:6379/0
REDIS_PASSWORD=
CACHE_TTL=3600 # seconds

# Application
APP_NAME=VFS-Automation-Enterprise
APP_VERSION=3.0.0
DEBUG=false
LOG_LEVEL=INFO

# Security
SECRET_KEY=change-this-to-a-secure-random-key-in-production
JWT_SECRET_KEY=change-this-jwt-secret-key
JWT_ALGORITHM=HS256
JWT_EXPIRATION_MINUTES=60
ENCRYPTION_KEY=change-this-encryption-key-32-chars

# Flask API
FLASK_HOST=0.0.0.0
FLASK_PORT=5000
FLASK_DEBUG=false
CORS_ORIGINS=http://localhost:3000,http://localhost:5000

# Rate Limiting
RATE_LIMIT_ENABLED=true
RATE_LIMIT_PER_MINUTE=60
RATE_LIMIT_PER_HOUR=1000

# VFS Global Configuration
VFS_BASE_URL=https://visa.vfsglobal.com
VFS_BOOKING_URL=https://visa.vfsglobal.com/gnb/pt/prt/book-appointment
VFS_LOGIN_URL=https://visa.vfsglobal.com/gnb/pt/prt/login
VFS_MONITORING_DURATION=4 # minutes
VFS_MAX_CLIENTS_PER_SESSION=5
VFS_CHECK_INTERVAL=30 # seconds

# Browser Configuration
BROWSER_HEADLESS=true
BROWSER_USE_PLAYWRIGHT=true
BROWSER_VIEWPORT_WIDTH=1920
BROWSER_VIEWPORT_HEIGHT=1080
BROWSER_TIMEOUT=30000 # milliseconds

# Cloudflare Bypass
CF_BYPASS_ENABLED=true
CF_MAX_ATTEMPTS=10
CF_WAIT_TIMEOUT=30

# Proxy Configuration
PROXY_ENABLED=true
PROXY_ROTATION_ENABLED=true
PROXY_TEST_TIMEOUT=10
PROXY_MAX_RETRIES=3

# Monitoring & Metrics
METRICS_ENABLED=true
METRICS_PORT=9090
HEALTH_CHECK_ENABLED=true

# OpenTelemetry
OTEL_ENABLED=false
OTEL_SERVICE_NAME=vfs-automation
OTEL_EXPORTER_ENDPOINT=http://localhost:4317

# Notifications
EMAIL_ENABLED=false
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USERNAME=
EMAIL_PASSWORD=
EMAIL_FROM=noreply@vfs-automation.com

TELEGRAM_ENABLED=false
TELEGRAM_BOT_TOKEN=
TELEGRAM_CHAT_ID=

# File Upload
MAX_FILE_SIZE=10485760 # 10MB in bytes
ALLOWED_FILE_EXTENSIONS=.jpg,.jpeg,.png,.pdf

# Retry & Circuit Breaker
MAX_RETRIES=5
RETRY_BACKOFF_FACTOR=1.5
CIRCUIT_BREAKER_THRESHOLD=5
CIRCUIT_BREAKER_TIMEOUT=60

# Celery (Task Queue - Optional)
CELERY_BROKER_URL=redis://localhost:6379/1
CELERY_RESULT_BACKEND=redis://localhost:6379/2

# Performance
ASYNC_WORKERS=4
CONNECTION_POOL_SIZE=20
194 changes: 194 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
name: CI/CD Pipeline

on:
push:
branches: [ main, develop, claude/* ]
pull_request:
branches: [ main, develop ]

env:
PYTHON_VERSION: '3.11'

jobs:
# Code Quality Checks
lint:
name: Code Quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements-enterprise.txt') }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black flake8 mypy pylint isort bandit

- name: Run Black
run: black --check src/ tests/

- name: Run Flake8
run: flake8 src/ tests/ --max-line-length=100

- name: Run isort
run: isort --check-only src/ tests/

- name: Run Bandit (Security)
run: bandit -r src/ -f json -o bandit-report.json || true

- name: Upload Bandit Report
uses: actions/upload-artifact@v3
with:
name: bandit-report
path: bandit-report.json

# Unit Tests
test:
name: Unit Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_password
POSTGRES_DB: test_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements-enterprise.txt') }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-enterprise.txt
playwright install chromium

- name: Run tests with coverage
env:
DATABASE_URL: postgresql+asyncpg://test_user:test_password@localhost:5432/test_db
REDIS_URL: redis://localhost:6379/0
run: |
pytest tests/ --cov=src --cov-report=xml --cov-report=html

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests

- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: htmlcov/

# Security Scanning
security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'

- name: Upload Trivy results
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'

# Docker Build
build:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [lint, test]
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKER_USERNAME }}/vfs-automation
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=sha

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# Deploy (Optional - customize for your deployment)
deploy:
name: Deploy to Production
runs-on: ubuntu-latest
needs: [build]
if: github.ref == 'refs/heads/main'
environment:
name: production
steps:
- uses: actions/checkout@v4

- name: Deploy notification
run: |
echo "Deployment triggered for production"
# Add your deployment steps here
Loading