How tsevdos/elutils works
Main Components
• Public API and Entry Point: Represent the main file (src/index.ts) that re-exports all the utility modules.
• geoUtils: Functions related to geographic data and location operations. This module depends on static JSON data (administrative regions, cities, postal codes, etc.) found in the data folder.
• validationUtils: Functions meant for validating data such as postal codes, VAT numbers, phone numbers, etc.
• dateUtils: Contains date-related functionality (getting days, months, quarters, eras, and holidays).
• formatUtils: Offers formatting functions (e.g., formatting weights).
• languageUtils: Deals with Greek text transformations and comparisons.
• Data Store: A dedicated component that represents the JSON data files in the data directory. This component is used primarily by geoUtils to consult static data.
• Testing: A clear “Test Suite” component representing the __tests__ directory, which runs various Jest tests to ensure the utility functions behave as expected.
• Build Tools: Files like tsconfig.json and tsup.config.ts indicating TypeScript compilation and bundling.
Relationships and Interactions
• From each module, you could also indicate dependency to helper modules (if any) and documentation. Additionally, mark the testing suite as running tests specifically on each module.
• The build and CI/CD components are shown separately and linked to the entire codebase; they “watch over” code quality and automated deployment.
Architectural Patterns and Design Principles
• Modular Design: The clear separation into discrete modules enhances maintainability and testability.
• Single Responsibility Principle: Each module is dedicated to a specific kind of utility (geographic, date, validating, formatting, and language processing).
• Zero-dependency and Strong Typing: Emphasize that the library is self-contained with no external dependencies and that TypeScript’s type-checking is central to its design.
• Test-Driven Development Support: Presence of tests for each module indicates an emphasis on reliability.
Relevant Technologies
• TypeScript – for strongly-typed code.
• Jest – for running unit tests (see jest.config.cjs and test folder).
• tsup – used for bundling/build configuration (see tsup.config.ts).
• GitHub Actions – automated CI/CD (workflows for testing and publishing).
• Static JSON Data Files – store geographic and related data which are consumed by certain utility functions.
• ESLint and Prettier – code style and formatting tools.