A Phoenix LiveView application for tracking personal expenses and managing budgets with real-time updates.
- Category Management: Create and manage expense categories with monthly budgets
- Expense Tracking: Add, edit, and delete expenses with detailed information
- Budget Monitoring: Real-time budget tracking with spending percentages
- Live Updates: Real-time UI updates using Phoenix LiveView
- Decimal Precision: Accurate money handling using Decimal library
Before you begin, ensure you have the following installed:
- Elixir (1.15 or later) - Installation Guide
- Erlang/OTP (26 or later) - Usually comes with Elixir
- Node.js (16 or later) - For asset compilation
- PostgreSQL (12 or later) - Installation Guide
elixir --version
node --version
psql --versiongit clone https://github.com/your-username/expense-tracker.git
cd expense-tracker# Install Elixir dependencies
mix deps.get
# Install Node.js dependencies for assets
npm install --prefix assets# Connect to PostgreSQL as superuser
sudo -u postgres psql
# Create user and database
CREATE USER expense_tracker WITH PASSWORD 'your_password' CREATEDB;
\qUpdate config/dev.exs with your database credentials:
config :expense_tracker, ExpenseTracker.Repo,
username: "expense_tracker",
password: "your_password",
hostname: "localhost",
database: "expense_tracker_dev",
# ... other config# This will create database, run migrations, and seed data
mix setupOr manually:
# Create the database
mix ecto.create
# Run migrations
mix ecto.migrate
# Optional: Run seeds (if any)
mix run priv/repo/seeds.exs# Start Phoenix server
mix phx.server
# Or start with interactive Elixir shell
iex -S mix phx.serverThe application will be available at http://localhost:4000
# Run all tests
mix test
# Run specific test files
mix test test/expense_tracker/expenses/
mix test test/expense_tracker_web/live/
# Run tests with coverage
mix test --cover
# Run tests in watch mode (if you have mix_test_watch)
mix test.watch# Format code
mix format
# Check for unused dependencies
mix deps.unlock --check-unused
# Static code analysis (if Credo is installed)
mix credo# Create a new migration
mix ecto.gen.migration migration_name
# Run migrations
mix ecto.migrate
# Rollback last migration
mix ecto.rollback
# Reset database (drops, creates, migrates)
mix ecto.reset
# Check migration status
mix ecto.migrationsexpense_tracker/
├── lib/
│ ├── expense_tracker/ # Business logic contexts
│ │ └── expenses/ # Expenses domain
│ │ ├── category.ex # Category schema
│ │ └── expense.ex # Expense schema
│ ├── expense_tracker_web/ # Web interface
│ │ └── live/ # LiveView modules
│ └── expense_tracker.ex # Application entry point
├── test/ # Test files
├── priv/
│ └── repo/
│ └── migrations/ # Database migrations
├── assets/ # Frontend assets
├── config/ # Configuration files
└── mix.exs # Project definition
- Navigate to "Categories" in the main menu
- Click "New Category"
- Fill in the name, description, and monthly budget
- Save the category
- Go to a category's detail page
- Click "New Expense"
- Enter expense details (description, amount, date, notes)
- Save the expense
- Each category shows total expenses vs. monthly budget
- Percentage indicators show spending levels
- Real-time updates when expenses are added/modified
For production deployment, set these environment variables:
# Database
DATABASE_URL=postgresql://user:pass@host/database
# Phoenix
SECRET_KEY_BASE=your_secret_key_base
PHX_HOST=your_domain.com
# Optional
PORT=4000Database Connection Error:
- Ensure PostgreSQL is running:
brew services start postgresql(macOS) orsudo service postgresql start(Linux) - Check database credentials in
config/dev.exs - Verify database exists:
mix ecto.create
Asset Compilation Error:
- Ensure Node.js is installed:
node --version - Install asset dependencies:
npm install --prefix assets - Clear asset cache:
rm -rf _build/dev/lib/*/priv/static/
Port Already in Use:
- Change port in
config/dev.exs:port: 4001 - Or kill process using port 4000:
lsof -ti:4000 | xargs kill -9
Mix Dependencies Error:
- Clean dependencies:
mix deps.clean --all - Reinstall:
mix deps.get
- Check the Phoenix Guides
- Visit Elixir Forum
- Review the NOTES.md file for architectural decisions
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes and add tests
- Run the test suite:
mix test - Format code:
mix format - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin feature/my-feature - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.