Simple banking system project developed in Java for the Distributed Systems course. The system allows for balance inquiries and transfers between accounts concurrently, ensuring that data remains consistent at all times, even in the event of node failures.
Develop a functional system where multiple users can operate on a shared database of 820,000 accounts. The project focuses on maintaining balance integrity through a replication model, allowing the system to keep operating even if some nodes are turned off, and ensuring information recovery using cloud storage.
- Distributed Model: The system functions with a leader node that coordinates operations and replica nodes that maintain a synchronized copy of the data.
- Fault Tolerance: If a replica fails, the system continues to function. Upon turning back on, the replica automatically synchronizes with the leader from the point where it left off.
- Cloud Backup: Every transaction is registered in Google Cloud Storage. If the entire system fails and in-memory information is lost, the leader can reconstruct the entire state of the bank by reading these logs.
- Concurrency Handling: Data access control was implemented so that, when processing many transfers at the same time, the total balance always matches and no money is lost.
- Monitoring Dashboard: Includes a simple web page to visualize in real-time the status of each node, their CPU/RAM usage, and how many transactions have been saved to the cloud.
For this project, I used Google Cloud Platform tools and standard Java technologies:
- Infrastructure: i deployed the system on Google Compute Engine virtual machines (
e2-standard-4instances for the leader ande2-standard-2for the replicas). - Development: The backend was programmed in Java using
com.sun.net.httpserverto handle HTTP requests in a lightweight manner. - Project Management: All code and dependencies were organized using Apache Maven.
- Storage: I used Google Cloud Storage to save transaction logs as JSON files, taking advantage of its REST API.
- Security: I implemented basic authentication using JSON Web Tokens (JWT) to protect the endpoints where transfers are made.
- Networking: I configured firewall rules in the Google Cloud VPC to allow secure communication between nodes.
The code is organized to separate the banking logic from the communication and backup components:
/
├── src/main/java/com/escom/banco/
│ ├── account/ # Basic account logic and balance management
│ ├── log/ # Code for saving and reading files in Google Cloud Storage
│ ├── server/ # Controllers for endpoints (Auth, Transactions, Status)
│ ├── sync/ # Code to keep replicas synchronized with the leader
│ ├── user/ # User management and access
│ └── util/ # Auxiliary functions for JWT and security
├── .mvn/ # Maven configuration
├── pom.xml # Project dependencies
└── .gitignore # Files ignored by Git (logs, credentials, compiled files)
- JDK 21 or higher.
- Apache Maven.
- A bucket configured in Google Cloud Storage.
- Google Cloud service account credentials file (
credentials.json) for the bucket connection.
Abre tu terminal y ejecuta:
git clone [https://github.com/AlejandroHZ-sys/mini-banco.git](https://github.com/AlejandroHZ-sys/mini-banco.git)
cd mini-banco
## 2. Compilation
To compile the project:
```bash
mvn clean package -DskipTestsTo start the Leader Node:
mvn exec:java -Dexec.args="LEADER 8080"To start a Replica Node:
mvn exec:java -Dexec.args="REPLICA 8080 http://<LEADER_IP>:8080"- Security: The project includes a
.gitignoreto avoid accidentally uploading Google Cloud credentials or temporary files. - Deployment: The configuration is standard and can be adapted to other virtual machines by adjusting the IP addresses in the network configuration.