Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 104 additions & 52 deletions docs/categories.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,53 @@

## Overview

moneyflow automatically uses your backend's category structure:
moneyflow automatically uses your backend's category structure with **profile-local isolation**:

- **Monarch Money** - Fetches your actual Monarch categories on every startup
- **YNAB** - Fetches your actual YNAB budget categories on every startup
- **Amazon Mode** - Uses categories from your Monarch/YNAB account (if previously configured), otherwise uses built-in defaults
- **Monarch Money** - Fetches your actual Monarch categories and saves to your Monarch profile
- **YNAB** - Fetches your actual YNAB budget categories and saves to your YNAB profile
- **Amazon Mode** - Inherits categories from your primary backend (Monarch/YNAB) or uses built-in defaults
- **Demo Mode** - Uses built-in default categories

**No manual configuration needed!** Categories are automatically synced from your finance platform.
**No manual configuration needed!** Categories are automatically synced from your finance platform and isolated per account.

---

## How It Works

### Profile-Local Category Storage

Each account has its own category configuration:

```text
~/.moneyflow/
├── config.yaml # Global settings (optional)
└── profiles/
├── monarch1/
│ └── config.yaml # Monarch categories (auto-synced)
├── ynab1/
│ └── config.yaml # YNAB categories (auto-synced)
└── amazon/
└── config.yaml # Amazon categories (optional, inherits by default)
```

**Benefits:**

- ✅ No category conflicts between accounts
- ✅ Different Monarch and YNAB category structures work independently
- ✅ Each account maintains its own category customizations

### For Monarch Money and YNAB Users

On every startup, moneyflow:

1. **Fetches your categories** from Monarch/YNAB API
2. **Saves them to `~/.moneyflow/config.yaml`** under `fetched_categories`
2. **Saves them to `~/.moneyflow/profiles/{account_id}/config.yaml`**
3. **Uses them throughout the session** for grouping and filtering

Your categories are always up-to-date with your finance platform. If you add or rename categories in
Monarch or YNAB, they'll automatically appear in moneyflow on next launch.

**Example config.yaml (auto-generated):**
**Example profile config.yaml (auto-generated):**

```yaml
version: 1
Expand All @@ -46,17 +68,50 @@ fetched_categories:

### For Amazon Mode Users

When you launch Amazon mode, moneyflow:
Amazon mode uses smart category inheritance:

**Priority order:**

1. **Profile-local config** - If `~/.moneyflow/profiles/amazon/config.yaml` exists, use it
2. **Explicit source** - If `amazon_categories_source` is set in global config, inherit from that profile
3. **Auto-inherit** - If only ONE Monarch/YNAB profile exists, inherit from it automatically
4. **Built-in defaults** - If multiple profiles exist or none configured

#### Example: Single Monarch Account + Amazon

```text
~/.moneyflow/profiles/
├── monarch1/config.yaml # Has Food, Shopping, etc.
└── amazon/ # No config.yaml
└── amazon.db
```

Result: Amazon automatically inherits Monarch's categories. Your Amazon purchases use the same category structure!

#### Example: Multiple Accounts + Amazon

```text
~/.moneyflow/profiles/
├── monarch1/config.yaml # Has Monarch categories
├── ynab1/config.yaml # Has different YNAB categories
└── amazon/ # No config.yaml
```

Result: Amazon uses built-in defaults (can't auto-pick between Monarch and YNAB).

1. **Checks for `fetched_categories` in config.yaml**
2. If found (from a previous Monarch/YNAB setup), uses those categories
3. If not found, uses built-in default categories
#### Explicit Control

This means Amazon purchases are categorized using the same category structure as your main finance platform.
To specify which profile Amazon should inherit from, add to global `~/.moneyflow/config.yaml`:

```yaml
version: 1
amazon_categories_source: monarch1 # Use monarch1's categories for Amazon
```

### For Demo Mode Users

Demo mode always uses the built-in default categories (~60 categories in 15 groups). This provides a consistent demo experience.
Demo mode always uses the built-in default categories (~60 categories in 15 groups). This provides a consistent
demo experience.

---

Expand Down Expand Up @@ -86,43 +141,30 @@ This shows the actual categories being used (fetched from backend or defaults).

---

## Advanced: Custom Category Overrides
## Global Configuration

!!! info "Only for advanced users"
Most users don't need this. Monarch/YNAB categories are automatically fetched and synced.

You can customize how categories are organized by editing `~/.moneyflow/config.yaml`:
The global `~/.moneyflow/config.yaml` is for application-wide settings only:

```yaml
version: 1

# Backend categories (auto-populated by Monarch/YNAB)
fetched_categories:
Food & Dining:
- Groceries
- Restaurants

# Optional: Custom overrides (applied on top of fetched_categories)
categories:
rename_groups:
"Food & Dining": "Food"
add_to_groups:
Food:
- Fast Food
# Optional: Specify which profile Amazon should inherit categories from
amazon_categories_source: monarch1

# Other global settings can go here
```

**Available customizations:**
**What goes in global config:**

- `rename_groups` - Rename category groups
- `rename_categories` - Rename individual categories
- `add_to_groups` - Add categories to existing groups
- `custom_groups` - Create entirely new groups
- `move_categories` - Move categories between groups
- `amazon_categories_source` - Explicit category inheritance for Amazon
- Application-wide preferences (future)
- Theme settings (future)

**Which backends write to config.yaml:**
**What does NOT go in global config:**

- Monarch/YNAB: Write `fetched_categories` on every startup
- Amazon/Demo: Only read, never write
- ❌ Categories (these are profile-local)
- ❌ Credentials (these are profile-local)
- ❌ Backend-specific settings (these are profile-local)

---

Expand All @@ -134,38 +176,48 @@ categories:

### I want to use Monarch categories in Amazon mode

**Solution:** Run moneyflow with Monarch at least once. The categories will be saved to
`config.yaml` and automatically used by Amazon mode.
**Solution:** If you have only one Monarch profile, Amazon will automatically inherit its categories. If you have
multiple profiles, add this to `~/.moneyflow/config.yaml`:

```yaml
version: 1
amazon_categories_source: monarch1 # Replace with your profile ID
```

### I see "Using built-in default categories" in logs

This is normal for:

- First run before connecting to Monarch/YNAB
- Demo mode
- Amazon mode without previous Monarch/YNAB setup
- Amazon mode with multiple other profiles (and no explicit source configured)

To get your actual categories, connect to Monarch or YNAB.
To use your actual categories for Amazon, either have only one other profile or configure
`amazon_categories_source`.

### How do I reset to defaults?
### How do I reset a profile's categories to defaults?

Delete the fetched categories from config.yaml:
Delete the profile's config file:

```bash
# Remove fetched_categories section
# Edit ~/.moneyflow/config.yaml and delete the 'fetched_categories:' section
# Reset specific profile
rm ~/.moneyflow/profiles/monarch1/config.yaml

# Or delete entire config
rm ~/.moneyflow/config.yaml
# Categories will be re-fetched from backend on next startup
```

### Categories are different between my accounts

This is expected! Each profile has its own category structure. Your Monarch categories won't interfere with your
YNAB categories.

---

## Technical Details

**Storage location:** `~/.moneyflow/config.yaml`
**Storage location:** `~/.moneyflow/profiles/{account_id}/config.yaml`

**Update frequency:** On every Monarch/YNAB startup (keeps categories in sync)
**Update frequency:** On every Monarch/YNAB startup (keeps categories in sync with backend)

**Format:**

Expand Down
Loading