14. Dependencies & Installation

14.1 Complete Dependency List

Frontend (Desktop App)

File: packages/desktop-app/package.json

{
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.20.0",
    "axios": "^1.6.2",
    "lucide-react": "^0.294.0",
    "@tanstack/react-query": "^5.12.0"
  },
  "devDependencies": {
    "@types/react": "^18.2.43",
    "@types/react-dom": "^18.2.17",
    "@types/node": "^20.10.4",
    "typescript": "^5.3.3",
    "vite": "^5.0.8",
    "electron": "^27.1.3",
    "electron-builder": "^24.9.1",
    "tailwindcss": "^3.3.6",
    "autoprefixer": "^10.4.16",
    "postcss": "^8.4.32",
    "eslint": "^8.55.0"
  }
}

Installation

cd packages/desktop-app
npm install

Backend (FastAPI)

File: packages/local-backend/requirements.txt

# Core Framework
fastapi==0.104.1
uvicorn[standard]==0.24.0
pydantic==2.5.2

# Database
sqlalchemy==2.0.23
alembic==1.13.0

# OCR Dependencies
pytesseract==0.3.10
Pillow==10.1.0
PyMuPDF==1.23.8
pdf2image==1.16.3
python-docx==1.1.0

# Utilities
python-multipart==0.0.6

Installation

cd packages/local-backend
pip install -r requirements.txt

Core Engine

File: packages/core-engine/requirements.txt

No external dependencies

Core engine uses only Python standard library for maximum portability and minimal dependencies.

14.2 System Dependencies

Tesseract OCR

Version 5.3.3+
Platform Windows 10/11
Download https://digi.bib.uni-mannheim.de/tesseract/
Auto-Installer packages/local-backend/install_ocr_dependencies.ps1

Auto Installation (Recommended)

# Run as Administrator
.\install_ocr_dependencies.ps1

Manual Installation

  1. Download Tesseract installer from the link above
  2. Run the installer (select all language packs)
  3. Add to PATH: C:\Program Files\Tesseract-OCR
  4. Verify installation: tesseract --version

Poppler (PDF to Image Conversion)

Version 24.08.0+
Platform Windows 10/11
Download https://github.com/oschwartz10612/poppler-windows
Auto-Installer Included in install_ocr_dependencies.ps1

Manual Installation

  1. Download Poppler release ZIP from GitHub
  2. Extract to C:\Program Files\poppler
  3. Add bin to PATH: C:\Program Files\poppler\Library\bin
  4. Verify installation: pdftoppm -v

14.3 Auto-Installation Script

File: packages/local-backend/install_ocr_dependencies.ps1

?? Administrator Rights Required

This script must be run as Administrator to install system dependencies and modify PATH.

# Complete Auto-Installer for OCR Dependencies
# Run as Administrator

Write-Host "=== OCR Dependencies Auto-Installer ===" -ForegroundColor Cyan
Write-Host ""

# 1. Install Tesseract
Write-Host "[1/2] Installing Tesseract OCR 5.3.3..." -ForegroundColor Yellow

$tesseractUrl = "https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w64-setup-5.3.3.20231005.exe"
$tesseractInstaller = "$env:TEMP\tesseract-setup.exe"

Invoke-WebRequest -Uri $tesseractUrl -OutFile $tesseractInstaller

Start-Process -FilePath $tesseractInstaller -ArgumentList "/S", "/D=C:\Program Files\Tesseract-OCR" -Wait

# Add to PATH
$tesseractPath = "C:\Program Files\Tesseract-OCR"
$currentPath = [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine)
if ($currentPath -notlike "*$tesseractPath*") {
    [Environment]::SetEnvironmentVariable("Path", "$currentPath;$tesseractPath", [EnvironmentVariableTarget]::Machine)
}

Write-Host "  ? Tesseract installed successfully!" -ForegroundColor Green

# 2. Install Poppler
Write-Host "[2/2] Installing Poppler 24.08.0..." -ForegroundColor Yellow

$popplerUrl = "https://github.com/oschwartz10612/poppler-windows/releases/download/v24.08.0-0/Release-24.08.0-0.zip"
$popplerZip = "$env:TEMP\poppler.zip"
$popplerPath = "C:\Program Files\poppler"

Invoke-WebRequest -Uri $popplerUrl -OutFile $popplerZip
Expand-Archive -Path $popplerZip -DestinationPath $popplerPath -Force

# Add bin to PATH
$popplerBin = "$popplerPath\poppler-24.08.0\Library\bin"
if ($currentPath -notlike "*$popplerBin*") {
    [Environment]::SetEnvironmentVariable("Path", "$currentPath;$popplerBin", [EnvironmentVariableTarget]::Machine)
}

Write-Host "  ? Poppler installed successfully!" -ForegroundColor Green

# Verify installations
Write-Host ""
Write-Host "=== Verification ===" -ForegroundColor Cyan
Write-Host "Tesseract version:" -ForegroundColor Yellow
& tesseract --version

Write-Host ""
Write-Host "Poppler version:" -ForegroundColor Yellow
& pdftoppm -v

Write-Host ""
Write-Host "=== Installation Complete! ===" -ForegroundColor Green
Write-Host "Please restart your terminal for PATH changes to take effect." -ForegroundColor Yellow

14.4 Complete Setup Guide

Step 1: Clone Repository

git clone <repository-url>
cd currency-denomination-calculator

Step 2: Install Frontend Dependencies

cd packages/desktop-app
npm install

Step 3: Install Backend Dependencies

cd ../local-backend
pip install -r requirements.txt

Step 4: Install OCR Dependencies (Auto)

# Run as Administrator
.\install_ocr_dependencies.ps1

Step 5: Initialize Database

Database is automatically initialized on first run. No manual setup required.

Step 6: Run Application

Terminal 1 (Backend)

cd packages/local-backend
python -m uvicorn app.main:app --reload --port 8000

Terminal 2 (Frontend)

cd packages/desktop-app
npm run dev

Expected Output

Backend Console

INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [12345]
INFO:     Started server process [67890]
INFO:     Waiting for application startup.
INFO:     Application startup complete.

Frontend Console

VITE v5.0.8  ready in 234 ms

  ?  Local:   http://localhost:5173/
  ?  Network: use --host to expose
  ?  press h to show help

14.5 Installation Verification

Verify Python Dependencies

# Check FastAPI
python -c "import fastapi; print(f'FastAPI {fastapi.__version__}')"

# Check SQLAlchemy
python -c "import sqlalchemy; print(f'SQLAlchemy {sqlalchemy.__version__}')"

# Check Tesseract binding
python -c "import pytesseract; print('pytesseract OK')"

# Check PDF processing
python -c "import fitz; print(f'PyMuPDF {fitz.__version__}')"

Verify System Dependencies

# Tesseract
tesseract --version

# Poppler
pdftoppm -v

# Python version
python --version

# Node.js version
node --version

Expected Versions

Tool Minimum Version Recommended
Python 3.8 3.11+
Node.js 16 18+
Tesseract 5.0 5.3.3+
Poppler 23.0 24.08.0+

14.6 Installation Troubleshooting

Issue: pip install fails

Symptoms

Error messages during pip install -r requirements.txt

Solutions

  1. Upgrade pip: python -m pip install --upgrade pip
  2. Use virtual environment:
    python -m venv venv
    .\venv\Scripts\Activate.ps1
    pip install -r requirements.txt
  3. Install Visual C++ Build Tools (for binary packages)

Issue: npm install fails

Solutions

  1. Clear cache: npm cache clean --force
  2. Delete node_modules: Remove-Item node_modules -Recurse -Force
  3. Retry installation: npm install
  4. Use different registry: npm install --registry https://registry.npmjs.org/

Issue: Tesseract not found

Solutions

  1. Verify PATH: $env:PATH -split ';' | Select-String Tesseract
  2. Set explicitly in code:
    # In ocr_processor.py
    pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
  3. Restart terminal after installation

Issue: Port already in use

Solutions

  1. Check what's using port 8000:
    netstat -ano | Select-String ":8000"
  2. Kill process:
    Stop-Process -Id <PID> -Force
  3. Use different port:
    uvicorn app.main:app --port 8001
? Section Complete

This section covers complete dependency lists (Frontend: React/Electron, Backend: FastAPI/SQLAlchemy, OCR: Tesseract/Poppler), auto-installation scripts, step-by-step setup guide, verification commands, and troubleshooting for common installation issues.