{"id":45886645,"url":"https://github.com/alphsx/banker-s-algorithmx","last_synced_at":"2026-02-27T16:04:02.856Z","repository":{"id":321624902,"uuid":"1085960185","full_name":"AlphsX/Banker-s-AlgorithmX","owner":"AlphsX","description":"🚀 The fast, visual way to learn and simulate Banker’s Algorithm","archived":false,"fork":false,"pushed_at":"2026-02-04T16:42:14.000Z","size":728,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-05T02:29:37.415Z","etag":null,"topics":["bankers-algorithm","bankers-algorithm-simulator","deadlock-avoidance","operating-systems","resource-allocation"],"latest_commit_sha":null,"homepage":"https://accio-labs.vercel.app","language":"TypeScript","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/AlphsX.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-29T18:42:46.000Z","updated_at":"2026-02-04T16:37:06.000Z","dependencies_parsed_at":"2025-10-30T17:39:01.472Z","dependency_job_id":null,"html_url":"https://github.com/AlphsX/Banker-s-AlgorithmX","commit_stats":null,"previous_names":["alphsx/banker-s-algorithmx"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/AlphsX/Banker-s-AlgorithmX","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlphsX%2FBanker-s-AlgorithmX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlphsX%2FBanker-s-AlgorithmX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlphsX%2FBanker-s-AlgorithmX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlphsX%2FBanker-s-AlgorithmX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlphsX","download_url":"https://codeload.github.com/AlphsX/Banker-s-AlgorithmX/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlphsX%2FBanker-s-AlgorithmX/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29903617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T14:46:13.553Z","status":"ssl_error","status_checked_at":"2026-02-27T14:46:10.522Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["bankers-algorithm","bankers-algorithm-simulator","deadlock-avoidance","operating-systems","resource-allocation"],"created_at":"2026-02-27T16:04:01.286Z","updated_at":"2026-02-27T16:04:02.850Z","avatar_url":"https://github.com/AlphsX.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable MD033 MD041 MD013 --\u003e\n\u003cdiv align=\"center\"\u003e\n\n# Banker's Algorithm Simulator ✨\n\n**The interactive, production-ready implementation of Dijkstra's deadlock avoidance algorithm.**\n\nBuilt with modern web technologies for educational and research purposes\n\n[![Next.js](https://img.shields.io/badge/Next.js-16+-black?logo=next.js\u0026logoColor=white)](https://nextjs.org)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5+-blue?logo=typescript\u0026logoColor=white)](https://www.typescriptlang.org)\n[![React](https://img.shields.io/badge/React-19.1-61DAFB?logo=react\u0026logoColor=white)](https://reactjs.org)\n[![Tailwind CSS](https://img.shields.io/badge/Tailwind_CSS-3.4+-38B2AC?logo=tailwind-css\u0026logoColor=white)](https://tailwindcss.com)\n[![Jest](https://img.shields.io/badge/Jest-30+-C21325?logo=jest\u0026logoColor=white)](https://jestjs.io)\n[![Framer Motion](https://img.shields.io/badge/Framer_Motion-12+-FF0055?logo=framer\u0026logoColor=white)](https://www.framer.com/motion/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n\u003c/div\u003e\n\n---\n\n\u003e **Note**\n\u003e\n\u003e **Production-Ready Banker's Algorithm Implementation**\n\u003e\n\u003e This is a comprehensive, interactive implementation of Dijkstra's Banker's Algorithm for deadlock avoidance in operating systems. Built with modern web technologies, it provides real-time visualization, step-by-step algorithm execution, and comprehensive testing capabilities.\n\u003e\n\u003e **Perfect for:** Computer Science education, operating systems courses, research demonstrations, and understanding resource allocation in concurrent systems.\n\n---\n\n**The Banker's Algorithm Simulator provides the fastest path from theory to practical understanding**, offering interactive visualization, real-time safety checking, and comprehensive algorithm analysis.\n\nThe [Banker's Algorithm](https://en.wikipedia.org/wiki/Banker%27s_algorithm) is a resource allocation and deadlock avoidance algorithm developed by Edsger Dijkstra. This simulator makes understanding and experimenting with the algorithm straightforward, with real-time visualization, step-by-step execution, and comprehensive validation.\n\n```typescript\n// Core algorithm implementation\nconst calculator = new BankersAlgorithmCalculator();\nconst safetyResult = calculator.checkSafety(available, allocation, need);\n\nif (safetyResult.isSafe) {\n  console.log(`Safe sequence: ${safetyResult.safeSequence.join(\" → \")}`);\n} else {\n  console.log(\"System is in unsafe state - potential deadlock!\");\n}\n```\n\n## 📋 Table of Contents\n\n- [What is the Banker's Algorithm?](#what-is-the-bankers-algorithm)\n- [Why This Implementation?](#why-this-implementation)\n- [Features](#features)\n- [Quick Start](#quick-start)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Core Components](#core-components)\n- [Algorithm Implementation](#algorithm-implementation)\n- [Keyboard Shortcuts](#keyboard-shortcuts)\n- [Testing](#testing)\n- [Architecture](#architecture)\n- [Deployment](#deployment)\n- [Contributing](#contributing)\n- [Developer Information](#developer-information)\n\n## What is the Banker's Algorithm?\n\nThe Banker's Algorithm is a deadlock avoidance algorithm used in operating systems to ensure that resource allocation never leads to a deadlock state. Developed by **Edsger Dijkstra** in 1965, it works by:\n\n- **Resource Allocation**: Managing finite resources among multiple processes\n- **Safety Checking**: Ensuring the system can always find a safe execution sequence\n- **Request Processing**: Evaluating resource requests before granting them\n- **Deadlock Prevention**: Avoiding states that could lead to circular waiting\n\nThe algorithm simulates a banker who lends money (resources) to customers (processes) while ensuring they can always collect all loans back.\n\n### Key Concepts\n\n- **Safe State**: A state where there exists at least one sequence of process execution that allows all processes to complete\n- **Unsafe State**: A state that may lead to deadlock (but does not guarantee it)\n- **Need Matrix**: `Need[i][j] = Max[i][j] - Allocation[i][j]` - remaining resource requirements\n- **Safe Sequence**: An ordering of processes that can all complete without deadlock\n\n## Why This Implementation?\n\nThis simulator handles all the complex algorithmic details while providing an intuitive interface for learning and experimentation.\n\n🚀 **Interactive**: Real-time visualization with step-by-step algorithm execution  \n🎓 **Educational**: Perfect for computer science courses and self-learning  \n🔍 **Comprehensive**: Complete implementation with validation and error handling  \n🧪 **Tested**: 31+ test cases covering edge cases and classical examples  \n💻 **Modern**: Built with Next.js 16, TypeScript 5, and React 19  \n📱 **Responsive**: Works seamlessly on desktop, tablet, and mobile devices  \n🎨 **Beautiful UI**: Dark/light mode with smooth animations using Framer Motion  \n⌨️ **Keyboard Shortcuts**: Efficient navigation and control for power users\n\n## Features\n\n### Core Algorithm Implementation\n\n- **Safety Algorithm**: Complete implementation of Dijkstra's safety checking algorithm\n- **Resource Request Processing**: Handles resource allocation requests with full validation\n- **Step-by-Step Visualization**: Shows each algorithm step with detailed explanations\n- **Multiple System States**: Support for 1-10 processes and 1-10 resource types\n- **Process Completion**: Simulate processes finishing and releasing resources\n- **System Validation**: Comprehensive validation of all system constraints\n\n### Interactive Interface\n\n- 🎯 **Real-time Matrix Editing**: Modify allocation, maximum, and available resources\n- 🔄 **Dynamic System Sizing**: Adjust number of processes and resources on the fly\n- 📊 **Request Simulation**: Submit resource requests and see immediate results\n- 🎨 **Visual Feedback**: Color-coded results and animated state transitions\n- 📱 **Touch-Friendly**: Optimized for mobile with swipe gestures\n- 🌓 **Dark/Light Mode**: Automatic theme switching with system preference detection\n\n### Educational Tools\n\n- 📖 **Algorithm Steps**: Detailed breakdown of each algorithm iteration\n- 🔢 **Step Numbering**: Clear step numbers (1-4) matching textbook algorithms\n- ✅ **Safety Sequence Display**: Clear visualization of safe execution order\n- ❌ **Error Explanations**: Comprehensive error messages for invalid states\n- 📚 **Classical Examples**: preloaded textbook examples for learning\n- 🎓 **Detailed Documentation**: Complete algorithm explanation in this readme\n\n### Advanced Features\n\n- ⌨️ **Keyboard Shortcuts**: Efficient navigation (Cmd/Ctrl+[, Cmd/Ctrl+D, Shift+Enter)\n- 🔔 **Toast Notifications**: Beautiful animated notifications for all actions\n- 💾 **State Persistence**: Maintains system state during navigation\n- 🎭 **Animated UI**: Smooth transitions using Framer Motion\n- 🧪 **Comprehensive Testing**: 31+ test cases with 100% coverage of core logic\n- 📊 **System Statistics**: Track resource utilization and process completion\n\n## Quick Start\n\n### Prerequisites\n\n- Bun 1.0+ (Node.js compatible)\n- Modern web browser (Chrome, Firefox, Safari, Edge)\n\n### Installation\n\n```bash\n# Clone the repository\ngit clone https://github.com/AlphsX/Banker-s-AlgorithmX.git\ncd bankers-algorithm-simulator/frontend\n\n# Install dependencies\nbun install\n\n# Start development server\nbun run dev\n```\n\nOpen [http://localhost:3000](http://localhost:3000) in your browser.\n\n### First Steps\n\n1. **Explore Default Example**: The app loads with a safe system state\n2. **Check Safety**: Click \"Check Safety\" or press `Shift+Enter`\n3. **Modify Values**: Click any cell in the matrices to edit\n4. **Submit Request**: Use the request panel to test resource allocation\n5. **View Steps**: Scroll down to see detailed algorithm execution\n\n## Usage\n\n### Basic Configuration\n\nThe system starts with a default safe state:\n\n```typescript\n// Default configuration (2 processes, 3 resources)\nProcesses: 2 (P0, P1)\nResources: 3 (A, B, C)\n\nAllocation Matrix:\nP0: [1, 0, 0]  // P0 currently has: A=1, B=0, C=0\nP1: [0, 1, 0]  // P1 currently has: A=0, B=1, C=0\n\nMax Matrix:\nP0: [2, 1, 1]  // P0 maximum needs: A=2, B=1, C=1\nP1: [1, 2, 1]  // P1 maximum needs: A=1, B=2, C=1\n\nAvailable: [2, 2, 3]  // Available resources: A=2, B=2, C=3\n\nNeed Matrix (calculated automatically):\nP0: [1, 1, 1]  // [2,1,1] - [1,0,0] = [1,1,1]\nP1: [1, 1, 1]  // [1,2,1] - [0,1,0] = [1,1,1]\n```\n\n### Checking System Safety\n\nClick \"Check Safety\" or press `Shift+Enter` to run the safety algorithm:\n\n```text\nStep 1: Initialize Work = [2, 2, 3], Finish = [false, false]\nStep 2: Check P0: Need[P0] = [1,1,1] ≤ Work = [2,2,3] [PASS]\nStep 3: P0 finishes: Work = [2,2,3] + [1,0,0] = [3,2,3]\nStep 2: Check P1: Need[P1] = [1,1,1] ≤ Work = [3,2,3] [PASS]\nStep 3: P1 finishes: Work = [3,2,3] + [0,1,0] = [3,3,3]\nStep 4: All processes finished [PASS] Safe Sequence: P0 → P1\n```\n\n### Submitting Resource Requests\n\n1. Select a process from the dropdown\n2. Enter requested resources for each type\n3. Click \"Submit Request\"\n4. View the detailed validation and safety check\n\nExample request:\n\n```typescript\nProcess: P0\nRequest: [1, 0, 0]  // P0 requests 1 unit of resource A\n\nValidation:\n[PASS] Step 1: Request ≤ Need ([1,0,0] ≤ [1,1,1])\n[PASS] Step 2: Request ≤ Available ([1,0,0] ≤ [2,2,3])\n[PASS] Step 3: Simulate allocation\n[PASS] Step 4: System remains safe → REQUEST GRANTED\n```\n\n### Adjusting System Size\n\nUse the controls in the sidebar to:\n\n- **Process Count**: 1-10 processes\n- **Resource Count**: 1-10 resource types\n- **Available Resources**: Set available units for each resource type\n\n### Resetting the System\n\n- **Reset Button**: Clears all values while preserving counts\n- **Logo Click**: Reloads the default safe example\n- **Keyboard**: Press `Cmd/Ctrl+N` to reset\n\n## Core Components\n\n### The `BankersAlgorithmCalculator`\n\nThe central class implementing Dijkstra's algorithm with comprehensive validation and step tracking.\n\n```typescript\nimport { BankersAlgorithmCalculator } from \"@/lib/bankers-algorithm-calculator\";\n\nconst calculator = new BankersAlgorithmCalculator();\n\n// Check system safety\nconst safetyResult = calculator.checkSafety(available, allocation, need);\n// Returns: { isSafe, safeSequence, steps, finalFinishState }\n\n// Process resource request\nconst requestResult = calculator.processRequest(request, currentState);\n// Returns: { canGrant, newState?, errorMessage?, simulationSteps? }\n\n// Validate system state\nconst errors = calculator.validateSystemState(state);\n// Returns: ValidationError[]\n\n// Complete a process (release resources)\nconst newState = calculator.completeProcess(state, processId);\n\n// Get system snapshot with statistics\nconst snapshot = calculator.getSystemSnapshot(state);\n```\n\n### Type Definitions\n\n```typescript\ninterface BankersAlgorithmState {\n  processCount: number;\n  resourceCount: number;\n  allocation: number[][];\n  max: number[][];\n  available: number[];\n  need: number[][];\n  finish: boolean[];\n  safeSequence: string[];\n  algorithmSteps: AlgorithmStep[];\n  isCalculating: boolean;\n  isSafe?: boolean;\n  lastUpdated?: Date;\n}\n\ninterface AlgorithmStep {\n  stepNumber: number | string;\n  description: string;\n  workVector: number[];\n  processChecked?: string;\n  canFinish?: boolean;\n  isHighlighted?: boolean;\n}\n\ninterface ResourceRequest {\n  processId: number;\n  requestVector: number[];\n}\n```\n\n### Matrix Utilities\n\nComprehensive utility functions for matrix operations:\n\n```typescript\nimport {\n  calculateNeedMatrix,\n  isVectorLessOrEqual,\n  addVectors,\n  cloneMatrix,\n  validateMatrixValues,\n  validateAllocationConstraints,\n} from \"@/utils/matrix-utils\";\n\n// Calculate Need = Max - Allocation\nconst need = calculateNeedMatrix(max, allocation);\n\n// Check if vector a ≤ vector b (component-wise)\nconst canAllocate = isVectorLessOrEqual(request, available);\n\n// Add two vectors\nconst newWork = addVectors(work, allocation[i]);\n\n// Validate matrix constraints\nconst errors = validateAllocationConstraints(allocation, max);\n```\n\n## Algorithm Implementation\n\n### Safety Algorithm\n\nBased on Dijkstra's original algorithm with optimized implementation:\n\n```typescript\n/**\n * Safety Algorithm Steps:\n * 1. Initialize Work = Available and Finish[i] = false for all processes\n * 2. Find process Pi where Finish[i] = false and Need[i] ≤ Work\n * 3. If found: Work = Work + Allocation[i], Finish[i] = true, repeat step 2\n * 4. If all Finish[i] = true, system is safe; otherwise unsafe\n */\ncheckSafety(available: number[], allocation: number[][], need: number[][]): SafetyResult\n```\n\n**Implementation Details:**\n\n- Uses work vector to simulate available resources\n- Iterates through processes to find those that can complete\n- Simulates resource release when process completes\n- Tracks detailed steps for educational visualization\n- Returns safe sequence if system is safe\n\n### Resource Request Algorithm\n\nComprehensive request processing with safety verification:\n\n```typescript\n/**\n * Resource Request Steps:\n * 1. Check if Request[i] ≤ Need[i] (does not exceed declared maximum)\n * 2. Check if Request[i] ≤ Available (resources are available)\n * 3. Temporarily allocate resources and check if resulting state is safe\n * 4. If safe, grant request; otherwise, deny and rollback\n */\nprocessRequest(request: ResourceRequest, currentState: BankersAlgorithmState): RequestResult\n```\n\n**Implementation Details:**\n\n- Validates request against declared maximum needs\n- Checks resource availability\n- Simulates allocation without committing changes\n- Runs safety algorithm on simulated state\n- Commits changes only if safe, otherwise rolls back\n\n### Validation System\n\nComprehensive validation of all system constraints:\n\n```typescript\n// Validates entire system state\nvalidateSystemState(state: BankersAlgorithmState): ValidationError[]\n\n// Validates system data integrity\nvalidateSystemData(state: BankersAlgorithmState): ValidationError[]\n\n// Validates matrix values (non-negative integers)\nvalidateMatrixValues(matrix: number[][]): ValidationError[]\n\n// Validates allocation constraints (Allocation ≤ Max)\nvalidateAllocationConstraints(allocation: number[][], max: number[][]): ValidationError[]\n```\n\n## Keyboard Shortcuts\n\nPower user features for efficient navigation and control:\n\n| Shortcut        | Action         | Description                        |\n| --------------- | -------------- | ---------------------------------- |\n| `Cmd/Ctrl + [`  | Toggle Sidebar | Show/hide the control sidebar      |\n| `Cmd/Ctrl + D`  | Toggle Theme   | Switch between dark and light mode |\n| `Shift + Enter` | Check Safety   | Run the safety algorithm           |\n\n**Platform-specific:**\n\n- Mac: Use `Cmd` key\n- Windows/Linux: Use `Ctrl` key\n\n## Testing\n\nThe project includes comprehensive test coverage with 31+ test cases:\n\n```bash\n# Run all tests\nbun run test\n\n# Run tests with coverage\nbun run test:coverage\n\n# Run tests in watch mode\nbun run test:watch\n\n# Run specific test file\nbun run test -- --testPathPattern=bankers-algorithm\n```\n\n### Test Categories\n\n#### Safety Algorithm Tests (6 tests)\n\n- Classical textbook examples\n- Safe state identification\n- Unsafe state detection\n- Detailed step tracking\n\n#### Resource Request Tests (9 tests)\n\n- Request validation\n- Availability checking\n- Safety verification\n- Grant/deny logic\n\n#### Process Completion Tests (3 tests)\n\n- Resource release simulation\n- State updates\n- Completion validation\n\n#### System Validation Tests (4 tests)\n\n- Matrix dimension validation\n- Value range checking\n- Constraint validation\n- Error reporting\n\n#### Additional Tests (9 tests)\n\n- System snapshots and statistics\n- Algorithm step numbering\n- Safe sequence finding\n- Matrix resizing\n\n### Test Coverage\n\n```bash\nbun run test:coverage\n```\n\nExpected coverage:\n\n- Statements: \u003e95%\n- Branches: \u003e90%\n- Functions: \u003e95%\n- Lines: \u003e95%\n\n## Architecture\n\n### Project Structure\n\n```text\nbankers-algorithm-simulator/\n├── frontend/\n│   ├── src/\n│   │   ├── app/                          # Next.js app router\n│   │   │   ├── layout.tsx               # Root layout with theme provider\n│   │   │   ├── page.tsx                 # Main algorithm interface\n│   │   │   └── globals.css              # Global styles and CSS variables\n│   │   ├── components/\n│   │   │   ├── bankers-algorithm/       # Algorithm-specific components\n│   │   │   │   ├── AlgorithmTable.tsx   # Matrix display and editing\n│   │   │   │   ├── SystemControls.tsx   # Process/resource controls\n│   │   │   │   ├── StepByStepResults.tsx # Algorithm step visualization\n│   │   │   │   ├── RequestPanel.tsx     # Resource request interface\n│   │   │   │   ├── ProcessControl.tsx   # Process count control\n│   │   │   │   ├── ResourceControl.tsx  # Resource count control\n│   │   │   │   ├── AvailableResourcesInput.tsx\n│   │   │   │   └── AnimatedFinishBadge.tsx\n│   │   │   ├── ui/                      # Reusable UI components\n│   │   │   │   ├── toast.tsx            # Toast notification system\n│   │   │   │   ├── loading-screen.tsx   # Loading state\n│   │   │   │   └── browser-compatibility-warning.tsx\n│   │   │   └── magicui/                 # Enhanced UI components\n│   │   │       └── AnimatedThemeToggler.tsx\n│   │   ├── lib/                         # Core algorithm implementation\n│   │   │   ├── bankers-algorithm-calculator.ts  # Main algorithm\n│   │   │   └── __tests__/               # Test files\n│   │   │       └── bankers-algorithm-enhanced.test.ts\n│   │   ├── types/                       # TypeScript type definitions\n│   │   │   └── bankers-algorithm.ts     # Core types and interfaces\n│   │   ├── utils/                       # Utility functions\n│   │   │   └── matrix-utils.ts          # Matrix operations\n│   │   ├── hooks/                       # Custom React hooks\n│   │   │   ├── useDarkMode.ts           # Theme management\n│   │   │   ├── useKeyboardShortcuts.ts  # Keyboard shortcuts\n│   │   │   ├── useSwipeGesture.ts       # Touch gestures\n│   │   │   ├── useDynamicFavicon.ts     # Favicon theming\n│   │   │   ├── useAppLoading.ts         # Loading state\n│   │   │   ├── useMediaQuery.ts         # Responsive utilities\n│   │   │   └── useIdleDetection.ts      # Idle detection\n│   │   └── styles/                      # Additional stylesheets\n│   │       └── animations.css           # Custom animations\n│   ├── public/                          # Static assets\n│   ├── jest.config.js                   # Jest configuration\n│   ├── jest.setup.js                    # Jest setup\n│   ├── tailwind.config.ts               # Tailwind configuration\n│   ├── tsconfig.json                    # TypeScript configuration\n│   └── package.json                     # Dependencies\n└── README.md                            # This file\n```\n\n### Key Technologies\n\n| Technology                | Version | Purpose                         |\n| ------------------------- | ------- | ------------------------------- |\n| **Next.js**               | 16.0+   | React framework with app router |\n| **React**                 | 19.1    | UI library                      |\n| **TypeScript**            | 5+      | Type-safe development           |\n| **Tailwind CSS**          | 3.4+    | Utility-first styling           |\n| **Framer Motion**         | 12+     | Smooth animations               |\n| **Jest**                  | 30+     | Testing framework               |\n| **React Testing Library** | 16+     | Component testing               |\n| **Zustand**               | 5+      | State management                |\n| **Lucide React**          | Latest  | Icon library                    |\n\n### Design Patterns\n\n- **Component Composition**: Modular, reusable components\n- **Custom Hooks**: Encapsulated logic for reusability\n- **Type Safety**: Comprehensive TypeScript types\n- **Separation of Concerns**: Clear separation between UI and logic\n- **Test-Driven Development**: Tests written alongside features\n\n## Deployment\n\n### Development\n\n```bash\ncd frontend\nbun install\nbun run dev\n```\n\nStarts the development server at `http://localhost:3000` with:\n\n- Hot module replacement\n- Fast refresh\n- TypeScript checking\n- ESLint validation\n\n### Production Build\n\n```bash\n# Build optimized production bundle\nbun run build\n\n# Start production server\nbun run start\n```\n\nThe build process:\n\n- Optimizes and minifies code\n- Generates static assets\n- Creates production-ready bundle\n- Enables performance optimizations\n\n### Static Export\n\nFor static hosting (GitHub Pages, Netlify, Vercel):\n\n```bash\nbun run build\n# Output in .next/ directory\n```\n\n### Docker Deployment\n\n```dockerfile\nFROM oven/bun:1 AS base\n\n# Install dependencies\nFROM base AS deps\nWORKDIR /app\nCOPY package.json bun.lock ./\nRUN bun install --frozen-lockfile\n\n# Build application\nFROM base AS builder\nWORKDIR /app\nCOPY --from=deps /app/node_modules ./node_modules\nCOPY . .\nRUN bun run build\n\n# Production image\nFROM base AS runner\nWORKDIR /app\nENV NODE_ENV production\n\nCOPY --from=builder /app/public ./public\nCOPY --from=builder /app/.next/standalone ./\nCOPY --from=builder /app/.next/static ./.next/static\n\nEXPOSE 3000\nENV PORT 3000\n\nCMD [\"bun\", \"server.js\"]\n```\n\nBuild and run:\n\n```bash\ndocker build -t bankers-algorithm .\ndocker run -p 3000:3000 bankers-algorithm\n```\n\n### Environment Variables\n\nCreate `.env.local` for local development:\n\n```bash\n# Optional: Analytics\nNEXT_PUBLIC_GA_ID=your-ga-id\n\n# Optional: Error tracking\nNEXT_PUBLIC_SENTRY_DSN=your-sentry-dsn\n```\n\n## Contributing\n\nContributions are welcome! This project follows standard open-source practices.\n\n### Development Workflow\n\n1. **Fork the Repository**\n\n   ```bash\n   # Fork on GitHub, then clone your fork\n   git clone https://github.com/yourusername/bankers-algorithm-simulator.git\n   cd bankers-algorithm-simulator/frontend\n   ```\n\n2. **Create a Branch**\n\n   ```bash\n   git checkout -b feature/your-feature-name\n   ```\n\n3. **Install Dependencies**\n\n   ```bash\n   bun install\n   ```\n\n4. **Make Changes**\n   - Write clean, documented code\n   - Follow existing code style\n   - Add tests for new features\n   - Update documentation as needed\n\n5. **Test Your Changes**\n\n   ```bash\n   # Run tests\n   bun run test\n\n   # Check linting\n   bun run lint\n\n   # Build to verify\n   bun run build\n   ```\n\n6. **Commit and Push**\n\n   ```bash\n   git add .\n   git commit -m \"feat: add your feature description\"\n   git push origin feature/your-feature-name\n   ```\n\n7. **Create Pull Request**\n   - Open a PR on GitHub\n   - Describe your changes in detail\n   - Link any related issues\n   - Wait for review\n\n### Code Standards\n\n#### TypeScript\n\n- Use strict type checking\n- Avoid `any` types\n- Document complex types\n- Use interfaces for objects\n\n#### React Components\n\n- Use functional components\n- Implement proper prop types\n- Use hooks appropriately\n- Keep components focused\n\n#### Testing Standards\n\n- Write tests for new features\n- Maintain \u003e90% coverage\n- Test edge cases\n- Use descriptive test names\n\n#### Documentation\n\n- Update readme for new features\n- Add JSDoc comments\n- Include usage examples\n- Document breaking changes\n\n### Commit Convention\n\nFollow [Conventional Commits](https://www.conventionalcommits.org/):\n\n```text\nfeat: add new feature\nfix: bug fix\ndocs: documentation changes\nstyle: formatting changes\nrefactor: code refactoring\ntest: add or update tests\nchore: maintenance tasks\n```\n\n### Areas for Contribution\n\n- 🐛 **Bugfixes**: Report and fix bugs\n- ✨ **Features**: Add new algorithm features\n- 📚 **Documentation**: Improve docs and examples\n- 🧪 **Tests**: Increase test coverage\n- 🎨 **UI/UX**: Enhance user interface\n- ♿ **Accessibility**: Improve accessibility\n- 🌐 **i18n**: Add internationalization\n- ⚡ **Performance**: Optimize performance\n\n## Algorithm Background\n\n### Historical Context\n\nThe Banker's Algorithm was developed by **Edsger Dijkstra** in 1965 as part of his work on the THE multiprogramming system. It is named after the way bankers manage loans to ensure they can always meet withdrawal demands.\n\n### Theoretical Foundation\n\n**Safe State Definition**: A state is safe if there exists a sequence of processes ⟨P₁, P₂, ..., Pₙ⟩ such that for each Pᵢ, the resources that Pᵢ can still request can be satisfied by the currently available resources plus the resources held by all Pⱼ where j \u003c i.\n\n**Key Theorem**: If a system is in a safe state, no deadlock can occur. If a system is in an unsafe state, deadlock may occur (but is not guaranteed).\n\n### Real-World Applications\n\n- **Operating Systems**: Process scheduling and resource management\n- **Database Systems**: Transaction management and lock allocation\n- **Cloud Computing**: Virtual machine resource allocation\n- **Network Systems**: Bandwidth and connection management\n- **Manufacturing**: Production line resource scheduling\n\n### Complexity Analysis\n\n- **Time Complexity**: O(m × n²) where m = resources, n = processes\n- **Space Complexity**: O(m × n) for storing matrices\n- **Worst Case**: Must check all processes in each iteration\n\n### Limitations\n\n- Requires advance knowledge of maximum resource needs\n- Number of processes must be fixed\n- Resources must be fixed and known\n- Processes must eventually release resources\n- Not practical for systems with dynamic resource requirements\n\n## Related Algorithms\n\n- **Deadlock Detection**: Detects existing deadlocks\n- **Wait-Die/Wound-Wait**: Timestamp-based deadlock prevention\n- **Resource Allocation Graph**: Visual deadlock detection\n- **Two-Phase Locking**: Database transaction management\n\n## References\n\n- Dijkstra, E. W. (1965). \"Cooperating sequential processes\"\n- Silberschatz, A., Galvin, P. B., \u0026 Gagne, G. (2018). \"Operating System Concepts\"\n- Tanenbaum, A. S. (2014). \"Modern Operating Systems\"\n- [GeeksforGeeks: Banker's Algorithm](https://www.geeksforgeeks.org/bankers-algorithm-in-operating-system-2/)\n\n## Developer Information\n\n### Project Maintainer\n\n**Senior Full-Stack Developer** specializing in Operating Systems, Algorithms, and Educational Technology\n\n#### Technical Expertise\n\n**Core Competencies:**\n\n- 🎓 Operating Systems \u0026 Concurrent Programming\n- 🧮 Algorithm Design \u0026 Analysis\n- 💻 Modern Web Technologies (React, Next.js, TypeScript)\n- 📚 Educational Software Development\n- ⚡ Performance Optimization \u0026 Testing\n- 🏗️ System Architecture \u0026 Design Patterns\n\n**Technology Stack:**\n\n- **Frontend**: React 19, Next.js 16, TypeScript 5, Tailwind CSS\n- **State Management**: Zustand, React Hooks\n- **Animation**: Framer Motion, CSS Animations\n- **Testing**: Jest 30, React Testing Library\n- **Build Tools**: webpack, Turbopack, SWC\n- **Development**: ESLint, Prettier, Git\n\n**Specializations:**\n\n- Deadlock avoidance algorithms and resource allocation\n- Interactive algorithm visualization\n- Real-time system simulation\n- Educational tool development\n- Responsive and accessible UI design\n- Comprehensive testing strategies\n\n#### Project Philosophy\n\nThis project represents the intersection of theoretical computer science and practical software engineering. The goal is to make complex operating system concepts accessible through:\n\n- **Interactive Learning**: Hands-on experimentation with real algorithms\n- **Visual Understanding**: Step-by-step visualization of algorithm execution\n- **Production Quality**: Professional-grade code and architecture\n- **Open Source**: Free and accessible to students worldwide\n- **Best Practices**: Modern development standards and patterns\n\n#### Development Approach\n\n- **Test-Driven Development**: 31+ comprehensive test cases\n- **Type Safety**: Full TypeScript coverage with strict mode\n- **Documentation**: Extensive inline comments and external docs\n- **Accessibility**: WCAG 2.1 AA compliance\n- **Performance**: Optimized rendering and state management\n- **Maintainability**: Clean code principles and SOLID design\n\n#### Open Source Commitment\n\nCommitted to creating high-quality educational tools that bridge the gap between academic theory and practical implementation. This project serves as:\n\n- 📖 A learning resource for computer science students\n- 🔬 A research tool for algorithm analysis\n- 🎓 A teaching aid for operating systems courses\n- 💡 A reference implementation of Dijkstra's algorithm\n- 🌍 A contribution to the open-source education community\n\n### Contact \u0026 Links\n\n- **GitHub**: [@AlphsX](https://github.com/AlphsX)\n- **YouTube**: [@AccioLabsX](https://www.youtube.com/channel/UCNn7PEFI65qIkR2bbK3yveQ)\n\n### Acknowledgments\n\nSpecial thanks to:\n\n- **Edsger Dijkstra** for the original algorithm\n- **Operating Systems community** for educational resources\n- **Open source contributors** for inspiration and tools\n- **Computer Science educators** for feedback and suggestions\n\n---\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n```text\nMIT License\n\nCopyright (c) 2025 [AlphsX]\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**⭐ Star this repository if you find it helpful!**\n\nMade with ❣️ for the computer science education community\n\n© 2025 AlphsX, Inc.\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falphsx%2Fbanker-s-algorithmx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falphsx%2Fbanker-s-algorithmx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falphsx%2Fbanker-s-algorithmx/lists"}