How 4bharathk/congestion-tax-calculator works
Project type + purpose (from README + tree)
This is a single-service Spring Boot (3.5) REST API that calculates congestion tax fees for a given vehicle type and a list of toll-entry timestamps.
• API boundary (HTTP)
• request/response model
• service + domain logic
• validation + exception handling
• configuration and rules (2013-only, exemptions, holidays, daily cap, etc.)
• test coverage
Architecture inferred from file structure
The code is organized in typical Spring layering:
• Bootstrap
• CongestionTaxCalculatorApplication.java (Spring Boot entrypoint)
• Configuration
• config/AppConfig.java (likely bean wiring, constants, rule configuration, etc.)
• resources/application.properties (runtime configuration)
• Web/API layer
• controller/CongestionTaxController.java (REST endpoint /v1/congestiontax)
• controller/GlobalExceptionHandler.java (central error mapping to HTTP responses)
• Service layer (core orchestrator)
• services/TaxCalculatorService.java (tax calculation orchestration; applies rules)
• Domain / API models
• models/VehicleTaxRequest.java (input payload: vehicleType + tollEntries)
• models/TaxFeeReponse.java, models/TaxDetails.java (output)
• models/ErrorResponse.java (error payload)
• Domain utilities / rule primitives
• utils/TaxCalUtils.java (helpers: parsing, date rules, holiday checks, etc.)
• utils/TaxSlot.java (time-slot fee mapping or fee bracket representation)
• Tests
Main components to include (separate into as many components as possible)
Clients / External
API Client (curl/Postman/consumer system)
Application / Runtime container
Spring Boot App (JVM process)
• Embedded Web Server (Tomcat/Netty—Spring Boot default)
• Spring MVC Dispatcher (request routing)
Web layer
GlobalExceptionHandler → ErrorResponse
Service + rules
TaxCalculatorService (main calculation coordinator)
• Vehicle exemption rule (e.g., Tractor exempt, etc.)
• “Only year 2013” rule
• Holiday exemption rule (with “except day before holiday” nuance)
• Daily max cap rule
• Duplicate timestamps / normalization (implied by sample inputs)
• Single charge rule (mark as TODO/partial)
Utility / domain primitives
TaxSlot (time-range → fee mapping)
Configuration
10. AppConfig + application.properties (fee table? caps? holidays? timezone? parsing formats?)
Outputs
TaxFeeReponse / TaxDetails returned to client
Quality gates (optional but good)
Controller → Validation
• If invalid: Controller/Framework → GlobalExceptionHandler → ErrorResponse → Client
Controller → returns response JSON → Client
• TaxCalculatorService / TaxCalUtils / TaxSlot ← AppConfig / application.properties (depending on how it’s wired)
Architectural patterns to highlight
• Layered architecture: Controller → Service → Utilities/Domain
• Centralized exception handling (@ControllerAdvice pattern)
• Rules engine (implicit): not a formal rules engine library, but a rule pipeline inside service/utils
• Configuration-driven behavior (if fees/caps/holidays are configurable)
• Java 21
• Spring Boot 3.5
• Spring MVC (REST)
• Maven build (pom.xml)
• JUnit tests (and Spring Test, if used)
Use the real names to be maximally accurate:
• CongestionTaxCalculatorApplication (entrypoint)
• CongestionTaxController
• GlobalExceptionHandler
• TaxCalculatorService
• TaxCalUtils
• TaxSlot
• VehicleTaxRequest
• TaxFeeReponse
• TaxDetails
• ErrorResponse
• AppConfig
• application.properties
• Tests:
• CongestionTaxControllerTest
• TaxCalculatorServiceTest
Final “don’t overthink it” checklist (what makes it “best”)
• You show both success and failure flows (invalid date, empty list, invalid vehicle type casing).
• You explicitly represent rule constraints from README (2013-only, holidays, cap, exemptions, TODO rule).
• You do not invent databases, queues, caches, or UIs that aren’t in the repo.