How jlannoo/rollies works
Main Components
• User Interface (UI) Components – Represent the visual parts of the application:
• App Component (src/App.tsx) as the entry point.
• UI subcomponents found in the src/components directory: Dialog, Header, Info, Input, Rolls.
• Styling folders (less crucial for architecture but indicate separation of concerns with module.scss files).
• Dice Rolling and Syntax Interpreter Logic – Captures the core functionality:
• Parser Module (src/parser): Contains lexer.ts (tokenizing input), parser.ts (creating a syntax tree), evaluator.ts (calculating roll results), and token.ts (defining tokens).
• Helper functions (src/helpers/loadMD.tsx) which may support rendering markdown (e.g., help texts or instructions).
• Application State Management – Maintains the state of dice roll results or user input:
• Located in src/stores (rolls.ts) which indicates a centralized state store.
• Public Assets – Resources such as images, fonts, and HTML (index.html, resources under public directory):
• These establish the static resources and visual assets (like rollies.png in public/img).
• Tests – Unit tests for the parser components under tests/parser, ensuring the dice syntax processing works correctly.
Relationships and Interactions Between Components
• The User interacts with the UI (Input, Dialog, etc.) that is rendered through the App component.
• The Input Component captures the dice expression (e.g., "2d6", "1d20+5").
• The expression is processed by the parser modules: the Lexer tokenizes the input, the Parser builds an abstract syntax tree and the Evaluator computes the dice rolls.
• The computed results are stored using the state management system (rolls.ts in src/stores).
• The result is then displayed via the Rolls component.
• Additionally, the Header and Info components might be used to display instructions or additional contextual information.
• Markdown files under src/md (Long.md, Short.md) are likely used as content resources that can be loaded dynamically via helper functions.
Architectural Patterns and Design Principles
• Modular Design – The parser, evaluator, and lexer are separate modules, making it easier to maintain and test (as reflected in the tests directory).
• Component-based Frontend – The React-based UI is neatly split into independent components, each with its own styling.
• Test-Driven Development – Presence of a comprehensive test suite showing a dedication to validation of core components (lexer, parser, evaluator).
Relevant Technologies and Frameworks
• TypeScript – Core language to enforce type safety throughout the codebase.
• React – Evidenced by .tsx files in the src directory (App.tsx and various components).
• Vite – Likely used for bundling/building the project (vite.config.js).
• ESLint – For code quality and standard conformance (.eslintrc.cjs).
• GitHub Actions – For CI/CD, as indicated by workflows in .github/workflows.
• SCSS Modules – Used for styling components (e.g., Header.module.scss).