Skip to content

NemSothea/AIExpenseTrackerBackEnd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Expense Tracker πŸ“±πŸ’°

Spring Boot Swift PostgreSQL React

An intelligent expense management application powered by AI

Features β€’ Installation β€’ API Docsβ€’ Team

πŸš€ Overview

AI Expense Tracker is a comprehensive financial management solution that leverages artificial intelligence to simplify expense tracking. The application features a robust Spring Boot backend, native iOS mobile app, and responsive web dashboard.

🎯 Key Highlights

  • AI-Powered: Automatic receipt scanning and expense categorization
  • Multi-Platform: iOS app + Web dashboard with real-time sync
  • Voice Control: Hands-free expense creation via voice commands
  • Smart Analytics: Interactive charts and spending insights

✨ Features

πŸš€ Enhanced AIExpense API v2

πŸ” Authentication & User Management

  • POST : /auth/signup Register new user
  • POST : /auth/login User login Refresh JWT token
  • POST : /auth/logout User logout
  • GET : /auth/profile Get user profile
  • PUT : /auth/profile Update user profile

πŸ’° Expense Management Admin Role

  • GET : /api/expenses Get all expenses (with filters)
  • POST : /api/expenses Create expense (manual/AI)
  • GET : /api/expenses/{id} Get specific expense
  • PUT : /api/expenses/{id} Update expense (full)
  • PATCH : /api/expenses/{id} Update expense (partial)
  • DELETE : /api/expenses/{id} Delete expense
  • PATCH : /api/expenses/{id}/disable Disable expense

πŸ’° Expense Management User Role

  • POST : /api/create-expenses Create expense
  • PUT : /api/create-expenses/{id} Update expense (full)
  • DELETE : /api/create-expenses/{id} Delete expense
  • PATCH : /api/create-expenses/{id} Update expense (partial)

πŸ“Š Analytics & Dashboard

  • GET : /api/dashboard Main dashboard data
  • GET : /api/dashboard/history-pagination Paginated history

🏷️ Category Management

  • GET : /api/categories Get all categories
  • GET : /api/categories/active Get active categories
  • POST : /api/categories Create category
  • GET : /api/categories/{id} Get specific category
  • PUT : /api/categories/{id} Update category
  • DELETE : /api/categories/{id} Delete category permanently
  • DELETE : /api/categories/{id}/soft Soft delete category

πŸ”§ Technical Features

  • Backend: Spring Boot with RESTful APIs
  • Database: PostgreSQL with optimized queries
  • Mobile: Native iOS app built with SwiftUI
  • Web: React dashboard with Tailwind CSS
  • Security: JWT authentication with secure credential storage

πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   iOS Mobile    β”‚ ◄──│  Spring Boot     β”‚ ──►│  PostgreSQL     β”‚
β”‚    (SwiftUI)    β”‚    β”‚   Backend API    β”‚    β”‚   Database      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚
         β”‚                       β”‚
         β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Web Dashboard β”‚    β”‚  AI Services     β”‚
β”‚    (React)      β”‚    β”‚ (OCR, ML, Voice) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“₯ Installation

Prerequisites

  • Java 21+
  • PostgreSQL 12+
  • Xcode 15+ (for iOS development)
  • Node.js 18+ (for web dashboard)
  • Maven 3.6+

πŸ—„οΈ Database Setup

  1. Create Database:
CREATE DATABASE aiexpensedb;
  1. Create Users Table:
CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    version BIGINT NOT NULL DEFAULT 0,
    name VARCHAR(20) NOT NULL,
    email VARCHAR(255) UNIQUE,
    password VARCHAR(255) NOT NULL,
    contact VARCHAR(10) UNIQUE,
    role VARCHAR(255),
    enabled BOOLEAN
);

βš™οΈ Backend Setup

# Clone the repository
git clone https://github.com/NemSothea/AIExpenseTrackerBackEnd.git
cd AIExpenseTrackerBackEnd

# Configure database connection
# Edit src/main/resources/application.properties

# Run the application
mvn spring-boot:run

🌐 Frontend Setup

# Clone frontend repository
git clone https://github.com/NemSothea/AIExpenseTrackerFrontend.git
cd AIExpenseTrackerFrontend

# Create environment file
echo "VITE_BASE_URL=https://localhost:5173" > .env

# Install dependencies
npm install

# Start development server
npm run dev

πŸ“± iOS App Setup

  1. Open in Xcode:
git clone https://github.com/NemSothea/AI-Expense-Tracker.git
open AI-Expense-Tracker/AIExapenseTracker.xcodeproj
  1. Configure API Endpoint:

    • Update API_BASE_URL in NetworkManager.swift
    • Configure bundle identifier and signing certificates
  2. Build and Run:

    • Select target device/simulator
    • Press Cmd + R to build and run

πŸ“š API Documentation

Base URL

http://localhost:8080

πŸ” Authentication Endpoints

Register New User

POST /auth/signup

{
  "name": "Sothea",
  "email": "[email protected]",
  "password": "secret123",
  "contact": "0123456789",
  "role": "ROLE_CUSTOMER"
}

User Login

POST /auth/login

{
  "email": "[email protected]",
  "password": "secret123"
}

Response:

{
  "token": "eyJhbGciOiJIUzI1NiJ9...",
  "email": "[email protected]"
}

πŸ’° Expense Management

Get All Expenses

GET /api/expenses

curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  http://localhost:8080/api/expenses

Create New Expense

POST /api/expenses

{
  "amount": 29.99,
  "description": "Lunch at restaurant",
  "category": "Food & Dining",
  "date": "2024-12-19",
  "paymentMethod": "Credit Card"
}

Update Expense

PUT /api/expenses/{id}

Delete Expense

DELETE /api/expenses/{id}

πŸ“Š Categories

Get All Categories

GET /api/categories

πŸ” Interactive API Docs

Access Swagger UI at: http://localhost:8080/swagger-ui/index.html

βš™οΈ Swagger-ui

Process Flow

🎯 Usage Guide

Adding Expenses

  1. Manual Entry:

    • Tap the "+" button on main screen
    • Fill in expense details (amount, category, date, description)
    • Save to automatically categorize with AI
  2. Receipt Scanning:

    • Select "Scan Receipt" option
    • Capture receipt using device camera
    • AI extracts amount, merchant, and date automatically
    • Review and confirm details
  3. Voice Input:

    • Tap microphone icon
    • Speak expense details naturally: "I spent $15 on lunch today"
    • AI processes and creates expense entry

Viewing and Managing

  • Dashboard: View spending overview with interactive charts
  • Expense List: Scroll through all expenses with sort/filter options
  • Search: Find specific expenses by description or merchant
  • Categories: View spending breakdown by category

Advanced Features

  • Smart Filtering: Filter by date range, category, amount
  • Data Export: Export expenses to CSV format
  • Budget Alerts: Set monthly budgets and receive notifications
  • Multi-Currency: Support for different currencies

πŸ‘₯ Team

Role Member Responsibilities
Project Lead Sothea iOS development, Spring Boot API, AI integration
Database Architect Pisey PostgreSQL design, query optimization, data integrity
UI/UX Designer Seyha Application design, web dashboard development
Documentation Lead Srey Nich Documentation, presentations, demo preparation

πŸ› οΈ Development

Project Structure

AI-Expense-Tracker/
β”œβ”€β”€ backend/                 # Spring Boot application
β”‚   β”œβ”€β”€ src/main/java/
β”‚   β”œβ”€β”€ src/main/resources/
β”‚   └── pom.xml
β”œβ”€β”€ ios/                    # iOS SwiftUI application
β”‚   β”œβ”€β”€ Models/
β”‚   β”œβ”€β”€ Views/
β”‚   β”œβ”€β”€ ViewModels/
β”‚   └── Utilities/
└── frontend/              # React web dashboard
    β”œβ”€β”€ src/
    β”œβ”€β”€ public/
    └── package.json

Building from Source

Backend

cd backend
mvn clean package
java -jar target/expense-tracker-1.0.0.jar

iOS

cd ios
xcodebuild -workspace AIExapenseTracker.xcworkspace -scheme AIExapenseTracker

Frontend

cd frontend
npm run build
npm start

🀝 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Commit Message Guidelines

  • Use descriptive commit messages
  • Include relevant emojis for better readability:
    • 🎨: Code structure/format improvements
    • πŸ›: Bug fixes
    • ✨: New features
    • πŸ“: Documentation updates
    • πŸ”§: Configuration changes

πŸ› Troubleshooting

Common Issues

Backend won't start:

  • Check PostgreSQL is running: pg_isready
  • Verify database credentials in application.properties
  • Ensure port 8080 is available

iOS build failures:

  • Clean build folder: Shift + Cmd + K
  • Reset package caches: File > Packages > Reset Package Caches
  • Check signing certificates and bundle identifier

Frontend connection issues:

  • Verify backend is running on port 8080
  • Check VITE_BASE_URL in .env file
  • Clear browser cache or try incognito mode

Logs and Debugging

Backend logs: tail -f logs/application.log
iOS debugging: Use Xcode debug console
Frontend debugging: Browser developer tools

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • OpenAI for AI/ML capabilities
  • Spring Boot community for excellent documentation
  • SwiftUI team for modern iOS development framework
  • PostgreSQL for reliable database performance

πŸ“ž Support

πŸ”— Links


Made with ❀️ by the AI Expense Tracker Team

Simplifying financial management through AI power

About

AI ExpenseTracker BackEnd

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages