The Finance Tracker is a full-stack application designed to help users manage their personal finances, track transactions, and monitor accounts. It is built using a microservices architecture with a distinct Spring Boot backend and a JavaFX frontend, all managed by Maven.
| Component | Technology | Description |
|---|---|---|
| Backend | Java 17, Spring Boot 3.x | Provides the REST API, business logic, and persistence layer. |
| Frontend | Java 17, JavaFX | A desktop application providing the user interface. |
| Database | PostgreSQL | Relational database for storing user, account, and transaction data. |
| Build Tool | Maven | Manages dependencies and the multi-module project structure. |
| Containerization | Docker & Docker Compose | Used for easy setup and deployment of the backend and database. |
This is a multi-module Maven project, organized into two main parts:
ahtat204-finance-tracker/
├── pom.xml # Root Maven file defining sub-modules
├── FinanceTrackerBackend/ # The Spring Boot REST API module
│ ├── src/main/java/... # Backend Java source code (Controllers, Services, Entities)
│ ├── docker-compose.yml # Docker setup for the backend and Postgres DB
│ └── pom.xml # Backend specific dependencies (JPA, Web, Postgres, Lombok)
└── FinanceTrackerFrontEnd/ # The JavaFX Desktop UI module
├── src/main/java/... # Frontend JavaFX source code (UI Controllers)
└── pom.xml # Frontend specific dependencies (JavaFX modules)
The backend is a standard Spring Boot application responsible for data persistence and API exposure.
| Layer | Classes | Responsibilities |
|---|---|---|
| Controllers | UserController, AccountController, TransactionController |
Exposes RESTful API endpoints for all operations (CRUD). |
| Services | UserServiceImpl, AccountServiceImpl, TransactionServiceImpl |
Implements the business logic, transactional management, and data validation. |
| Entities | User, Account, Transaction |
JPA entities representing the database schema. |
| Repositories | UserRepository, AccountRepository, TransactionRepository |
Spring Data JPA interfaces for database access. |
The API is exposed under the /api/ path (e.g., http://localhost:8080/api/accounts).
| Resource | HTTP Method | Endpoint | Description |
|---|---|---|---|
| Accounts | GET |
/api/accounts/{id} |
Retrieve a specific account. |
| Accounts | POST |
/api/accounts |
Create a new account. |
| Transactions | GET |
/api/transactions |
Retrieve all transactions. |
| Users | GET |
/api/users |
Retrieve all users. |
The easiest way to get the backend and database running is by using Docker Compose.
Navigate to the project root and use Maven to clean and package the application.
# In the repository root:
./mvnw clean packageThis will generate the necessary JAR file for the Docker image within FinanceTrackerBackend/target/.
Create a file named .env in the FinanceTrackerBackend/ directory with your desired database credentials and connection string:
# Example .env file in FinanceTrackerBackend/
DB_USERNAME=finuser
DB_PASSWORD=secret
database=finance_tracker_db
DB_URL=jdbc:postgresql://db:5432/${database}
With the .env file and the built JAR, you can start the entire backend stack (PostgreSQL DB and Spring Boot API).
# Navigate to the backend directory:
cd FinanceTrackerBackend/
# Start the services
docker-compose up --build -d- The PostgreSQL database will be accessible on
localhost:5432. - The Spring Boot API will be accessible on
http://localhost:8080.
The FinanceTrackerFrontEnd is a standard JavaFX application. It can be run after the backend is up and running:
- Open the project in your IDE (e.g., IntelliJ IDEA or VS Code).
- Run the
org.asue24.financetrackerfrontend.HelloApplicationclass.
The backend includes unit tests for its core business logic within the service layer.
FinanceTrackerBackend/src/test/java/.../services/
├── account/AccountServiceImplTest.java
├── transaction/TransactionServiceImplTest.java
└── user/UserServiceImplTest.java
To run all tests:
./mvnw testto test the API , Install Docker ,if you don't have it already, create a file with "docker-compose.yml" , copy-paste the content below:
version: '3.9'
services:
# --- API Service Configuration ---
api:
image: lahcen3ahtat/finance-tracker:1.1 # The API's Docker image
container_name: app
ports:
- "8080:8080" # Map host port 8080 to container port 8080
environment:
# These environment variables
SPRING_DATASOURCE_URL: ${DB_URL}
SPRING_DATASOURCE_USERNAME: ${DB_USERNAME}
SPRING_DATASOURCE_PASSWORD: ${DB_PASSWORD}
SPRING_JPA_HIBERNATE_DDL_AUTO: update
depends_on:
- db # Ensure PostgresSQL starts before the API
networks:
- app-network
# ---PostgresSQL database service configuration
db:
image: postgres:13.1-alpine
container_name: db
environment:
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${database}
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
# --- Docker Volume for Data Persistence ---
volumes:
mongo-data:
# --- Docker Network for Service Communication ---
networks:
app-network: