The Personal Finance Tracker is a command-line application built to help users manage their personal finances by tracking income and expenses. It supports core operations such as adding, editing, deleting transactions and generating financial reports. The application is built using Kotlin and uses CSV file storage for persistent data management.
This application is designed to be simple, extensible, and reliable, with a focus on testing and clean code practices.
- Add, edit, and delete transactions: Provides functionality to manage your financial records easily.
- Transaction Validation: Ensures no invalid data (e.g., no negative amounts, duplicate transaction IDs).
- Generate monthly financial reports: Summarizes income, expenses, and net balance for a given month.
- Generate reports for a custom date range: View financial data for any specified period.
- Store transaction data in CSV files for long-term persistence: Ensures your data is saved between application runs.
- Load and save transactions using a flexible CSV-based approach: Simplifies file management without a database.
This project follows a Test-Driven Development (TDD) approach.Test methods are defined in the /test directory and are designed to validate the business logic implemented in the main source code.
- Each core functionality (e.g., add/edit/delete transaction) has its own dedicated set of tests.
- A custom
check(actual, expected)helper function ensures clear output on test success/failure. - Continuous Testing with GitHub Actions : Automated tests are executed on every pull request and push using GitHub Actions to ensure the integrity and stability of the codebase.
The project uses this Principles in classes (InMemoryDatasource,CSVDatasource,TransactionRepositoryImpl) as below :
interface LocalDatasource {
fun addTransaction(transaction: Transaction): Boolean
fun deleteTransaction(id: Int): Boolean
fun editTransaction(transaction: Transaction): Boolean
fun getAllTransactions(): List<Transaction>
fun getTransactionById(id: Int): Transaction
fun getMonthlyReport(date: LocalDate): Report
fun getTransactionsByDateRange(startDate: LocalDate, endDate: LocalDate): List<Transaction>
}
class InMemoryDatasource : LocalDatasource {}
class CSVDatasource(private val csvFileHandler: CsvFileHandler) : LocalDatasource {}
The class parameter accepts objects from InMemoryDatasource and CSVDatasource classes
TransactionRepositoryImpl(private val datasource: LocalDatasource) : TransactionRepository {}
val datasource: LocalDatasource = InMemoryDatasource()
val repo = TransactionRepositoryImpl(datasource)
- Java 21 or higher ☕
- Kotlin 1.9 or higher 🛠️
- Gradle (wrapper included) ⚡
-
Clone the repository:
git clone https://github.com/Beijing-Squad/PersonalFinanceTracker.git cd PersonalFinanceTracker -
Build the project:
./gradlew build
-
Run the application 🚀:
To run the project from the terminal:
./gradlew run
4.Test Command
./gradlew testAlternatively, you can run the main class directly through the IntelliJ IDEA if you prefer.
The project is designed to be used via the command line. After running the application, you will interact with the system through a series of menu options or commands.
======================
PERSONAL FINANCE TRACKER
======================
1. Add Transaction
2. View Transactions
3. Edit Transaction
4. Delete Transaction
5. Generate Monthly Report
0. Exit
======================
1. View All Transactions
2. View Transactions By Date
3. View Transactions By ID