Refactor: Extract components and utilities into modular architecture#3
Open
Gluflex wants to merge 1 commit into
Open
Refactor: Extract components and utilities into modular architecture#3Gluflex wants to merge 1 commit into
Gluflex wants to merge 1 commit into
Conversation
…r architecture
Split two 654-line and 824-line monolithic files into 20 focused modules
with clear separation of concerns, following industry best practices.
New structure:
- src/constants/ — deviceConstants.js, simConstants.js (pure data)
- src/components/ — LCD, Btn, DevicePanel, DropSimulatorPanel, LiveStatsPanel,
ScreenJumper, SpecPanel (presentational components)
- src/hooks/ — useDripMonitor.js (all device state, effects, handlers)
- src/utils/ — flowCalc.js, displayHelpers.js (pure business logic)
- src/sim/ — physics.js, measurement.js, drawChamber.js, drawScope.js
(simulation engine separated from rendering)
- src/styles/ — theme.js (design tokens for recurring color values)
App.jsx reduced from 654 to 110 lines (orchestration only).
DripitoSim.jsx tick() reduced from 490 lines to ~30-line orchestrator.
Deleted unused src/App.css; cleaned Vite scaffold styles from index.css.
No behavioral changes; all functionality preserved exactly.
https://claude.ai/code/session_01AGTCTQnVmKLfVutZoNHKhj
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors the monolithic
App.jsxandDripitoSim.jsxfiles into a modular, component-based architecture. The codebase is reorganized into separate concerns: UI components, simulation physics, utility functions, and constants, improving maintainability and testability.Key Changes
Component Extraction
LCD,Btninto dedicated component files (src/components/LCD.jsx,src/components/Btn.jsx)DevicePanel,DropSimulatorPanel,LiveStatsPanel,SpecPanel,ScreenJumperfor organized UI sectionsuseDripMonitor(src/hooks/useDripMonitor.js)Simulation Refactoring
src/sim/physics.js(makeDrop,updateDropPhysics,calcBeamOcclusion)src/sim/measurement.js(tryMeasureDrop)src/sim/drawChamber.jsandsrc/sim/drawScope.jssrc/constants/simConstants.jsUtilities & Constants
src/utils/displayHelpers.jsfor LCD display formatting (formatElapsed,alarmLevel,devPct,getLines)src/utils/flowCalc.jsfor flow rate calculations (calcInstFlow,calcAvgFlow,calcTotalMl)src/constants/deviceConstants.js(drip sets, alarm states, timing)src/styles/theme.jsfor centralized color tokensApp Structure
App.jsxnow acts as a thin orchestration layer, delegating touseDripMonitorhook and component compositionApp.cssindex.cssto essential styles onlyImplementation Details
useDripMonitorhook encapsulates all device state management (drop counting, flow calculation, alarm logic, UI state)https://claude.ai/code/session_01AGTCTQnVmKLfVutZoNHKhj