Files
leggen/PROJECT.md
Elisiário Couto 91f53b35b1 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>
2025-09-09 19:39:11 +01:00

3.2 KiB

Leggen Web Transformation Project

Overview

Transform leggen from CLI-only to web application with FastAPI backend (leggend) and SvelteKit frontend (leggen-web).

Progress Tracking

Phase 1: FastAPI Backend (leggend)

1.1 Core Structure

  • Create directory structure (leggend/, api/, services/, etc.)
  • Add FastAPI dependencies to pyproject.toml
  • Create configuration management system
  • Set up FastAPI main application
  • Create Pydantic models for API responses

1.2 API Endpoints

  • Banks API (/api/v1/banks/)
    • GET /institutions - List available banks
    • POST /connect - Connect to bank
    • GET /status - Bank connection status
  • Accounts API (/api/v1/accounts/)
    • GET / - List all accounts
    • GET /{id}/balances - Account balances
    • GET /{id}/transactions - Account transactions
  • Sync API (/api/v1/sync/)
    • POST / - Trigger manual sync
    • GET /status - Sync status
  • Notifications API (/api/v1/notifications/)
    • GET/POST/PUT /settings - Manage notification settings

1.3 Background Jobs

  • Implement APScheduler for sync scheduling
  • Replace Ofelia with internal Python scheduler
  • Migrate existing sync logic from CLI

Phase 2: SvelteKit Frontend (leggen-web)

2.1 Project Setup

  • Create SvelteKit project structure
  • Set up API client for backend communication
  • Design component architecture

2.2 UI Components

  • Dashboard with account overview
  • Bank connection wizard
  • Transaction history and filtering
  • Settings management
  • Real-time sync status

Phase 3: CLI Refactoring

3.1 API Client Integration

  • Create HTTP client for FastAPI calls
  • Refactor existing commands to use APIs
  • Maintain CLI user experience
  • Add API URL configuration option

Phase 4: Docker & Deployment

4.1 Container Setup

  • Create Dockerfile for leggend service
  • Update docker-compose.yml with leggend service
  • Remove Ofelia dependency (scheduler now internal)
  • Create Dockerfile for leggen-web (deferred - not implementing web UI yet)

Current Status

Active Phase: Phase 2 - CLI Integration Complete Last Updated: 2025-09-01 Completion: ~80% (FastAPI backend and CLI refactoring complete)

Next Steps (Future Enhancements)

  1. Implement SvelteKit web frontend
  2. Add real-time WebSocket support for sync status
  3. Implement user authentication and multi-user support
  4. Add more comprehensive error handling and logging
  5. Implement database migrations for schema changes

Recent Achievements

  • Complete FastAPI backend with all major endpoints
  • Configurable background job scheduler (replaces Ofelia)
  • CLI successfully refactored to use API endpoints
  • Docker configuration updated for new architecture
  • Maintained backward compatibility and user experience

Architecture Decisions

  • FastAPI: For high-performance async API backend
  • APScheduler: For internal job scheduling (replacing Ofelia)
  • SvelteKit: For modern, reactive frontend
  • Existing Logic: Reuse all business logic from current CLI commands
  • Configuration: Centralize in leggend service, maintain TOML compatibility