A self-hosted, LLM-powered personal finance management web application that automatically categorizes your expenses and provides detailed analytics.
- Automated Expense Categorization: Uses LLM (OpenAI GPT or local Ollama) to intelligently categorize transactions
- Multiple File Format Support: Upload CSV, Excel, or PDF bank statements
- Rich Analytics Dashboard: View spending patterns by week, month, quarter, or year
- Interactive Visualizations: Charts and graphs for easy analysis
- Self-Hosted: Complete control over your financial data
- Single Docker Container: Easy deployment with external database support
- Flexible LLM Options: Use OpenAI API or run locally with Ollama
The application provides:
- File upload interface for bank statements
- Summary cards showing income, expenses, and net balance
- Category breakdown with interactive pie charts
- Time-based trends with line charts
- Transaction history table
- Upload history tracking
- Backend: FastAPI (Python)
- Frontend: HTML/CSS/JavaScript with Chart.js
- Database: PostgreSQL (external or containerized)
- LLM: OpenAI GPT-3.5/4 or Ollama (local)
- Docker and Docker Compose installed
- PostgreSQL database (external or use the included one)
- OpenAI API key OR Ollama installed (for local LLM)
- Clone the repository
git clone <your-repo-url>
cd finance-manager- Configure environment variables
Copy the example environment file:
cp .env.example .envEdit .env with your settings:
For OpenAI (recommended for best results):
DATABASE_URL=postgresql://user:password@db:5432/financedb
USE_OLLAMA=false
OPENAI_API_KEY=sk-your-actual-openai-api-key
OPENAI_MODEL=gpt-3.5-turboFor Ollama (local, no API costs):
DATABASE_URL=postgresql://user:password@db:5432/financedb
USE_OLLAMA=true
OLLAMA_URL=http://ollama:11434/v1
OLLAMA_MODEL=llama2- Start the application
docker-compose up -d- Access the application
Open your browser and navigate to:
http://localhost:8000
To use your own PostgreSQL database instead of the containerized one:
- Update the DATABASE_URL in your
.envfile:
DATABASE_URL=postgresql://username:password@your-db-host:5432/your-database- Comment out the db service in
docker-compose.yml:
# db:
# image: postgres:15-alpine
# ...- Remove the depends_on in the finance-manager service:
finance-manager:
build: .
# Remove or comment out:
# depends_on:
# - dbThe parser automatically detects common column names:
- Date: date, transaction date, posting date, trans date
- Description: description, memo, payee, merchant, details
- Amount: amount, transaction amount, debit, credit
Example CSV format:
Date,Description,Amount
2024-01-15,Grocery Store,-45.67
2024-01-16,Salary Deposit,2500.00
2024-01-17,Gas Station,-35.20Same column detection as CSV files. Supports standard Excel formats.
Automatically extracts transaction data from PDF bank statements using LLM. Works best with structured PDF statements from major banks.
-
Upload a Statement
- Click "Choose File" and select your bank statement (CSV, Excel, or PDF)
- Click "Upload & Process"
- Wait for the LLM to categorize all transactions
-
View Analytics
- Select time period (Week/Month/Quarter/Year)
- Review summary cards for income, expenses, and net
- Analyze spending by category using the pie chart
- Track trends over time with the line chart
-
Review Transactions
- Scroll down to see all transactions
- Each transaction shows date, description, category, and amount
-
Check Upload History
- View all previously uploaded files
- See processing status and transaction counts
The LLM automatically assigns transactions to these categories:
- Food & Dining
- Groceries
- Transportation
- Shopping
- Entertainment
- Bills & Utilities
- Healthcare
- Travel
- Income
- Transfer
- Other
The application provides a REST API:
POST /api/upload- Upload and process a bank statementGET /api/transactions- Get transactions with filtersGET /api/categories- Get all categoriesPOST /api/categories- Create a new categoryGET /api/analytics- Get analytics for a time periodGET /api/uploads- Get upload historyPUT /api/transactions/{id}/category- Update transaction categoryGET /health- Health check endpoint
API documentation available at: http://localhost:8000/docs
| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | postgresql://user:password@db:5432/financedb |
USE_OLLAMA |
Use local Ollama instead of OpenAI | false |
OPENAI_API_KEY |
Your OpenAI API key | Required if USE_OLLAMA=false |
OPENAI_MODEL |
OpenAI model to use | gpt-3.5-turbo |
OLLAMA_URL |
Ollama API endpoint | http://localhost:11434/v1 |
OLLAMA_MODEL |
Ollama model to use | llama2 |
To use Ollama instead of OpenAI:
-
Uncomment the Ollama service in
docker-compose.yml -
Pull a model (first time only):
docker-compose exec ollama ollama pull llama2- Update environment variables:
USE_OLLAMA=true
OLLAMA_URL=http://ollama:11434/v1
OLLAMA_MODEL=llama2For production use:
- Use an external database for better persistence and backups
- Set strong passwords in your environment variables
- Enable HTTPS using a reverse proxy (nginx, Traefik, etc.)
- Regular backups of your PostgreSQL database
- Monitor logs for any issues
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}# Check if database is running
docker-compose ps
# View logs
docker-compose logs db
docker-compose logs finance-manager- Verify your OPENAI_API_KEY is correct
- Check API quota and billing
- For Ollama, ensure the model is pulled:
docker-compose exec ollama ollama list
- Check file format is supported (CSV, XLSX, PDF)
- Ensure file contains proper column headers
- Review logs:
docker-compose logs finance-manager
- Install dependencies:
cd backend
pip install -r requirements.txt- Set environment variables:
export DATABASE_URL=postgresql://user:password@localhost:5432/financedb
export OPENAI_API_KEY=your-key-here- Run the application:
uvicorn app.main:app --reloadThe application automatically creates database tables on startup. For manual migration management, you can use Alembic (included in requirements).
- Data Privacy: All financial data stays on your server
- API Keys: Never commit API keys to version control
- Database: Use strong passwords and restrict access
- HTTPS: Always use HTTPS in production
- Updates: Keep Docker images and dependencies updated
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT License - feel free to use this for personal or commercial purposes.
For issues, questions, or contributions, please open an issue on GitHub.
Future enhancements:
- Budget tracking and alerts
- Recurring transaction detection
- Multi-user support with authentication
- Mobile app
- Export reports to PDF
- Integration with bank APIs
- Custom categorization rules
- Spending predictions using ML
Made with ❤️ for better personal finance management