Skip to content

Commit 61d3dec

Browse files
feat: Improve documentation and integrate mise
This commit introduces a comprehensive documentation system and integrates `mise` for a streamlined development environment. Key changes include: - A new `docs/` directory with detailed guides for Spendee, Firestore, MCP, testing, and project scripts. - A hierarchical `agents.md` structure for AI-specific instructions, following the Docs/Agents split policy. - A revamped `README.md` with separate sections for users and developers, and updated setup instructions. - A `.mise.toml` file to manage Python, jq, and the Bitwarden CLI, simplifying environment setup.
1 parent fe8df56 commit 61d3dec

12 files changed

Lines changed: 253 additions & 26 deletions

File tree

README.md

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,51 @@
1-
# Spendee
1+
# Spendee Python Client
22

33
This is a Python client for interfacing with the wonderful [Spendee app](https://www.spendee.com/).
44

55
The codebase was forked from [dionysio/spendee](https://github.com/dionysio/spendee) (many thanks! <3) in 2025, which was authored in 2019-2020 and archived since then.
66

7-
About Spendee:
8-
> Spendee.com is a budget and expense tracker application to manage personal finances. It allows users to connect bank accounts, e-wallets, and crypto wallets to get an aggregated overview of their financial situation. The app helps users organize and analyze spending through automatic transaction categorization, visually appealing graphs, and insights.
7+
## ⚠️ Warning
98

10-
# Warning
9+
This is a work in progress and is not recommended for general use yet. The original Spendee API is undocumented, and while this client works at the time of writing, it might stop working at any time. The author is not associated with Spendee in any way.
1110

12-
No guarantees are provided here. If you wanna use it, go for it, but do know that the original API is undocumented and while it works at the time of writing, it might stop at any time. I'm not associated with Spendee in any way.
11+
---
1312

14-
## Development setup
13+
## For Users
1514

16-
To set up a development environment (only linux is documented):
15+
*This section is for people who want to use the `spendee-python-client` library in their own projects.*
1716

18-
1. Ensure you have Python 3.11+ installed.
19-
2. Setup the virtual environment:
17+
_(Coming soon)_
18+
19+
---
20+
21+
## For Developers & Contributors
22+
23+
*This section is for people who want to contribute to the development of this library.*
24+
25+
### Development Environment Setup
26+
27+
This project uses [mise](https://mise.jdx.dev/) to manage the development environment.
28+
29+
1. **Install `mise`**: Follow the [official installation instructions](https://mise.jdx.dev/getting-started.html#installing-mise-cli) to install `mise` on your system.
30+
31+
2. **Activate `mise`**: Activate `mise` in your shell by following the instructions for your shell in the [official documentation](https://mise.jdx.dev/getting-started.html#activate-mise).
32+
33+
3. **Install Tools**: Once `mise` is activated, navigate to the project's root directory and run `mise install` to install the required tools.
34+
35+
4. **Set Credentials**: Create a `.env` file in the project root and add your Spendee credentials:
36+
```bash
37+
echo 'EMAIL=<your-email>' > .env
38+
echo 'PASSWORD=<your-password>' >> .env
39+
```
40+
41+
5. **Run**: You can now run the `run.py` script to experiment with the library:
2042
```bash
21-
# Create a virtual environment
22-
python3 -m venv .venv
23-
# Activate the virtual environment
24-
source .venv/bin/activate
25-
# Install dependencies
26-
pip install -r requirements.txt
43+
python run.py
2744
```
28-
3. Set credentials in a newly created `.env` file.
29-
```bash
30-
echo 'EMAIL=<email>' > .env
31-
echo 'PASSWORD=<passwrod' >> .env
32-
```
33-
4. Adapt `run.py` for your experiment and execute.
3445

35-
## Backstory and roadmap
46+
### Backstory and Roadmap
3647

37-
As I started to use the forked repo in 2025, the fetched data from the REST API was outdated by multiple days compared to what is visible on connected Bank accounts and the online webpage.
48+
As the forked repo was started to be used in 2025, the fetched data from the REST API was outdated by multiple days compared to what is visible on connected Bank accounts and the online webpage.
3849

3950
In the interim time since the original author implemented the REST API calls in 2020, Spendee most possibly migrated to another architecture. Based on browser debugging the new setup relies on Google firestore.
4051

@@ -44,8 +55,6 @@ Next step will be to abstract away the most common operations.
4455

4556
After that groundwork, the plan is to implement an MCP server enabling AI agent collaboration to have smarter categorization and conversational exploration of spending habits.
4657

47-
Until that last milestone this project is not recommended for usage.
48-
49-
## Contributing
58+
### Contributing
5059

5160
If you can improve anything in this repo, feel free to add a pull request or add an issue!

agents.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Agents Guide (Central)
2+
3+
## Overview
4+
This document provides AI coding assistants with essential context for working with the spendee-python-client project.
5+
6+
## Development Environment Setup
7+
This project uses [mise](https://mise.jdx.dev/) to manage the development environment. To set up your environment, follow these steps:
8+
9+
1. **Install `mise`**: If you don't have `mise` installed, you can install it by running `curl https://mise.run | sh`.
10+
2. **Activate `mise`**: Activate `mise` in your shell by running `eval "$(~/.local/bin/mise activate bash)"`.
11+
3. **Install Tools**: Navigate to the project's root directory and run `mise install`. This will install the tools defined in the `.mise.toml` file.
12+
13+
For more detailed instructions, please refer to the [environment setup documentation](docs/environment.md).
14+
15+
## Secrets Management
16+
We use Bitwarden for managing secrets. To access secrets, you will need the `BWS_ACCESS_TOKEN` environment variable set. You can then use the `bws` CLI to fetch secrets.
17+
18+
**Example: Get a specific secret by key**
19+
```bash
20+
bws secret list | jq -r '.[] | select(.key == "spendee-password") | .value'
21+
```
22+
23+
**Example: List all secret keys**
24+
```bash
25+
bws secret list | jq -r '.[] | .key'
26+
```
27+
28+
## Living Documentation
29+
Important: The `agents.md` files are living documentation that should be updated alongside code changes. When implementing modifications:
30+
31+
* **Update Relevant Agent Files:** Consider which `agents.md` files need updates when making changes. Avoid adding to the root agents.md file and use dedicated directory related agents.md. Only add the the root, when it is really globally applicable, otherwise just reference there.
32+
* **Keep Implementation Details Current:** Ensure commands, file paths, and procedures reflect the current state
33+
* **Maintain Cross-References:** Update links between agent files and documentation
34+
* **File References Only:** Never quote file content in agent files - only reference files by path
35+
* **Consistency:** Ensure terminology and patterns remain consistent across all agent files
36+
37+
## Docs/Agents split policy
38+
* **Human docs (docs/**):** "What/Why"—architecture, domain flows, decisions, onboarding narratives, high-level troubleshooting flows.
39+
* **Agents (`agents.md` files):** "How"—exact files to touch, commands, env/secrets guidance, gotchas, safe-change checklists, Cursor-ready prompts.
40+
41+
Each agent file starts with a "Read the overview" links block to the relevant `docs/**` pages.
42+
43+
Each relevant `docs/**` page gets a small footer: "For implementation details, see `<path>/agents.md`".
44+
45+
Reduce code/text duplication as much as possible across twin docs and agents files.

docs/environment.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Environment Setup
2+
3+
This project uses [mise](https://mise.jdx.dev/) to manage the development environment. `mise` is a tool that helps you manage your development tools and environment variables.
4+
5+
## Getting Started
6+
7+
1. **Install `mise`**: Follow the [official installation instructions](https://mise.jdx.dev/getting-started.html#installing-mise-cli) to install `mise` on your system.
8+
9+
2. **Activate `mise`**: Activate `mise` in your shell by following the instructions for your shell in the [official documentation](https://mise.jdx.dev/getting-started.html#activate-mise).
10+
11+
3. **Install Tools**: Once `mise` is activated, navigate to the project's root directory and run the following command to install the tools defined in the `.mise.toml` file:
12+
```bash
13+
mise install
14+
```
15+
16+
## Tools
17+
This project uses the following tools, which are managed by `mise`:
18+
* **Python 3.11**
19+
* **jq**: A command-line JSON processor.
20+
* **Bitwarden CLI**: The command-line interface for Bitwarden.

docs/firestore.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Firestore
2+
3+
## High-Level Overview
4+
Firestore is a NoSQL document database from Google Firebase. It is used in this project to store and sync data in real-time.
5+
6+
## Focused Examples
7+
Here's a basic example of how we interact with Firestore:
8+
9+
```python
10+
from google.cloud import firestore
11+
12+
# Initialize the client
13+
db = firestore.Client()
14+
15+
# Get a reference to a document
16+
doc_ref = db.collection(u'users').document(u'alovelace')
17+
18+
# Set data
19+
doc_ref.set({
20+
u'first': u'Ada',
21+
u'last': u'Lovelace',
22+
u'born': 1815
23+
})
24+
```
25+
26+
## Pointers
27+
* [Official Firestore Documentation](https://firebase.google.com/docs/firestore)
28+
* [Python Client Library Documentation](https://googleapis.dev/python/firestore/latest/index.html)
29+
30+
---
31+
For implementation details, see `spendee/agents.md`.

docs/mcp.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# MCP (Model Context Protocol)
2+
3+
## High-Level Overview
4+
MCP (Model Context Protocol) is an open-source standard for connecting AI applications to external systems. Think of it like a USB-C port for AI applications. Just as USB-C provides a standardized way to connect electronic devices, MCP provides a standardized way to connect AI applications to external systems like data sources, tools, and workflows.
5+
6+
## Key Concepts
7+
* **Servers:** Expose data and tools to AI applications.
8+
* **Clients:** Connect to MCP servers to access data and tools.
9+
* **Transports:** The underlying communication mechanism between clients and servers.
10+
11+
## MCP Inspector
12+
The [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector) is an interactive developer tool for testing and debugging MCP servers. It allows you to:
13+
* Inspect available resources, prompts, and tools.
14+
* Test prompt generation and tool execution.
15+
* View server logs and notifications.
16+
17+
The `inspect2.sh` script in this repository is designed to help you run the MCP Inspector.
18+
19+
## Further Reading
20+
For a deeper understanding of MCP, please refer to the [official documentation](https://modelcontextprotocol.io/docs/getting-started/intro).
21+
22+
---
23+
For implementation details, see `mcp/agents.md`.

docs/scripts.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Scripts and Dockerfile
2+
3+
This page provides a brief overview of the scripts and the Dockerfile in this repository.
4+
5+
## Scripts
6+
7+
* **`build.sh`**: Builds the Docker image for the MCP server and pushes it to a local registry.
8+
* **`inspect.sh`**: A development script that sets up a Python virtual environment and executes the `spendee_mcp.py` script.
9+
* **`inspect2.sh`**: Manages the MCP inspector tool, including cloning the repository, building the Docker image, and running the container.
10+
* **`run-mcp.sh`**: Activates the Python virtual environment, loads environment variables, and executes the `spendee_mcp.py` script.
11+
* **`run.py`**: A script for manual testing and interaction with the `SpendeeApi` and `SpendeeFirestore` classes. It's useful for debugging and experimentation.
12+
* **`run_tests.sh`**: The test runner script. It checks for a `.env` file and then executes the test suite using `pytest`.
13+
* **`re-deploy.sh`**: This script was requested for documentation but does not exist in the repository.
14+
15+
## Dockerfile
16+
The `Dockerfile` sets up a Python 3.11 environment, installs dependencies from `requirements.txt`, copies the application code, and defines the entry point to run the MCP server.

docs/spendee.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Spendee
2+
3+
## What it is
4+
Spendee is a personal finance application that helps users track their expenses and income. This client library provides a Python interface to the Spendee API.
5+
6+
## Core Concepts
7+
* **Wallets:** Wallets represent your accounts (e.g., bank account, cash).
8+
* **Transactions:** Transactions are individual expenses or incomes.
9+
* **Categories:** Categories help you classify your transactions (e.g., food, transportation).
10+
* **Labels:** Labels provide an additional way to organize your transactions.
11+
12+
---
13+
For implementation details, see `spendee/agents.md`.

docs/testing.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Testing
2+
3+
## Overview
4+
This project uses a combination of unit tests and integration tests to ensure code quality. We use `pytest` as our primary testing framework.
5+
6+
## MCP Testing
7+
MCP tests are located in the `tests/mcp` directory. These tests focus on verifying the logic of the orchestration tasks.
8+
9+
## Spendee Firestore Testing
10+
Spendee Firestore tests are located in the `tests/spendee` directory. These tests focus on verifying the interaction between the Spendee client and the Firestore database.
11+
12+
---
13+
For implementation details, see `tests/agents.md`.

mcp/agents.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# MCP Agent Guide
2+
3+
This document provides AI coding assistants with essential context for working with the MCP server.
4+
5+
## Key Files
6+
* **`spendee/spendee_mcp.py`**: This file contains the implementation of the MCP server. It uses the `SpendeeFirestore` class to interact with Spendee.
7+
* **`run-mcp.sh`**: This script is used to run the MCP server.
8+
* **`inspect.sh`**: This script is a development script that sets up a Python virtual environment and executes the `spendee_mcp.py` script.
9+
* **`inspect2.sh`**: This script is used to run the MCP Inspector, which is a tool for debugging MCP servers.
10+
11+
## How to Work with the MCP Server
12+
When working with the MCP server, you will primarily be modifying the `spendee/spendee_mcp.py` file. Here are some common tasks:
13+
* **Adding New Endpoints**: Add new methods to the `SpendeeMcp` class to expose new functionality.
14+
* **Modifying Existing Endpoints**: Modify the existing methods in the `SpendeeMcp` class to change their behavior.
15+
* **Running the Server**: Use the `run-mcp.sh` script to run the MCP server.
16+
* **Debugging the Server**: Use the `inspect2.sh` script to run the MCP Inspector and debug the server.

mise.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[tools]
2+
python = "3.11"
3+
jq = "latest"
4+
bws = "npm:@bitwarden/cli"
5+
6+
[env]
7+
BWS_ACCESS_TOKEN = { source = "bws", secret = "BWS_ACCESS_TOKEN" }

0 commit comments

Comments
 (0)