|
3 | 3 | ## Overview |
4 | 4 | This document provides AI coding assistants with essential context for working with the spendee-python-client project. |
5 | 5 |
|
| 6 | +**Project Purpose:** This is a Python client for the Spendee personal finance app. The original client was based on an undocumented REST API and has been deprecated. The current implementation uses Google Firestore, which is what the Spendee web application uses. The project is evolving to include an MCP (Multi-Agent Collaboration Protocol) server, which will allow AI agents to interact with the Spendee data for tasks like smart categorization and conversational data exploration. |
| 7 | + |
| 8 | +**Core Components:** |
| 9 | +- `SpendeeFirestore` class in `spendee/spendee_firestore.py` - main interface for Spendee data |
| 10 | +- `FirebaseClient` class in `spendee/firebase_client.py` - handles authentication |
| 11 | +- Methods decorated with `@mcp_tool` are exposed to the MCP server |
| 12 | +- See `docs/firestore-schema.md` for Firestore schema information |
| 13 | + |
6 | 14 | ## Development Environment Setup |
7 | 15 | This project uses [mise](https://mise.jdx.dev/) to manage the development environment and leverages python virtual environment by relying on the [requirements.txt](requirements.txt) file. For details how the environment set up works, look into the [setup.sh](setup.sh) file. Even after the setup with mise, you need to activate the python virtual environment as well. |
8 | 16 |
|
| 17 | +**Setup Steps:** |
| 18 | + |
| 19 | +1. **Ensure wanted code state:** |
| 20 | + |
| 21 | +Check if you are already on a feature branch, if not change to main, then pull, to work with the latest code version. |
| 22 | +```bash |
| 23 | +git pull |
| 24 | +``` |
| 25 | + |
| 26 | +2. **Run the setup script:** |
| 27 | +For agents, it populates the .env file using the bitwarden credentials available in the enrivonment. |
| 28 | +```bash |
| 29 | + ./setup.sh |
| 30 | +``` |
| 31 | + |
| 32 | +3. **Activate the virtual environment:** |
| 33 | +```bash |
| 34 | + source .venv/bin/activate |
| 35 | +``` |
| 36 | + |
| 37 | +## Running the Application |
| 38 | + |
| 39 | +**Manual Testing:** |
| 40 | +The `run.py` script is used for manual testing and experimentation. You can modify it to call the methods you want to test. |
| 41 | +```bash |
| 42 | +./run.py |
| 43 | +``` |
| 44 | + |
| 45 | +**Running Tests:** |
| 46 | +The project uses `pytest` for testing. |
| 47 | +```bash |
| 48 | + |
| 49 | +# For spendee-firestore client testing |
| 50 | +python -m pytest tests/ -v --tb=short |
| 51 | +#alternatively use ./run_tests.sh |
| 52 | + |
| 53 | +# For agent based MCP testing |
| 54 | +python -m pytest agent-test/ -v --tb=short |
| 55 | +``` |
| 56 | + |
| 57 | +**Building the MCP Server:** |
| 58 | +The project includes a `Dockerfile` to build the MCP server. |
| 59 | +```bash |
| 60 | +./build.sh |
| 61 | +``` |
| 62 | + |
| 63 | +This will build a Docker image named `spendee-mcp` and push it to a local registry. |
| 64 | + |
9 | 65 | ## Secrets Management |
10 | 66 | 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. |
11 | 67 |
|
@@ -53,10 +109,13 @@ It is left there if anytime a function would be needed from it, but all developm |
53 | 109 |
|
54 | 110 | The authentication in the firebase_client.py is not intuitive, you may used to have more seamless firebase authentication, but THIS WORKS, DO NOT MODIFY. I was not able to make it work using the google.oauth2.credentials, do not try re-implementing that. Maybe because web page flow was only enabled by original authors and service owners, and python SDK based auth flow differs. Maybe because that library is intended for admin API access, not user-client access, I am not an expert in this, but did considerable trial-and-error on that front. |
55 | 111 |
|
56 | | - |
57 | 112 | If you face authorization problems, troubleshoot what identities and wallets are used, or you may experiment with new firebase centric functions, but the authentication steps in the login flow should be only modified if user approved or explicitly asked. |
58 | 113 |
|
59 | | -## Jules Agent |
| 114 | +### Logging |
| 115 | + |
| 116 | +The project uses the `logging` module. A `debug.log` file is created with debug-level logs. |
| 117 | + |
| 118 | +## AI Agent (Google Jules, Claude code, Gemini, Openai codex, etc...) |
60 | 119 |
|
61 | 120 | ### Session Start Checklist |
62 | 121 | - `git pull origin main` |
|
0 commit comments