mirror of
https://github.com/elisiariocouto/leggen.git
synced 2025-12-13 14:52:16 +00:00
Added comprehensive settings page with account settings component, integrated with existing layout and routing structure. Updated project documentation with frontend architecture details. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>")
5.6 KiB
5.6 KiB
Agent Guidelines for Leggen
Quick Setup for Development
Prerequisites
- uv must be installed for Python dependency management (can be installed via
pip install uv) - Configuration file: Copy
config.example.tomltoconfig.tomlbefore running any commands:cp config.example.toml config.toml
Generate Mock Database
The leggen CLI provides a command to generate a mock database for testing:
# Generate sample database with default settings (3 accounts, 50 transactions each)
uv run leggen --config config.toml generate_sample_db --database /path/to/test.db --force
# Custom configuration
uv run leggen --config config.toml generate_sample_db --database ./test-data.db --accounts 5 --transactions 100 --force
The command outputs instructions for setting the required environment variable to use the generated database.
Start the API Server
- Install uv if not already installed:
pip install uv - Set the database environment variable to point to your generated mock database:
export LEGGEN_DATABASE_PATH=/path/to/your/generated/database.db - Ensure the API can find the configuration file (choose one):
# Option 1: Copy config to the expected location mkdir -p ~/.config/leggen && cp config.toml ~/.config/leggen/config.toml # Option 2: Set environment variable to current config file export LEGGEN_CONFIG_FILE=./config.toml - Start the API server:
uv run leggen server- For development mode with auto-reload:
uv run leggen server --reload - API will be available at
http://localhost:8000with docs athttp://localhost:8000/docs
- For development mode with auto-reload:
Start the Frontend
- Navigate to the frontend directory:
cd frontend - Install npm dependencies:
npm install - Start the development server:
npm run dev- Frontend will be available at
http://localhost:3000 - The frontend is configured to connect to the API at
http://localhost:8000/api/v1
- Frontend will be available at
Build/Lint/Test Commands
Frontend (React/TypeScript)
- Dev server:
cd frontend && npm run dev - Build:
cd frontend && npm run build - Lint:
cd frontend && npm run lint
Backend (Python)
- Lint:
uv run ruff check . - Format:
uv run ruff format . - Type check:
uv run mypy leggen --check-untyped-defs - All checks:
uv run pre-commit run --all-files - Run all tests:
uv run pytest - Run single test:
uv run pytest tests/unit/test_api_accounts.py::TestAccountsAPI::test_get_all_accounts_success -v - Run tests by marker:
uv run pytest -m "api"oruv run pytest -m "unit"
Code Style Guidelines
Python
- Imports: Standard library → Third-party → Local (blank lines between groups)
- Naming: snake_case for variables/functions, PascalCase for classes
- Types: Use type hints for all function parameters and return values
- Error handling: Use specific exceptions, loguru for logging
- Path handling: Use
pathlib.Pathinstead ofos.path - CLI: Use Click framework with proper option decorators
TypeScript/React
- Imports: React hooks first, then third-party, then local components/types
- Naming: PascalCase for components, camelCase for variables/functions
- Types: Use
import typefor type-only imports, define interfaces/types - Styling: Tailwind CSS with
clsxutility for conditional classes - Icons: lucide-react with consistent naming
- Data fetching: @tanstack/react-query with proper error handling
- Components: Functional components with hooks, proper TypeScript typing
Frontend Structure
Layout Architecture
- Root Layout:
frontend/src/routes/__root.tsx- Contains main app structure with Sidebar and Header - Header/Navbar:
frontend/src/components/Header.tsx- Top navigation bar (sticky on mobile only) - Sidebar:
frontend/src/components/Sidebar.tsx- Left navigation sidebar - Routes:
frontend/src/routes/- TanStack Router file-based routing
Key Components Location
- UI Components:
frontend/src/components/ui/- Reusable UI primitives - Feature Components:
frontend/src/components/- Main app components - Pages:
frontend/src/routes/- Route components (index.tsx, transactions.tsx, etc.) - Hooks:
frontend/src/hooks/- Custom React hooks - API:
frontend/src/lib/api.ts- API client configuration - Context:
frontend/src/contexts/- React contexts (ThemeContext, etc.)
Routing Structure
/- Overview/Dashboard (TransactionsTable component)/transactions- Transactions page/analytics- Analytics page/notifications- Notifications page/settings- Settings page
General
- Formatting: ruff for Python, ESLint for TypeScript
- Commits: Use conventional commits with optional scopes, run pre-commit hooks before pushing
- Format:
type(scope): Description starting with uppercase and ending with period. - Scopes:
cli,api,frontend(optional) - Types:
feat,fix,refactor(avoid too many different types) - Examples:
feat(frontend): Add support for S3 backups.fix(api): Resolve authentication timeout issues.refactor(cli): Improve error handling for missing config.
- Avoid including specific numbers, counts, or data-dependent information that may become outdated
- Format:
- Security: Never log sensitive data, use environment variables for secrets
Contributing Guidelines
This repository follows conventional changelog practices. Refer to CONTRIBUTING.md for detailed contribution guidelines including:
- Commit message format and scoping
- Release process using
scripts/release.sh - Pre-commit hooks setup with
pre-commit install