How khant-nyar/codetest works
Main Components
• Client/Requester: Represents the external consumer (could be a browser, mobile app, or other API consumer making HTTP requests).
• API Gateway/Load Balancer: If applicable, denote the entry point through which requests are routed into the system.
• Web Server & Laravel Framework: Represent the Laravel application which includes several layers:
a. Routing Layer: Use the routes files (routes/api.php, channels.php, console.php, web.php) to show how incoming API requests are directed.
b. Controller Layer: Identify controllers such as DemoController and any others that handle the currency conversion endpoint.
d. Service/Integration Layer: A logical node where the application interacts with external services:
• IP Geolocation Service: For identifying the client’s location based on their IP.
• Exchange Rate API Provider: For retrieving up-to-date currency exchange rates.
• Currency Mapping: Optionally, include the “currencybycountry.json” as a reference for mapping countries to their respective currencies if that is used within the service.
e. Console/Task Scheduling: Note any Artisan commands, scheduled tasks, or console commands (such as GenerateAuthToken.php) that may facilitate periodic updates or authentication token generation.
Database and Persistence
• Caching/Storage: Optionally add nodes for caching mechanisms if used (see Laravel cache configurations and the storage directory).
Data Flow and Interactions
• Start the flow at the Client initiating a request.
• Within the controller, illustrate interactions with the Middleware (for authentication and request validation).
• The controller then interacts with the service layer: call out two branches:
• One branch to the IP Geolocation service to retrieve user location.
• Another branch to the Exchange Rate API to fetch rates.
• After receiving data from both external services, show the controller/service computing the conversion (including the percentage difference).
Architectural Patterns and Design Principles
• The project follows a layered architecture typical of Laravel applications. Emphasize the separation of concerns between routing, controller logic, middleware for security, and integration layers for external API interactions.
• That the system leverages configuration files (in the config directory) and uses environment variables (.env.example) for sensitive configuration, ensuring secure and deployable settings.
• Rectangles for system components (Laravel routing, controllers, etc.)