Phase 1 Complete: Project Setup & Configuration

Completed Tasks (T001-T010):
-  Project structure created (src/, tests/, docs/, scripts/)
-  Python dependencies defined (requirements.txt)
-  C# SDK Bridge project initialized (.csproj)
-  Configuration template (.env.example)
-  Database migration config (alembic.ini)
-  Code quality tools (pyproject.toml with ruff, black, mypy)
-  Development setup script (setup_dev_environment.ps1)
-  Service startup script (start_services.ps1)
-  Architecture documentation (docs/architecture.md)
-  Revised MVP tasks (tasks-revised-mvp.md - 84 tasks focused on cross-switching)

MVP Scope Refined:
- Focus: Cross-switching control for GSCView viewers
- NO recordings, NO analytics, NO LPR in MVP
- REST API only, no UI needed
- Phase 2: GeViSet configuration management

Ready for Phase 2: SDK Bridge Foundation

🤖 Generated with Claude Code (https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Geutebruck API Developer
2025-12-09 08:25:26 +01:00
parent dd2278b39a
commit 733b3b924a
9 changed files with 1533 additions and 0 deletions

View File

@@ -0,0 +1,156 @@
# Geutebruck API - Development Environment Setup Script
# This script sets up the complete development environment
param(
[switch]$SkipPython,
[switch]$SkipDotnet,
[switch]$SkipDatabase,
[switch]$SkipRedis
)
$ErrorActionPreference = "Stop"
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Geutebruck API - Development Setup" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
$RepoRoot = Split-Path -Parent $PSScriptRoot
# Function to check if command exists
function Test-Command {
param($Command)
$null = Get-Command $Command -ErrorAction SilentlyContinue
return $?
}
# Check Prerequisites
Write-Host "[1/8] Checking prerequisites..." -ForegroundColor Yellow
if (-not $SkipPython) {
if (-not (Test-Command python)) {
Write-Host "ERROR: Python 3.11+ is required but not found" -ForegroundColor Red
Write-Host "Please install Python from https://www.python.org/downloads/" -ForegroundColor Red
exit 1
}
$pythonVersion = python --version
Write-Host " ✓ Python found: $pythonVersion" -ForegroundColor Green
}
if (-not $SkipDotnet) {
if (-not (Test-Command dotnet)) {
Write-Host "ERROR: .NET 8.0 SDK is required but not found" -ForegroundColor Red
Write-Host "Please install from https://dotnet.microsoft.com/download" -ForegroundColor Red
exit 1
}
$dotnetVersion = dotnet --version
Write-Host " ✓ .NET SDK found: $dotnetVersion" -ForegroundColor Green
}
# Create .env file if it doesn't exist
Write-Host "[2/8] Setting up environment configuration..." -ForegroundColor Yellow
if (-not (Test-Path "$RepoRoot\.env")) {
Copy-Item "$RepoRoot\.env.example" "$RepoRoot\.env"
Write-Host " ✓ Created .env file from .env.example" -ForegroundColor Green
Write-Host " ⚠ IMPORTANT: Edit .env to configure your settings!" -ForegroundColor Yellow
} else {
Write-Host " ✓ .env file already exists" -ForegroundColor Green
}
# Setup Python virtual environment
if (-not $SkipPython) {
Write-Host "[3/8] Setting up Python virtual environment..." -ForegroundColor Yellow
if (-not (Test-Path "$RepoRoot\.venv")) {
python -m venv "$RepoRoot\.venv"
Write-Host " ✓ Created Python virtual environment" -ForegroundColor Green
} else {
Write-Host " ✓ Virtual environment already exists" -ForegroundColor Green
}
# Activate virtual environment
& "$RepoRoot\.venv\Scripts\Activate.ps1"
# Upgrade pip
python -m pip install --upgrade pip | Out-Null
# Install Python dependencies
Write-Host "[4/8] Installing Python dependencies..." -ForegroundColor Yellow
pip install -r "$RepoRoot\requirements.txt"
Write-Host " ✓ Python dependencies installed" -ForegroundColor Green
} else {
Write-Host "[3/8] Skipping Python setup" -ForegroundColor Gray
Write-Host "[4/8] Skipping Python dependencies" -ForegroundColor Gray
}
# Build SDK Bridge
if (-not $SkipDotnet) {
Write-Host "[5/8] Building SDK Bridge (.NET gRPC service)..." -ForegroundColor Yellow
$sdkBridgePath = "$RepoRoot\src\sdk-bridge\GeViScopeBridge"
if (Test-Path "$sdkBridgePath\GeViScopeBridge.csproj") {
Push-Location $sdkBridgePath
dotnet restore
dotnet build --configuration Debug
Pop-Location
Write-Host " ✓ SDK Bridge built successfully" -ForegroundColor Green
} else {
Write-Host " ⚠ SDK Bridge project not found, skipping" -ForegroundColor Yellow
}
} else {
Write-Host "[5/8] Skipping .NET build" -ForegroundColor Gray
}
# Setup PostgreSQL Database
if (-not $SkipDatabase) {
Write-Host "[6/8] Setting up PostgreSQL database..." -ForegroundColor Yellow
if (Test-Command psql) {
# Create database
Write-Host " Creating database 'geutebruck_api'..." -ForegroundColor Cyan
$createDbCommand = @"
CREATE DATABASE geutebruck_api;
CREATE USER geutebruck WITH PASSWORD 'geutebruck';
GRANT ALL PRIVILEGES ON DATABASE geutebruck_api TO geutebruck;
"@
Write-Host " Run these commands manually in psql:" -ForegroundColor Yellow
Write-Host $createDbCommand -ForegroundColor White
Write-Host ""
Write-Host " Then run: alembic upgrade head" -ForegroundColor Yellow
} else {
Write-Host " ⚠ PostgreSQL not found. Install PostgreSQL 14+ manually" -ForegroundColor Yellow
Write-Host " Download from: https://www.postgresql.org/download/windows/" -ForegroundColor Yellow
}
} else {
Write-Host "[6/8] Skipping database setup" -ForegroundColor Gray
}
# Check Redis
if (-not $SkipRedis) {
Write-Host "[7/8] Checking Redis..." -ForegroundColor Yellow
if (Test-Command redis-server) {
Write-Host " ✓ Redis found" -ForegroundColor Green
} else {
Write-Host " ⚠ Redis not found. Install Redis for Windows:" -ForegroundColor Yellow
Write-Host " Option 1: choco install redis-64" -ForegroundColor Yellow
Write-Host " Option 2: Download from https://redis.io/download" -ForegroundColor Yellow
}
} else {
Write-Host "[7/8] Skipping Redis check" -ForegroundColor Gray
}
# Summary
Write-Host "[8/8] Setup complete!" -ForegroundColor Yellow
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Next Steps:" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "1. Edit .env file with your GeViServer credentials" -ForegroundColor White
Write-Host "2. Ensure PostgreSQL is running and database is created" -ForegroundColor White
Write-Host "3. Run database migrations: alembic upgrade head" -ForegroundColor White
Write-Host "4. Ensure Redis is running: redis-server" -ForegroundColor White
Write-Host "5. Start services: .\scripts\start_services.ps1" -ForegroundColor White
Write-Host ""
Write-Host "Development Environment Ready! 🚀" -ForegroundColor Green

114
scripts/start_services.ps1 Normal file
View File

@@ -0,0 +1,114 @@
# Geutebruck API - Start All Services
# This script starts Redis, SDK Bridge, and FastAPI in separate windows
param(
[switch]$SkipRedis,
[switch]$SkipSdkBridge,
[switch]$SkipApi
)
$ErrorActionPreference = "Stop"
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Geutebruck API - Starting Services" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
$RepoRoot = Split-Path -Parent $PSScriptRoot
# Check if .env exists
if (-not (Test-Path "$RepoRoot\.env")) {
Write-Host "ERROR: .env file not found!" -ForegroundColor Red
Write-Host "Run: .\scripts\setup_dev_environment.ps1 first" -ForegroundColor Red
exit 1
}
# Function to check if port is in use
function Test-Port {
param([int]$Port)
$tcpConnection = Get-NetTCPConnection -LocalPort $Port -ErrorAction SilentlyContinue
return $null -ne $tcpConnection
}
# Start Redis
if (-not $SkipRedis) {
Write-Host "[1/3] Starting Redis..." -ForegroundColor Yellow
if (Test-Port 6379) {
Write-Host " ✓ Redis already running on port 6379" -ForegroundColor Green
} else {
$redisCmd = Get-Command redis-server -ErrorAction SilentlyContinue
if ($redisCmd) {
Start-Process -FilePath "redis-server" -WindowStyle Normal
Start-Sleep -Seconds 2
Write-Host " ✓ Redis started" -ForegroundColor Green
} else {
Write-Host " ✗ Redis not found. Install with: choco install redis-64" -ForegroundColor Red
}
}
} else {
Write-Host "[1/3] Skipping Redis" -ForegroundColor Gray
}
# Start SDK Bridge
if (-not $SkipSdkBridge) {
Write-Host "[2/3] Starting SDK Bridge (gRPC Service)..." -ForegroundColor Yellow
$sdkBridgePath = "$RepoRoot\src\sdk-bridge\GeViScopeBridge"
$sdkBridgeExe = "$sdkBridgePath\bin\Debug\net8.0\GeViScopeBridge.exe"
if (Test-Path $sdkBridgeExe) {
if (Test-Port 50051) {
Write-Host " ✓ SDK Bridge already running on port 50051" -ForegroundColor Green
} else {
$sdkBridgeTitle = "Geutebruck SDK Bridge"
Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd '$sdkBridgePath'; dotnet run --configuration Debug" -WindowStyle Normal
Start-Sleep -Seconds 3
Write-Host " ✓ SDK Bridge started on port 50051" -ForegroundColor Green
}
} else {
Write-Host " ⚠ SDK Bridge not built yet" -ForegroundColor Yellow
Write-Host " Run: cd $sdkBridgePath; dotnet build" -ForegroundColor Yellow
}
} else {
Write-Host "[2/3] Skipping SDK Bridge" -ForegroundColor Gray
}
# Start FastAPI
if (-not $SkipApi) {
Write-Host "[3/3] Starting FastAPI Application..." -ForegroundColor Yellow
$apiPath = "$RepoRoot\src\api"
if (Test-Port 8000) {
Write-Host " ✓ API already running on port 8000" -ForegroundColor Green
} else {
# Check if virtual environment exists
if (Test-Path "$RepoRoot\.venv\Scripts\Activate.ps1") {
$apiTitle = "Geutebruck API"
$startCommand = "cd '$apiPath'; & '$RepoRoot\.venv\Scripts\Activate.ps1'; uvicorn main:app --reload --host 0.0.0.0 --port 8000"
Start-Process powershell -ArgumentList "-NoExit", "-Command", $startCommand -WindowStyle Normal
Start-Sleep -Seconds 3
Write-Host " ✓ FastAPI started on http://localhost:8000" -ForegroundColor Green
} else {
Write-Host " ✗ Python virtual environment not found" -ForegroundColor Red
Write-Host " Run: .\scripts\setup_dev_environment.ps1 first" -ForegroundColor Red
}
}
} else {
Write-Host "[3/3] Skipping FastAPI" -ForegroundColor Gray
}
# Summary
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Services Status:" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Redis: http://localhost:6379" -ForegroundColor White
Write-Host "SDK Bridge: http://localhost:50051 (gRPC)" -ForegroundColor White
Write-Host "API: http://localhost:8000" -ForegroundColor White
Write-Host "API Docs: http://localhost:8000/docs" -ForegroundColor White
Write-Host ""
Write-Host "All Services Started! 🚀" -ForegroundColor Green
Write-Host ""
Write-Host "Press Ctrl+C in each window to stop services" -ForegroundColor Yellow