Console-based ATM simulator with authentication, balance inquiry, withdrawals, deposits, and transfers. Academic project for the Diseño de Interfaces course.
| Layer | Technology |
|---|---|
| Language | Java 26 |
| Database | SQLite (JDBC) |
| Auth | PIN hashing with SHA-256 + salt |
| IDE | IntelliJ IDEA |
- JDK >= 26
- sqlite-jdbc driver JAR in classpath
# 1. Clone the repository
git clone <repo-url>
cd cajero
# 2. Compile
javac -cp ".:path/to/sqlite-jdbc.jar" -d out src/**/*.java
# 3. Run
java -cp "out:path/to/sqlite-jdbc.jar" MainOr open the project folder in IntelliJ IDEA — add sqlite-jdbc.jar to the project dependencies and run Main.java.
The database file banco.db is created automatically in the working directory on first run.
| Field | Value |
|---|---|
| User ID | 111111111 |
| Name | Juan Perez |
| PIN | 1234 |
| Account Number | 999999999 |
| Initial Balance | 5,420 CUP |
src/
├── Main.java # Entry point
├── dao/
│ ├── DatabaseManager.java # SQLite connection & schema init
│ ├── UsuarioDAO.java # Users CRUD
│ ├── CuentaDAO.java # Accounts CRUD
│ └── TransaccionDAO.java # Transactions CRUD
├── model/
│ ├── Usuario.java # User entity
│ ├── Cuenta.java # Account entity
│ └── Transaccion.java # Transaction entity (enum Tipo)
├── service/
│ ├── AuthService.java # Login, PIN validation
│ ├── CuentaService.java # Balance, history
│ └── TransaccionService.java # Withdraw, deposit, transfer
├── ui/
│ └── Menu.java # Console UI (menus, prompts)
└── util/
├── Formatter.java # Currency & date formatting
├── InputHelper.java # User input (Scanner + Console)
└── PinHasher.java # SHA-256 PIN hashing
Main
└── Menu (UI)
└── Services (business logic)
└── DAOs (data access)
└── DatabaseManager (SQLite)
- model/ — Plain entities (Usuario, Cuenta, Transaccion)
- dao/ — Data access layer with raw SQL via JDBC
- service/ — Business logic orchestration
- ui/ — Console interface (Menu)
- util/ — Helpers (hashing, formatting, input)
| Feature | Description |
|---|---|
| Login | Authenticate with numeric ID + 4-digit PIN (3 attempts max) |
| Balance Inquiry | Display current balance in CUP |
| Withdrawal | Predefined amounts (5–2,000 CUP) or custom amount |
| Deposit | Add funds to the account |
| Transfer | Send money to another account with atomic commit/rollback |
| Transaction History | Last 10 movements with type, amount (+/-), and date |
- Login attempts: after 3 failed PIN attempts, the session is blocked (program restarts).
- PIN security: PINs are hashed with SHA-256 + salt (
CAJERO_APP_2025_). Never stored in plain text. - Positive amounts: withdrawals, deposits, and transfers require a positive amount.
- Sufficient balance: transfers and withdrawals check that the source account has enough funds.
- Transfer atomicity: transfers use SQL transactions (
setAutoCommit(false)+commit/rollback) — both debit and credit execute or neither does. - Target validation: the destination account must exist; the recipient's name is shown for confirmation before executing.
- History scope: only the last 10 transactions for the authenticated account are shown.
CREATE TABLE usuarios (
id TEXT PRIMARY KEY,
nombre TEXT NOT NULL,
pin_hash TEXT NOT NULL,
created_at TEXT DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE cuentas (
numero TEXT PRIMARY KEY,
usuario_id TEXT NOT NULL,
saldo REAL DEFAULT 0.0,
created_at TEXT DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (usuario_id) REFERENCES usuarios(id)
);
CREATE TABLE transacciones (
id INTEGER PRIMARY KEY AUTOINCREMENT,
cuenta_origen TEXT NOT NULL,
tipo TEXT NOT NULL CHECK(tipo IN ('RETIRO','DEPOSITO','TRANSFERENCIA')),
monto REAL NOT NULL,
cuenta_destino TEXT,
descripcion TEXT,
fecha TEXT DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (cuenta_origen) REFERENCES cuentas(numero)
);