{"id":25549790,"url":"https://github.com/stormdotcom/banking_system","last_synced_at":"2026-01-24T06:46:28.096Z","repository":{"id":272118387,"uuid":"915583129","full_name":"stormdotcom/banking_system","owner":"stormdotcom","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-12T08:48:55.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-30T17:48:52.640Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stormdotcom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-12T08:48:14.000Z","updated_at":"2025-01-12T08:48:58.000Z","dependencies_parsed_at":"2025-01-12T09:31:22.473Z","dependency_job_id":"84fd420f-217d-4c80-9b66-3ff1d254968f","html_url":"https://github.com/stormdotcom/banking_system","commit_stats":null,"previous_names":["stormdotcom/banking_system"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stormdotcom/banking_system","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stormdotcom%2Fbanking_system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stormdotcom%2Fbanking_system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stormdotcom%2Fbanking_system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stormdotcom%2Fbanking_system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stormdotcom","download_url":"https://codeload.github.com/stormdotcom/banking_system/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stormdotcom%2Fbanking_system/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28717321,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T05:53:42.649Z","status":"ssl_error","status_checked_at":"2026-01-24T05:53:41.698Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-20T10:20:19.443Z","updated_at":"2026-01-24T06:46:28.081Z","avatar_url":"https://github.com/stormdotcom.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# 🏦 Banking System Design with SQL and Apache Kafka\n\n## **1. System Architecture Overview**\n\n### **Components**\n\n1. **API Gateway** – Handles client requests (REST/GraphQL)  \n2. **Authentication Service** – User authentication and authorization  \n3. **Core Banking Service** – Account management and transaction handling  \n4. **Kafka Event Bus** – Asynchronous communication between services  \n5. **Transaction Service** – Manages fund transfers (ACID compliant)  \n6. **SQL Database** – PostgreSQL/MySQL for high consistency  \n7. **Audit \u0026 Notification Service** – Logs and user notifications  \n\n### **Architecture Flow**\n\n```\nClient → API Gateway → Core Banking Service → SQL DB\n                                   ↓\n                             Kafka Broker\n                                   ↓\n      Transaction Service → SQL DB → Audit/Notification Service\n```\n\n---\n\n## **2. Technology Stack**\n\n- **Backend:** Node.js / .NET Core (C#)  \n- **Database:** PostgreSQL (ACID-compliant, high consistency)  \n- **Message Broker:** Apache Kafka  \n- **Containerization:** Docker \u0026 Kubernetes  \n- **Authentication:** OAuth 2.0 / JWT  \n- **Monitoring:** Prometheus \u0026 Grafana  \n\n---\n\n## **3. Database Schema (SQL)**\n\n```sql\n-- Users Table\nCREATE TABLE users (\n    user_id SERIAL PRIMARY KEY,\n    username VARCHAR(50) UNIQUE NOT NULL,\n    password_hash VARCHAR(255) NOT NULL,\n    created_at TIMESTAMP DEFAULT NOW()\n);\n\n-- Accounts Table\nCREATE TABLE accounts (\n    account_id SERIAL PRIMARY KEY,\n    user_id INT REFERENCES users(user_id),\n    balance DECIMAL(15, 2) DEFAULT 0.00,\n    created_at TIMESTAMP DEFAULT NOW()\n);\n\n-- Transactions Table\nCREATE TABLE transactions (\n    transaction_id SERIAL PRIMARY KEY,\n    from_account INT REFERENCES accounts(account_id),\n    to_account INT REFERENCES accounts(account_id),\n    amount DECIMAL(15, 2) NOT NULL,\n    status VARCHAR(20) DEFAULT 'PENDING',\n    created_at TIMESTAMP DEFAULT NOW()\n);\n\n-- Audit Logs Table\nCREATE TABLE audit_logs (\n    log_id SERIAL PRIMARY KEY,\n    event_type VARCHAR(50),\n    details JSONB,\n    created_at TIMESTAMP DEFAULT NOW()\n);\n```\n\n---\n\n## **4. Kafka Topics Design**\n\n1. **`transaction_initiated`** – When a transaction starts  \n2. **`transaction_completed`** – When a transaction succeeds  \n3. **`transaction_failed`** – When a transaction fails  \n4. **`audit_log`** – Logs important system events  \n\n---\n\n## **5. Core Logic Implementation**\n\n### **Producer (Node.js) - Initiate Transaction**\n\n```javascript\nconst { Kafka } = require('kafkajs');\nconst kafka = new Kafka({ clientId: 'banking-app', brokers: ['localhost:9092'] });\nconst producer = kafka.producer();\n\nasync function initiateTransaction(fromAccount, toAccount, amount) {\n    await producer.connect();\n    await producer.send({\n        topic: 'transaction_initiated',\n        messages: [{ value: JSON.stringify({ fromAccount, toAccount, amount }) }],\n    });\n    await producer.disconnect();\n}\n```\n\n---\n\n### **Consumer (Transaction Service)**\n\n```javascript\nconst consumer = kafka.consumer({ groupId: 'transaction-service' });\n\nasync function processTransactions() {\n    await consumer.connect();\n    await consumer.subscribe({ topic: 'transaction_initiated' });\n\n    await consumer.run({\n        eachMessage: async ({ message }) =\u003e {\n            const { fromAccount, toAccount, amount } = JSON.parse(message.value);\n\n            try {\n                await db.transaction(async (trx) =\u003e {\n                    const sender = await trx('accounts').where('account_id', fromAccount).first();\n                    if (sender.balance \u003c amount) throw new Error('Insufficient funds');\n\n                    await trx('accounts')\n                        .where('account_id', fromAccount)\n                        .decrement('balance', amount);\n\n                    await trx('accounts')\n                        .where('account_id', toAccount)\n                        .increment('balance', amount);\n\n                    await producer.send({\n                        topic: 'transaction_completed',\n                        messages: [{ value: JSON.stringify({ fromAccount, toAccount, amount }) }],\n                    });\n                });\n            } catch (err) {\n                await producer.send({\n                    topic: 'transaction_failed',\n                    messages: [{ value: JSON.stringify({ fromAccount, toAccount, amount, reason: err.message }) }],\n                });\n            }\n        },\n    });\n}\n```\n\n---\n\n## **6. Consistency \u0026 ACID Guarantee**\n\n- **ACID Transactions:** PostgreSQL ensures atomicity, consistency, isolation, and durability.  \n- **Exactly-Once Processing:** Kafka ensures no duplication using **idempotent producers**.  \n- **Error Handling:** Failed transactions are logged and retried.\n\n---\n\n## **7. High Availability \u0026 Fault Tolerance**\n\n- **Kafka Cluster:** Multi-node Kafka cluster for redundancy  \n- **Database Replication:** PostgreSQL replication for disaster recovery  \n- **Circuit Breaker:** Graceful failure handling between services  \n- **Retry Mechanism:** Kafka handles message retries\n\n---\n\n## **8. Deployment with Docker**\n\n### **Docker Compose**\n\n```yaml\nversion: '3'\nservices:\n  postgres:\n    image: postgres\n    environment:\n      POSTGRES_USER: bankuser\n      POSTGRES_PASSWORD: bankpass\n      POSTGRES_DB: banking\n    ports:\n      - \"5432:5432\"\n\n  kafka:\n    image: wurstmeister/kafka\n    ports:\n      - \"9092:9092\"\n    environment:\n      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181\n\n  zookeeper:\n    image: wurstmeister/zookeeper\n    ports:\n      - \"2181:2181\"\n```\n\n---\n\n## **9. Monitoring \u0026 Logging**\n\n- **Kafka Monitoring:** Kafka Manager, Burrow  \n- **Database Monitoring:** PgAdmin, Prometheus  \n- **Logging:** Kafka `audit_log` topic, ELK Stack (Elasticsearch, Logstash, Kibana)  \n\n---\n\n## **10. Security Considerations**\n\n- **TLS Encryption** for Kafka communication  \n- **Role-Based Access Control (RBAC)** for API and DB  \n- **Input Validation** to prevent SQL injection  \n- **Audit Logs** for tracking sensitive operations  \n\n---\n\n## **Summary**\n\n- **Strong Consistency** through SQL ACID transactions  \n- **Real-Time Processing** with Kafka event-driven architecture  \n- **Scalable \u0026 Fault-Tolerant** deployment with Docker/Kubernetes  \n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstormdotcom%2Fbanking_system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstormdotcom%2Fbanking_system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstormdotcom%2Fbanking_system/lists"}