How anthonylimo90/ussd-composer works
Main Components
• USSDComposer Library: The heart of the project, implemented in lib/USSDComposer.js. This component handles the composition of menus, addition of options via the addOption method, title management, and rendering of the menu/flow.
• Entry Point (index.js): Acts as a re-exporter of the USSDComposer class or as a minimal integration layer.
• Consumer/Application: Although not included in this repository, the README gives an example integration (e.g., an Express POST endpoint) which represents how external applications use this utility.
• Testing Suite: Located in tests/USSDComposer.test.js, ensuring the library’s operations are validated.
• External Client / USSD Gateway:
• Represents the client (usually a mobile phone user) that initiates USSD requests.
• API Endpoint (e.g., Express Server’s /ussd route):
• Acts as a mediator, receiving USSD requests from users and invoking the library.
• USSDComposer Library:
• Key methods: constructor (for setting the initial menu title), addOption (for adding menu items and their handlers), setTitle (for updating the title), and render (for processing user input and generating menus).
• Attach a note about its internal flow of choosing the right response based on input received.
• Testing & Validation:
• Package Management:
Architectural Patterns and Design Principles
• Emphasis on Separation of Concerns: The utility library focuses purely on USSD flow composition. It does not deal with network layers or HTTP handling (left to client apps).
• Modularity: The clear separation between the library code (lib) and tests allows for independent evolution and easy integration into various systems.
• Reusability: By exposing a clean API, this library can be plugged into any Node.js server application, as indicated in the README’s usage instructions.