Skip to content

About

A console-based banking system in C with authentication, file persistence, transfers, transaction history, automated testing, and GitHub Actions CI.

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

82 Commits

Folders and files

Repository files navigation

🏦 Banking System in C

C CI License: MIT Language: C

A console-based banking system written in C that demonstrates account management, authentication, file-based persistence, transfers, and transaction history β€” without an external database.

πŸŽ“ Learning project: built to practice C programming, structs, file I/O, functions, input validation, error handling, and basic application architecture.

⚠️ Important: this is an educational simulation, not production banking software. Do not use real credentials, personal financial data, or real money.

✨ Features

  • πŸ‘€ Create bank accounts with year-based IDs (2026/1, 2026/2, 2026/3, ...)
  • πŸ–₯️ Styled terminal interface with reusable ANSI color helpers and NO_COLOR support
  • πŸ“Š Customer dashboard with account summary and the five most recent transactions
  • πŸ”‘ Change PIN from the authenticated account menu
  • 🚦 Limit each login session to three authentication attempts
  • πŸ” PIN-protected login with 4-digit validation
  • πŸ’° Deposit and withdraw money
  • πŸ”„ Transfer money between accounts
  • πŸ“Š Check account balance
  • 🧾 View timestamped transaction history
  • πŸ“‹ List active demo accounts
  • πŸ—‘οΈ Delete accounts only after the balance reaches zero
  • πŸ’Ύ Persistent storage using binary files
  • πŸ›‘οΈ Defensive input validation and file-write checks
  • 🧰 Simple Makefile build and test workflow
  • πŸ€– GitHub Actions CI for automated build and smoke testing
  • πŸ–₯️ Runs on Linux, macOS, and Windows with a compatible C11 toolchain

πŸš€ Quick Start

Requirements

  • GCC or another C11-compatible compiler
  • Make (recommended)

Build

make

Or compile directly:

gcc -Wall -Wextra -Wpedantic -std=c11 -O2 -o banking_system banking_system.c

Run

Linux/macOS/WSL:

./banking_system

Windows (MinGW):

banking_system.exe

πŸ”§ Development Workflow

Use the following commands during development:

make          # build the application
make test     # run the smoke/regression tests
make sanitize # build with sanitizers
make verify   # run the complete local verification workflow

The repository also runs automated checks through GitHub Actions on pushes and pull requests.

πŸ§ͺ Test

The project uses a small regression/smoke suite to catch common failures in account creation, startup, invalid input, and transfer behavior.

What is checked

  • Successful compilation with the configured C11 flags
  • Account creation and persisted runtime data
  • Clean program startup and exit
  • Invalid input handling
  • Self-transfer rejection
  • Temporary test-data cleanup

πŸ› οΈ Troubleshooting

make is not recognized

Install a C toolchain and Make. On Windows, MinGW/MSYS2 or another GCC-compatible environment can provide both.

Compiler not found

Check that GCC is available in your terminal:

gcc --version

If the command is unavailable, install GCC and add it to your system PATH.

Tests leave runtime files behind

The application normally creates accounts.dat and transactions.dat in the working directory. The automated smoke test uses temporary test data and cleans it up when it finishes.

If you want to reset a local demo manually, first make sure the program is not running, then remove the generated runtime files:

Linux/macOS/WSL:

rm -f accounts.dat transactions.dat

Windows PowerShell:

Remove-Item accounts.dat, transactions.dat -ErrorAction SilentlyContinue

These files contain local demo data and should remain untracked; do not commit them to the repository.

Sanitizer build is unavailable

make sanitize depends on compiler sanitizer support. If your toolchain does not provide AddressSanitizer, use make test and the normal make build, then report the toolchain details when opening an issue.

πŸ–₯️ Example

================ BANKING SYSTEM ================
1. Create Account
2. Login
3. List All Accounts (demo)
4. Exit
==================================================
Choose an option: 1

=== Create New Account ===
Enter full name: Alex Kumar
Set a 4-digit PIN: 1234
Enter initial deposit amount: 5000

Account created successfully!
Your account number is: 2026/1

Account IDs use a readable YYYY/N format. New accounts in the current configured account year start at 2026/1 and continue sequentially (2026/2, 2026/3, ...). The sequence is persisted with the account data, so deleted accounts do not cause an existing ID to be reused. For example, if 2026/1 and 2026/2 already exist and 2026/1 is deleted, the next new account remains 2026/3, not 2026/1. After login, users can check their balance, deposit, withdraw, transfer funds, review transactions, or delete an account after its balance reaches zero.

🧭 Typical Usage Flow

  1. Create an account and note the generated YYYY/N account number.
  2. Log in with the account number and 4-digit PIN.
  3. Use deposits, withdrawals, transfers, and transaction history from the account menu.
  4. Keep the account balance at zero before deleting the account.

This flow is intended for local learning and testing; runtime data stays in the ignored accounts.dat and transactions.dat files.

🧠 What This Project Demonstrates

This project is useful for students learning C because it combines several concepts in one application:

  • struct-based data modeling
  • Functions and modular program flow
  • Binary file read/write operations
  • Account lookup and record updates
  • Year-based sequential account ID generation (YYYY/N)
  • Transaction logging
  • Basic authentication
  • Robust line-based input parsing
  • Persistent local application state
  • Make-based compilation and testing
  • Continuous integration with GitHub Actions

🧩 Architecture Overview

The application follows a simple file-backed design:

User Input β†’ Menu/Validation β†’ Account Operations β†’ File Storage
                              ↓
                       Transaction Logging

Core responsibilities are kept in banking_system.c, while the tests/ directory contains regression checks and .github/workflows/ runs the automated CI workflow.

πŸ“ Project Structure

.
β”œβ”€β”€ .github/
β”‚   β”œβ”€β”€ ISSUE_TEMPLATE/
β”‚   β”‚   β”œβ”€β”€ bug_report.md
β”‚   β”‚   └── feature_request.md
β”‚   └── workflows/
β”‚       └── ci.yml
β”œβ”€β”€ tests/
β”‚   └── smoke_test.sh
β”œβ”€β”€ banking_system.c
β”œβ”€β”€ ui.h
β”œβ”€β”€ Makefile
β”œβ”€β”€ LICENSE
β”œβ”€β”€ CONTRIBUTING.md
β”œβ”€β”€ SECURITY.md
β”œβ”€β”€ README.md
└── .gitignore

accounts.dat and transactions.dat are generated locally at runtime and are intentionally excluded from Git.

⚠️ Security & Limitations

This is an educational project, not production banking software.

The current implementation intentionally keeps the design simple. In particular:

  • PINs are stored as plaintext in the local binary account file.
  • Account and transaction files are not encrypted at rest.
  • The three-attempt login limit applies only to one login session; it is not persistent rate limiting or a production-grade lockout.
  • PINs remain stored in plaintext in the local binary account file.
  • The demo account directory displays account data and should not be treated as a real bank interface.
  • File operations are designed for a simple local application, not concurrent users.
  • There is no real bank/payment integration.

See SECURITY.md for the project's security notes and responsible-reporting guidance.

πŸ—ΊοΈ Roadmap

Potential next improvements:

  • Hash PINs with a vetted password-hashing library
  • Replace floating-point money with integer cents
  • Add comprehensive automated unit/integration tests
  • Make transfers fully atomic with stronger storage guarantees
  • Add account statements/export
  • Add a styled terminal UI and customer dashboard
  • Add customer PIN change and a three-attempt login limit
  • Add account statements/export
  • Add transaction filtering by date and type
  • Add login retry limits and lockout
  • Improve cross-platform tooling
  • Make the account year configurable instead of compile-time configured
  • Add a database-backed version for comparison

🀝 Contributing

Contributions are welcome β€” especially improvements that make the project safer, easier to understand, or more useful for C learners.

Before opening a pull request

  1. Build the project with make.
  2. Run make test to execute the regression checks.
  3. Run make verify when changing core behavior.
  4. Keep generated runtime files such as accounts.dat and transactions.dat out of commits.
  5. Explain the behavior change and testing performed in the pull request description.

See CONTRIBUTING.md for development guidelines. Bug reports and feature ideas can also use the repository's issue templates.

⭐ Support the Project

If this project helped you learn C, file handling, or application design, consider starring the repository. A genuine star helps other learners discover the project.

Issues, pull requests, documentation improvements, and constructive feedback are also welcome.

πŸ“„ License

Released under the MIT License. See LICENSE for details.

πŸ‘¨β€πŸ’» Author

Prabhjot Singh Gill

GitHub: @prabhtheone


Keywords

c c-programming c11 banking-system banking finance console-application file-handling file-io binary-files authentication transaction-history makefile github-actions smoke-test beginner-project student-project learning-c systems-programming

About

A console-based banking system in C with authentication, file persistence, transfers, transaction history, automated testing, and GitHub Actions CI.

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages