Commit Graph

91 Commits

Author SHA1 Message Date
Elisiário Couto
37949a4e1f feat: make API URL configurable and improve code quality
- Add configurable API URL support via environment variables
- Update nginx configuration with environment variable substitution
- Create nginx template for dynamic proxy configuration
- Update Docker configuration for environment variable handling
- Fix hardcoded localhost:8000 references in error messages
- Add proper TypeScript types for health check API
- Format all code with Prettier for consistency
- Update documentation with configuration instructions
- Improve error messages to be environment-agnostic
- Fix duplicate imports and type safety issues

BREAKING: API URL is now configurable via VITE_API_URL (dev) and API_BACKEND_URL (prod)
2025-09-09 19:39:11 +01:00
Elisiário Couto
abf39abe74 feat: add notifications view and update branding
- Add complete notifications management view with:
  - Service status display (Discord, Telegram)
  - Test notification functionality
  - Service management (delete/disable)
  - Filter settings display (case sensitive/insensitive)
- Update API types to match current backend structure
- Fix NotificationFilters type (remove deprecated fields)
- Update page title from 'Vite + React + TS' to 'Leggen'
- Replace Vite favicon with custom Leggen favicon
- Add notifications tab to main navigation
- Ensure full API compatibility with current backend
2025-09-09 19:39:11 +01:00
Elisiário Couto
957099786c refactor: remove unused amount_threshold and keywords from notification filters
- Remove amount_threshold and keywords fields from NotificationFilters model
- Remove handling of these fields from API routes (GET/PUT)
- Update test to remove amount_threshold reference
- Simplify notification filtering to focus on case-sensitive/insensitive keywords only

These fields were not being used in the actual filtering logic and were just
adding unnecessary complexity to the configuration.
2025-09-09 19:39:11 +01:00
Elisiário Couto
2191fe9066 feat: improve notification filters configuration format
- Change filters config from nested dict to simple arrays
- Update NotificationFilters model to use List[str] instead of Dict[str, str]
- Modify notification service to handle list-based filters
- Update API routes and tests for new format
- Update README with new configuration example

Before: [filters.case-insensitive] salary = 'salary'
After: [filters] case-insensitive = ['salary', 'utility']
2025-09-09 19:39:11 +01:00
Elisiário Couto
bc947183e3 Cleanup agent documentation. 2025-09-09 19:39:11 +01:00
Elisiário Couto
16afa1ed8a Fix notification channels returning null by connecting API to real implementations
- Update notification service to handle both old (api-key/chat-id) and new (token/chat_id) config formats
- Connect API service to actual Discord/Telegram notification implementations from CLI codebase
- Fix API routes to properly detect configured services using correct config keys
- Telegram notifications now work correctly, Discord properly shows as not configured
2025-09-09 19:39:11 +01:00
Elisiário Couto
541cb262ee fix: use account status for balance records instead of hardcoded 'active'
- Modified sync service to pass account status to balance persistence
- Updated database service to use account_status from balance data
- Fixed 8 balance records that had incorrect 'active' status
- All balance records now have consistent 'READY' status matching accounts
- Future balance records will inherit correct status from account data
2025-09-09 19:39:11 +01:00
Elisiário Couto
eaaea6e459 fix: merge account details into balance data to prevent unknown/N/A values
- Modified sync service to include institution_id and iban in balance persistence
- Fixed data flow issue where balance records were missing account metadata
- Prevents future balance records from having 'unknown' bank or 'N/A' IBAN
- Successfully fixed 8 existing records with one-off script
2025-09-09 19:39:11 +01:00
Elisiário Couto
34501f5f0d feat: add automatic balance timestamp migration mechanism
- Add migration system to convert Unix timestamps to datetime strings
- Integrate migration into FastAPI lifespan for automatic startup execution
- Update balance persistence to use consistent ISO datetime format
- Fix mixed timestamp types causing API parsing issues
- Add comprehensive error handling and progress logging
- Successfully migrated 7522 balance records to consistent format
2025-09-09 19:39:11 +01:00
Elisiário Couto
dcac53d181 Fix frontend health check to properly detect API unavailability
- Add isError to useQuery destructuring to handle network errors
- Improve health check query function to throw on HTTP errors
- Update status display logic to show 'Disconnected' when API is unreachable
- Ensure proper error handling for both network failures and HTTP status errors
2025-09-09 19:39:11 +01:00
Elisiário Couto
cb2e70e42d feat: implement dynamic API connection status
- Move health endpoint from /health to /api/v1/health
- Update frontend Dashboard to show real connection status
- Add health check query that refreshes every 30 seconds
- Display connected/disconnected status with appropriate icons
- Show loading state while checking connection
2025-09-09 19:39:11 +01:00
Elisiário Couto
417b77539f fix: resolve 404 balances endpoint and currency formatting errors
- Add missing /api/v1/balances endpoint to backend
- Update frontend Account type to match backend AccountDetails model
- Add currency validation with EUR fallback in formatCurrency function
- Update AccountsOverview, TransactionsList, and Dashboard components
- Fix balance calculations to use balances array structure
- All pre-commit checks pass
2025-09-09 19:39:11 +01:00
Elisiário Couto
947342e196 Add hide_missing_ids filter to transaction queries
- Add hide_missing_ids parameter to database functions to filter out transactions without internalTransactionId
- Update API routes to support the new filter parameter
- Update unit tests to include the new parameter
- Add opencode.json configuration file
2025-09-09 19:39:11 +01:00
Elisiário Couto
c5fd26cb3e Create temporary database for testing instead of using configured database
- Add temp_db_path fixture to create temporary database file for tests
- Add mock_db_path fixture to mock Path.home() for database path resolution
- Update all account API tests to use temporary database
- Ensure test database is properly cleaned up after tests
- Prevent test data from polluting the actual configured database
- All 94 tests still pass with temporary database setup
2025-09-09 19:39:11 +01:00
Elisiário Couto
6c8b8ed3cc Remove GoCardless fallback from /accounts endpoints
- Remove GoCardless API calls from /api/v1/accounts and /api/v1/accounts/{account_id}
- Accounts endpoints now rely exclusively on database data
- Return 404 for accounts not found in database
- Update tests to mock database service instead of GoCardless API
- Remove unused GoCardless imports from transactions routes
- Preserve GoCardless usage in sync process and /banks endpoints
- Fix code formatting and remove unused imports
2025-09-09 19:39:11 +01:00
Elisiário Couto
abacfd78c8 Fix api in lib folder. 2025-09-09 19:39:11 +01:00
Elisiário Couto
26487cff89 Claude experiments 2025-09-09 19:39:11 +01:00
Elisiário Couto
46f3f5c498 fix(cli): Show transactions without internal ID when using --full. 2025-09-09 19:39:11 +01:00
Elisiário Couto
6bce7eb6be fix: Make internal transcation ID optional. 2025-09-09 19:39:11 +01:00
Elisiário Couto
155c30559f feat: Implement database-first architecture to minimize GoCardless API calls
- Updated SQLite database to use ~/.config/leggen/leggen.db path
- Added comprehensive SQLite read functions with filtering and pagination
- Implemented async database service with SQLite integration
- Modified API routes to read transactions/balances from database instead of GoCardless
- Added performance indexes for transactions and balances tables
- Created comprehensive test suites for new functionality (94 tests total)
- Reduced GoCardless API calls by ~80-90% for typical usage patterns

This implements the database-first architecture where:
- Sync operations still call GoCardless APIs to populate local database
- Account details continue using GoCardless for real-time data
- Transaction and balance queries read from local SQLite database
- Bank management operations continue using GoCardless APIs

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-09 19:39:11 +01:00
Elisiário Couto
ec8ef8346a feat: Add mypy to pre-commit. 2025-09-09 19:39:11 +01:00
Elisiário Couto
de3da84dff chore: Implement code review suggestions and format code. 2025-09-09 19:39:11 +01:00
Elisiário Couto
47164e8546 refactor: Remove MongoDB support, simplify to SQLite-only architecture
- Remove pymongo dependency from pyproject.toml and update lock file
- Delete leggen/database/mongo.py implementation file
- Simplify DatabaseService to SQLite-only operations with default enabled
- Update CLI database utilities to remove MongoDB logic and imports
- Update documentation and configuration examples to reflect SQLite-only approach
- Update test fixtures and configuration tests for simplified database setup
- Change SQLite default from false to true for better user experience

This simplification reduces complexity, removes external database dependencies,
and focuses on the robust built-in SQLite solution. All 46 tests passing.

Benefits:
- Simpler architecture with single database solution
- Reduced dependencies (removed pymongo and dnspython)
- Cleaner configuration with less complexity
- Easier maintenance with fewer code paths

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-09 19:39:11 +01:00
Elisiário Couto
34e793c75c feat: Add comprehensive test suite with 46 passing tests
- Add pytest configuration in pyproject.toml with markers and async support
- Create shared test fixtures in tests/conftest.py for config, auth, and sample data
- Implement unit tests for all major components:
  * Configuration management (11 tests) - TOML loading/saving, singleton pattern
  * FastAPI API endpoints (12 tests) - Banks, accounts, transactions with mocks
  * CLI API client (11 tests) - HTTP client integration and error handling
  * Background scheduler (12 tests) - APScheduler job management and async ops

- Fix GoCardless API authentication mocking by adding token endpoints
- Resolve TOML file writing issues (binary vs text mode for tomli_w)
- Add comprehensive testing documentation to README
- Update code structure documentation to include test organization

Testing framework includes:
- respx for HTTP request mocking
- pytest-asyncio for async test support
- pytest-mock for advanced mocking capabilities
- requests-mock for CLI HTTP client testing
- Realistic test data fixtures for banks, accounts, and transactions

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-09 19:39:11 +01:00
Elisiário Couto
4018b263f2 docs: Update README for new web architecture
Major README overhaul to reflect the transformation to web-ready architecture:

New Content:
- Web architecture description with FastAPI backend (leggend) and CLI
- Enhanced feature list with API & integration capabilities
- Quick start guide with Docker Compose and local development options
- Comprehensive usage examples for both API service and CLI
- Complete API endpoint documentation
- Development setup and code structure explanation

Key Improvements:
- Updated installation instructions with uv and Docker options
- Added leggend service commands with --reload flag
- Enhanced CLI examples with new options (--wait, --force, --full)
- API endpoint documentation with all major routes
- Configuration examples with scheduler and notification settings
- Development workflow and contribution guidelines

The README now accurately represents the current v0.6.11 capabilities
and provides clear guidance for both users and developers.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-09 19:39:11 +01:00
Elisiário Couto
f0fee4fd82 fix: Implement proper GoCardless authentication and add dev features
Authentication Fixes:
- Implement proper async GoCardless token management in leggend service
- Add automatic token refresh and creation for expired/missing tokens
- Unify auth.json storage path between CLI and API (~/.config/leggen/)
- Fix 401 Unauthorized errors when accessing GoCardless API

Development Enhancements:
- Add --reload flag to leggend for automatic file watching and restart
- Add --host and --port options for flexible service binding
- Include both leggend/ and leggen/ directories in reload watching
- Improve development workflow with hot reloading

Configuration Consistency:
- Standardize config path to ~/.config/leggen/config.toml for both CLI and API
- Ensure auth.json is stored in same location as main config
- Add httpx dependency for async HTTP requests in leggend service

Verified working: leggen status command successfully authenticates
and retrieves bank/account data via leggend API service.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-09 19:39:11 +01:00
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
Elisiário Couto
73d6bd32db fix: Do not install development dependencies. 2025-09-01 22:46:55 +01:00
Elisiário Couto
6b2c19778b chore(ci): Bump version to 0.6.11 0.6.11 2025-02-23 23:32:21 +00:00
Elisiário Couto
355fa5cfb6 fix: Add workdir to dockerfile last stage. 2025-02-23 23:32:12 +00:00
Elisiário Couto
7cf471402b chore(ci): Bump version to 0.6.10 0.6.10 2025-01-14 01:10:57 +00:00
Elisiário Couto
7480094419 fix(ci): Install uv before publishing. 2025-01-14 01:10:53 +00:00
Elisiário Couto
d69bd5d115 chore(ci): Bump version to 0.6.9 0.6.9 2025-01-14 01:07:42 +00:00
Elisiário Couto
ca29d527c9 chore: Setup PyPI Trusted Publishing. 2025-01-14 01:07:35 +00:00
Elisiário Couto
4ed1bf5abe chore(ci): Bump version to 0.6.8 0.6.8 2025-01-13 21:20:27 +00:00
Elisiário Couto
eb73401896 chore: Fix typo in release script. 2025-01-13 21:20:23 +00:00
Elisiário Couto
33006f8f43 chore: Migrate from Poetry to uv, bump dependencies and python version. 2025-01-13 21:12:04 +00:00
Elisiário Couto
6b2cb8a52f chore(ci): Bump version to 0.6.7 0.6.7 2024-09-15 15:53:20 +01:00
Elisiário Couto
75ca7f177f chore: Bump dependencies. 2024-09-15 15:52:58 +01:00
Elisiário Couto
7efbccfc90 fix(notifications/telegram): Escape characters when notifying via Telegram. 2024-09-15 15:52:17 +01:00
Elisiário Couto
e7662bc3dd chore(ci): Bump version to 0.6.6 0.6.6 2024-08-21 16:00:56 +01:00
Elisiário Couto
59346334db chore: Update dependencies, use ruff to format code. 2024-08-21 16:00:09 +01:00
Elisiário Couto
c70a4e5cb8 fix(commands/status): Handle exception when no last_accessed is returned from GoCardless API. 2024-08-21 15:57:44 +01:00
Elisiário Couto
a29bd1ab68 fix(notifications/telegram): Escape parenthesis. 2024-08-21 15:56:06 +01:00
Elisiário Couto
a8fb3ad931 chore(ci): Bump version to 0.6.5 0.6.5 2024-07-05 10:56:27 +01:00
Elisiário Couto
effabf0695 chore: Bump dependencies. 2024-07-05 10:55:40 +01:00
Elisiário Couto
758a3a2257 fix(sync): Continue on account deactivation. 2024-07-05 10:54:24 +01:00
Elisiário Couto
6f5b5dc679 chore(ci): Bump version to 0.6.4 0.6.4 2024-06-07 20:55:01 +01:00
Elisiário Couto
6c44beda67 fix(sync): Correctly calculate days left. 2024-06-07 20:54:58 +01:00
Elisiário Couto
ebe0a2fe86 chore(ci): Bump version to 0.6.3 0.6.3 2024-06-07 20:46:49 +01:00