Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/akevalion/life_cost/llms.txt

Use this file to discover all available pages before exploring further.

Life Cost is a personal finance web application built with Flask and SQLAlchemy. Its backend exposes a REST API that the built-in frontend uses to manage wallets, record money transfers, organise transactions with categories and tags, and retrieve analytics data. All state is scoped to the authenticated user’s last visited wallet, which means most data-returning endpoints automatically filter results by the wallet the user most recently viewed.

Base URL

There is no version prefix. All endpoints are served directly from the application root:
http://<host>:<port>
The default development port is 3000 (as set in index.py). When deploying with Docker or a reverse proxy, map to whatever external port suits your setup.
# Example — local development
http://localhost:3000

# Example — production behind a reverse proxy
https://your-domain.com

Authentication

All protected endpoints rely on a Flask-Login session cookie obtained after completing the Google OAuth 2.0 flow. There are no API keys or Bearer tokens. See the Authentication page for the full flow. Requests to @login_required endpoints that are made without a valid session cookie are met with an HTTP 302 redirect to /google_login — not a JSON 401 response.

Content-Type

Any request that sends a body (all POST endpoints) must include the header:
Content-Type: application/json

Endpoints

Wallets

MethodPathAuth RequiredDescription
GET/wallet/<id>Fetch a single wallet by ID
POST/add_walletCreate a new wallet and associate it with all existing users
POST/update_last_visited_walletSet the current user’s active (last visited) wallet

Users

MethodPathAuth RequiredDescription
GET/user/<id>Fetch a single user record by ID
GET/profileReturn the authenticated user’s profile (name, email, avatar)

Categories

MethodPathAuth RequiredDescription
GET/category/<id>Fetch a single category by ID
POST/add_categoryCreate a new category

Tags

MethodPathAuth RequiredDescription
GET/tag/<id>Fetch a single tag by ID
POST/add_tagCreate a new tag linking a category to a money transfer
DELETE/remove_tag/<id>Delete a tag by ID

Transactions (Money Transfers)

MethodPathAuth RequiredDescription
GET/money/<id>Fetch a single money transfer by ID
POST/add_moneyRecord a new money transfer in the active wallet
POST/edit_moneyUpdate an existing money transfer and replace its tags
DELETE/remove_money/<id>Delete a money transfer and all its associated tags
GET/last_money_transfers/<limit>Return the <limit> most recent transfers in the active wallet
GET/money_transfers_by_category/<category_id>Return all transfers tagged with a given category
POST/money_transfer_from_dateReturn transfers for a specific calendar day (client timezone-aware)
POST/money_transfersReturn transfers for a full month with daily totals and averages

Charts & Analytics

MethodPathAuth RequiredDescription
POST/chart_dataReturn daily spending totals for all time (for a line/bar chart)
POST/pi_dataReturn total income vs. total expenditure (for a pie chart)

Auth & Views

MethodPathAuth RequiredDescription
GET/google_loginEntry point for the Google OAuth flow
GET/logoutLog out the current user and redirect to /
GET/Home page — renders the app if authenticated, otherwise redirects to /google_login
GET/privacyPrivacy policy page
GET/termsTerms of service page

Error Handling

ScenarioBehaviour
Unauthenticated request to a @login_required routeHTTP 302 redirect to /google_login
Resource not found (e.g. unknown wallet/transfer ID)HTTP 404 (Flask’s default get_or_404)
Database write failureHTTP 500 with a JSON {"message": "Error while adding …"} body
Missing required JSON fieldTypically an unhandled KeyError — ensure all required fields are present
The Life Cost API is designed primarily for use by its own browser-based frontend. Authentication relies on browser session cookies managed by Flask-Login — no API key or Bearer token mechanism is supported. Automated or server-to-server clients must replicate the full browser OAuth cookie flow to authenticate.

Explore by Resource

Wallets

Create and manage spending wallets. Set the active wallet context used by all transaction and analytics endpoints.

Transactions

Add, edit, delete, and query money transfers with full tag and category support.

Charts & Analytics

Retrieve daily spending series and income/outcome breakdowns for visualisation.

Authentication

Understand the Google OAuth 2.0 session-cookie flow required to access protected endpoints.

Build docs developers (and LLMs) love