feat: Transform to web architecture with FastAPI backend

This major update transforms leggen from CLI-only to a web-ready
architecture while maintaining full CLI compatibility.

New Features:
- FastAPI backend service (leggend) with comprehensive REST API
- Background job scheduler with configurable cron (replaces Ofelia)
- All CLI commands refactored to use API endpoints
- Docker configuration updated for new services
- API client with health checks and error handling

API Endpoints:
- /api/v1/banks/* - Bank connections and institutions
- /api/v1/accounts/* - Account management and balances
- /api/v1/transactions/* - Transaction retrieval with filtering
- /api/v1/sync/* - Manual sync and scheduler configuration
- /api/v1/notifications/* - Notification settings management

CLI Enhancements:
- New --api-url option and LEGGEND_API_URL environment variable
- Enhanced sync command with --wait and --force options
- Improved transactions command with --full and --limit options
- Automatic fallback and health checking

Breaking Changes:
- compose.yml structure updated (leggend service added)
- Ofelia scheduler removed (internal scheduler used instead)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Elisiário Couto
2025-09-02 00:01:35 +01:00
committed by Elisiário Couto
parent 73d6bd32db
commit 91f53b35b1
39 changed files with 2810 additions and 347 deletions

View File

@@ -1,12 +1,36 @@
services:
# Defaults to `sync` command.
# FastAPI backend service
leggend:
build:
context: .
dockerfile: Dockerfile.leggend
restart: "unless-stopped"
ports:
- "127.0.0.1:8000:8000"
volumes:
- "./leggen:/root/.config/leggen" # Configuration file directory
- "./db:/app" # Database storage
environment:
- LEGGEN_CONFIG_FILE=/root/.config/leggen/config.toml
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
# CLI for one-off operations (uses leggend API)
leggen:
image: elisiariocouto/leggen:latest
command: sync
command: sync --wait
restart: "no"
volumes:
- "./leggen:/root/.config/leggen" # Default configuration file should be in this directory, named `config.toml`
- "./leggen:/root/.config/leggen"
- "./db:/app"
environment:
- LEGGEND_API_URL=http://leggend:8000
depends_on:
leggend:
condition: service_healthy
nocodb:
image: nocodb/nocodb:latest
@@ -17,20 +41,8 @@ services:
ports:
- "127.0.0.1:8080:8080"
depends_on:
- leggen
# Recommended: Run `leggen sync` every day.
ofelia:
image: mcuadros/ofelia:latest
restart: "unless-stopped"
depends_on:
- leggen
command: daemon --docker -f label=com.docker.compose.project=${COMPOSE_PROJECT_NAME}
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
labels:
ofelia.job-run.leggen-sync.schedule: "0 0 3 * * *"
ofelia.job-run.leggen-sync.container: ${COMPOSE_PROJECT_NAME}-leggen-1
leggend:
condition: service_healthy
# Optional: If you want to have a mongodb, uncomment the following lines
# mongo: