How mildlybrutal/cpu-scheduling works
Main Components
• Frontend (Presentation Layer):
• Next.js App Router: Represents the primary structure of the pages contained in the src/app directory (e.g., home page, simulator page, docs pages).
• Documentation Pages: Under src/app/docs, these pages present educational content and details for each algorithm.
• Shared UI Components: Located in src/components (e.g., GanttChart, ProcessForm, SimulationControls, and common UI elements contained in src/components/ui).
• State Management:
• SchedulingContext: Found in src/context, this provides a global context for managing simulation state and data.
• Business Logic and Simulation Engine:
• Scheduler Library: In src/lib/schedulers, separate files for fcfs.ts, sjf.ts, roundRobin.ts, and priority.ts implement the respective simulation algorithms.
• Scheduling Controller: src/lib/schedulingController.ts acts as a coordinator that likely integrates the simulation algorithms with the application’s state.
• Utility Functions: In src/lib/utils and metrics (src/lib/utils/metrics.ts) for calculations, data processing, and performance metric computation.
• Configuration and Styling:
• Next.js and Tailwind configurations: next.config.ts, tailwind.config.ts, and global styles (src/app/globals.css).
Relationships and Interactions
• The UI Layer sends user input (process details and simulation controls) from components (ProcessForm and SimulationControls) to the SchedulingContext.
• SchedulingContext acts as the mediator that passes simulation data to the scheduling controller and the corresponding scheduler algorithm (from src/lib/schedulers) based on user selection.
• Scheduler algorithms process simulation data and return performance metrics which are then passed back through the context to update UI components (GanttChart and MetricsDisplay).
• Documentation pages (under src/app/docs) provide interactive explanations of each algorithm, likely integrating similar UI components or specialized content.
• Utility functions support both the simulation computational logic (e.g., calculating statistics) and UI data formatting.
Architectural Patterns and Technologies
• The application follows a component-based architecture using Next.js (with the new App Router paradigm) and React 18+ for interactive UI and concurrent rendering.
• TypeScript is used throughout for type safety.
• The separation of concerns is clear: presentation (in src/app & src/components), state management (src/context), business logic (src/lib), and styling (Tailwind CSS).
• Patterns such as MVC-like separation or service/module-based separation can be observed here: UI components trigger interactions, the context handles state, and lib modules perform core business logic.