README.md•3.4 kB
# Expense Tracker API
A simple FastAPI application for tracking expenses with SQLite database and MCP server integration.
## Features
- **Web Dashboard**: Beautiful, modern UI for viewing expense analytics
- **SQLite Database**: Persistent storage for transactions
- **REST API**: Full CRUD operations for expense tracking
- **MCP Server**: AI assistant integration via Model Context Protocol
- **Simple & Clean**: Minimal dependencies, easy to understand
## Quick Start
1. **Install dependencies**:
```bash
pip install -r requirements.txt
```
2. **Run both API and MCP servers**:
```bash
python start.py
```
Or run separately:
```bash
# API server
python main.py
# MCP server (in another terminal)
python mcp_server.py
```
3. **Access the application**:
- **Dashboard**: http://localhost:8002/ (Main web interface)
- **API Docs**: http://localhost:8002/docs (Interactive API documentation)
- **MCP Server**: http://localhost:9002 (AI assistant integration)
4. **Populate sample data** (optional):
```bash
python seed_data.py
```
## Project Structure
```
server/
├── main.py # FastAPI application with routes
├── models.py # Pydantic models
├── store.py # SQLite data store
├── config.py # Configuration settings
├── mcp_server.py # MCP server for AI integration
├── start.py # Startup script
├── seed_data.py # Sample data populator
├── templates/
│ └── index.html # Dashboard web interface
├── requirements.txt # Dependencies
└── expenses.db # SQLite database (auto-created)
```
## Dashboard Features
The web dashboard provides:
- **Real-time Statistics**: View total income, expenses, and net balance at a glance
- **Category Breakdown**: Visual summary showing spending by category with percentages
- **Latest Transactions**: Quick view of recent financial activities
- **Auto-refresh**: Dashboard updates every 30 seconds automatically
- **Responsive Design**: Works beautifully on desktop and mobile devices
- **Dark Theme**: Easy on the eyes with modern dark mode UI
Access the dashboard at: **http://localhost:8002/**
## API Endpoints
### Dashboard
- `GET /` - Web dashboard interface (HTML)
### Transactions
- `GET /transactions` - List all transactions
- `GET /transactions/{id}` - Get specific transaction
- `POST /transactions` - Create new transaction
- `PUT /transactions/{id}` - Update transaction
- `DELETE /transactions/{id}` - Delete transaction
- `GET /transactions/search?q={query}` - Search transactions
### Analytics
- `GET /summary` - Get financial summary
- `GET /summary/categories` - Category breakdown
- `GET /transactions/type/{type}` - Get by type (income/expense)
- `GET /transactions/category/{category}` - Get by category
- `GET /transactions/date-range` - Get by date range
### System
- `GET /health` - Health check
## Database
Uses SQLite for persistent storage. Database file: `expenses.db`
## MCP Integration
The MCP server exposes all API endpoints as tools for AI assistants. Connect your agent to:
```
http://localhost:9002/mcp
```
## Configuration
Environment variables (optional):
- `HOST` - Server host (default: 0.0.0.0)
- `PORT` - API port (default: 8002)
- `MCP_HOST` - MCP host (default: localhost)
- `MCP_PORT` - MCP port (default: 9002)