web-api
Finance Wallet API
Sprint Boot Web API service for FinWallet application

A comprehensive RESTful API for personal finance management, built with Spring Boot 4 and Kotlin.
β¨ Features#
Core Functionality#
- π JWT Authentication - Secure user authentication with refresh tokens
- π³ Multi-Account Management - Manage multiple accounts (checking, savings, credit cards)
- πΈ Transaction Tracking - Record income, expenses, and transfers
- π Smart Categorization - 15 pre-defined categories + custom categories
- π― Budget Management - Create and track budgets with real-time alerts
- π Financial Goals - Set and track savings goals with progress monitoring
- π Receipt Attachments - Upload and manage transaction receipts/invoices
- π Dashboard Analytics - Comprehensive financial insights and statistics
- π Multi-Currency Support - Support for multiple currencies with exchange rates
Advanced Features#
- π± Real-time budget progress tracking
- π·οΈ Transaction tagging system
- π Location tracking for transactions
- π Automatic goal completion
- π Category-wise expense breakdown
- π Daily/weekly/monthly/yearly statistics
- π¨ Customizable colors and icons
- π Secure file storage with validation
π Quick Start#
Prerequisites#
- JDK 17 or higher
- PostgreSQL 15 or higher
- Gradle (wrapper included)
Installation#
- Clone the repository
git clone https://github.com/mixin27/finance-wallet-api.git
cd finance-wallet-api- Configure database
# Create database
createdb finance_wallet
# Update src/main/resources/application.properties
spring.datasource.url=jdbc:postgresql://localhost:5432/finance_wallet
spring.datasource.username=your_username
spring.datasource.password=your_password- Configure JWT secret
jwt.secret=your-super-secret-jwt-key-at-least-256-bits-long
jwt.expiration=86400000- Run the application
./gradlew bootRunThe API will be available at http://localhost:8080
π API Documentation#
Authentication Endpoints#
POST /api/auth/register - Register new user
POST /api/auth/login - Login and get JWT token
POST /api/auth/refresh - Refresh access tokenAccount Endpoints#
GET /api/accounts - Get all accounts
POST /api/accounts - Create new account
GET /api/accounts/{id} - Get account details
PUT /api/accounts/{id} - Update account
DELETE /api/accounts/{id} - Delete accountTransaction Endpoints#
GET /api/transactions - Get all transactions
POST /api/transactions - Create transaction
POST /api/transactions/transfer - Transfer between accounts
GET /api/transactions/{id} - Get transaction details
PUT /api/transactions/{id} - Update transaction
DELETE /api/transactions/{id} - Delete transactionCategory Endpoints#
GET /api/categories - Get all categories
GET /api/categories?type=INCOME - Get income categories
POST /api/categories - Create custom category
PUT /api/categories/{id} - Update category
DELETE /api/categories/{id} - Delete categoryBudget Endpoints#
GET /api/budgets - Get all budgets
GET /api/budgets/active - Get active budgets with progress
POST /api/budgets - Create budget
PUT /api/budgets/{id} - Update budget
DELETE /api/budgets/{id} - Delete budgetGoal Endpoints#
GET /api/goals - Get all goals
GET /api/goals?activeOnly=true - Get active goals only
POST /api/goals - Create goal
PATCH /api/goals/{id}/progress - Update goal progress
PATCH /api/goals/{id}/complete - Mark goal as completed
PUT /api/goals/{id} - Update goal
DELETE /api/goals/{id} - Delete goalDashboard Endpoints#
GET /api/dashboard - Get dashboard overview
GET /api/dashboard/statistics - Get statistics (custom range)
GET /api/dashboard/statistics/this-month - This month statistics
GET /api/dashboard/statistics/last-month - Last month statistics
GET /api/dashboard/statistics/this-year - This year statisticsFile Upload Endpoints#
POST /api/transactions/{id}/attachments - Upload receipt
GET /api/transactions/{id}/attachments - Get attachments
DELETE /api/transactions/{id}/attachments/{fileId} - Delete attachment
GET /api/uploads/{subDir}/{filename} - View/download fileπ§ Configuration#
Database Configuration#
spring.datasource.url=jdbc:postgresql://localhost:5432/finance_wallet
spring.datasource.username=your_username
spring.datasource.password=your_password
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=falseJWT Configuration#
jwt.secret=your-256-bit-secret-key
jwt.expiration=86400000
jwt.refresh-expiration=604800000File Upload Configuration#
spring.servlet.multipart.enabled=true
spring.servlet.multipart.max-file-size=5MB
spring.servlet.multipart.max-request-size=10MB
app.upload.dir=uploads
app.upload.max-file-size=5242880CORS Configuration#
# Configured in SecurityConfig.kt
# Allows localhost with any port for developmentπ Example Usage#
1. Register and Login#
# Register
curl -X POST http://localhost:8080/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "john@example.com",
"username": "johndoe",
"password": "securePass123",
"fullName": "John Doe"
}'
# Login
curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "john@example.com",
"password": "securePass123"
}'2. Create Account#
curl -X POST http://localhost:8080/api/accounts \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Main Checking",
"accountTypeId": "account-type-uuid",
"currencyId": "currency-uuid",
"initialBalance": 5000.00,
"color": "#4CAF50",
"icon": "π°"
}'3. Add Transaction#
curl -X POST http://localhost:8080/api/transactions \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"accountId": "account-uuid",
"type": "EXPENSE",
"amount": 45.99,
"transactionDate": "2024-01-15T19:30:00",
"description": "Groceries at Whole Foods",
"categoryId": "food-category-uuid",
"tags": ["groceries", "weekly shopping"]
}'4. Create Budget#
curl -X POST http://localhost:8080/api/budgets \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Monthly Food Budget",
"amount": 600.00,
"period": "MONTHLY",
"startDate": "2024-01-01",
"currencyId": "currency-uuid",
"categoryId": "food-category-uuid",
"alertThreshold": 80
}'5. Create Financial Goal#
curl -X POST http://localhost:8080/api/goals \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Emergency Fund",
"targetAmount": 10000.00,
"initialAmount": 1000.00,
"targetDate": "2024-12-31",
"currencyId": "currency-uuid",
"icon": "π°",
"color": "#4CAF50"
}'ποΈ Project Structure#
src/main/kotlin/com/financewallet/api/
βββ config/ # Configuration classes
β βββ SecurityConfig.kt
β βββ DataInitializer.kt
βββ controller/ # REST controllers
β βββ AuthController.kt
β βββ AccountController.kt
β βββ TransactionController.kt
β βββ CategoryController.kt
β βββ BudgetController.kt
β βββ GoalController.kt
β βββ DashboardController.kt
β βββ FileController.kt
βββ service/ # Business logic
β βββ auth/
β βββ account/
β βββ transaction/
β βββ category/
β βββ budget/
β βββ goal/
β βββ dashboard/
β βββ file/
βββ repository/ # Data access layer
βββ entity/ # JPA entities
βββ dto/ # Data transfer objects
β βββ request/
β βββ response/
βββ security/ # Security components
βββ exception/ # Exception handling
βββ FinanceWalletApiApplication.ktπ§ͺ Testing#
Comprehensive testing guides available for all endpoints:
- Category Management API
- Budget Management API
- File Upload API
- Dashboard & Statistics API
- Goals Management API
Each guide includes:
- Complete curl examples
- Expected responses
- Error handling
- Common use cases
- Pro tips
π Security Features#
- β JWT-based authentication
- β Password encryption (BCrypt)
- β Refresh token rotation
- β CORS configuration
- β Path traversal protection
- β File type validation
- β File size limits
- β User data isolation
- β SQL injection prevention (JPA)
- β XSS protection
π Database Schema#
Core Tables#
users- User accounts and authenticationrefresh_tokens- JWT refresh tokensaccounts- Financial accountsaccount_types- Account type definitionstransactions- Income/expense/transfer recordstransaction_attachments- Receipt filescategories- Transaction categoriesbudgets- Budget definitionsgoals- Financial goalscurrencies- Currency definitionsexchange_rates- Currency exchange ratestags- Transaction tagsuser_preferences- User settingssync_log- Synchronization tracking
π Features in Detail#
1. Smart Categorization#
- 15 pre-defined system categories
- Unlimited custom categories
- Hierarchical categories (parent/child)
- Color-coded for easy identification
- Icon support for visual appeal
2. Budget Tracking#
- Multiple budget periods (daily, weekly, monthly, yearly, custom)
- Category-specific or global budgets
- Real-time progress tracking
- Alert thresholds (80%, 90%, etc.)
- Over-budget warnings
- Automatic period calculation
3. Goal Management#
- Track multiple financial goals
- Progress percentage calculation
- Remaining amount tracking
- Target date support
- Link to specific accounts
- Auto-completion when target reached
- Manual completion option
4. Dashboard Analytics#
- Total balance across accounts
- Monthly income/expense
- Savings calculation
- Month-over-month comparison
- Category breakdown
- Daily trends for charts
- Custom date range analysis
5. File Attachments#
- Support for images (JPEG, PNG, GIF, WebP)
- PDF document support
- 5MB file size limit
- Secure local storage
- Path traversal protection
- Multiple attachments per transaction
π Deployment#
Docker Deployment#
# Build Docker image
docker build -t finance-wallet-api .
# Run with Docker Compose
docker-compose up -dCloud Deployment#
- Heroku
- AWS Elastic Beanstalk
- Google Cloud Run
- Azure App Service
π€ Contributing#
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
π License#
This project is licensed under the MIT License - see the LICENSE file for details.
π¨βπ» Author#
Your Name
- GitHub: @mixin27
π Acknowledgments#
- Spring Boot team for the amazing framework
- Kotlin team for the modern language
- PostgreSQL for reliable database
- All contributors and users of this project
π Support#
For support, email kyawzayartun.contact@gmail.com or open an issue on GitHub.
πΊοΈ Roadmap#
Version 1.0 (Current) β #
- Authentication & Authorization
- Account Management
- Transaction Management
- Category System
- Budget Tracking
- Goal Management
- File Uploads
- Dashboard Analytics
Version 1.1 (Planned)#
- Recurring Transactions
- OAuth2 Integration (Google, Apple)
- User Preferences
- Email Notifications
- Live Exchange Rates
Version 2.0 (Future)#
- Bill Reminders
- Investment Tracking
- Report Generation (PDF)
- Data Export (CSV, Excel)
- Multi-user Support
- Mobile App Integration
- Webhooks
- API Rate Limiting
Made with β€οΈ using Spring Boot & Kotlin

