Note
This project is under development. Some new features coming soon
Microservice-based application for managing personal finances.
- Language & Framework: Java 17, Spring Boot, Spring Security, Spring Data JPA
- Database: PostgreSQL
- Testing: JUnit, Mockito
- DevTools: Maven, Docker
- API documentation: OpenAPI (Swagger)
- User registration & login (JWT-based authentication)
- Track income and expenses
- Modular microservices architecture
- Unit & integration testing
- API documentation via Swagger / OpenAPI
git clone https://github.com/terletskij/microservice-financial-tracker.git
cd microservice-financial-tracker
In the root directory of the project, create a file named .env and add the following environment variables:
# === Database URLs ===
TRANSACTION_DATASOURCE_URL=jdbc:postgresql://transaction-db:5432/transaction_db
AUTH_DATASOURCE_URL=jdbc:postgresql://auth-db:5432/auth_db
# === Common Database Credentials ===
DB_USERNAME=your_db_username
DB_PASSWORD=your_db_password
# === Ports Configuration ===
POSTGRES_PORT=5432
TRANSACTION_SERVICE_PORT=8082
AUTH_SERVICE_PORT=8081
# === Database Names ===
TRANSACTION_DB_NAME=transaction_db
AUTH_DB_NAME=auth_db
# === JWT Configuration ===
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRATION=3600000 # in milliseconds (e.g., 1 hour)
JWT_REFRESH_EXPIRATION=86400000 # in milliseconds (e.g., 24 hours)
Note
Replace the values (e.g., your_db_username, your_jwt_secret_key, etc.) with your own configuration. These values are used by Docker containers and Spring Boot services during startup.
Start the application by using the following command
docker-compose up --build
After you have successfully launched the project (see steps above), you can test the API using tools like Postman, curl, or directly via Swagger UI.
Example: Register a New User
POST auth/register
📍 URL via gateway:
http://localhost:<GATEWAY_PORT>/auth/register
Gateway port by default is 8080
Request Body:
{
"username": "testuser",
"email": "testuser@example.com",
"password": "securePassword123"
}
Response Body:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
Example: Add a Transaction POST /transactions
📍 URL via gateway:
http://localhost:<GATEWAY_PORT>/transactions
Gateway port by default is 8080 Headers:
Authorization: Bearer <your_token>
Request Body:
{
"type": "INCOME",
"amount": 1500.00,
"description": "Salary"
}
Note
New features soon
-
GitHub Repository:
- Provide clear and beginner-friendly documentation (installation, usage, environment setup)
- Add architecture diagram and service overview
- Simplify project startup with improved docker-compose automation
-
Development Goals:
- Refactor .env variables, remove redundant
- Implement centralized logging (e.g., ELK stack or simple logger config)
- Add rate limiting and request validation in API Gateway
- Implement role-based access control (RBAC)
- Add email verification and password reset flow in Auth Service
-
Discovery Service
- Initialize service with Spring Cloud Netflix Eureka
- Configure application.yml
- Update docker-compose.yml to include the discovery-service with port mapping.
- Configure application.yml in each service to point to http://discovery-service:8761/eureka/ as the defaultZone.
- Verify that all services register with Eureka and that API calls work through the gateway.
-
API Gateway
- Initialize Spring Cloud Gateway
- Configure basic routes to
auth-serviceandtransaction-service - Implement
JWTvalidation inAPI Gateway - Extract
userIdfrom token and forward to services viaheaders - Add
CORSconfiguration for frontend
-
Auth Service
- Entity & Database: create
Userentity and setup PostgreSQL tableuserswith (id, username, email, password, role) - Security: Configure security, implement JWT token generation and validation
- Service: Implement
AuthServicewithregistrationandlogin - Controller: Implement
AuthControllerwithregistrationandloginendpoints
- Entity & Database: create
-
Transaction Service
- Entity & Database: create
Transactionentity and configure PostgreSQL connection - Service & Repository: implement
TransactionServiceandTransactionRepositoryfor CRUD operations - Controller: implement
TransactionController - Validation & Error Handling: Implement data validation and global error handling
- Documentation: Integrate Swagger/OpenAPI for API documentation
- Testing: Write unit and integration tests
- Entity & Database: create