Skip to content

refactor: Modernize architecture and apply canonical C++ project layout#2

Open
NoaLand wants to merge 72 commits intotechops-recsys-lateral-hiring:mainfrom
NoaLand:main
Open

refactor: Modernize architecture and apply canonical C++ project layout#2
NoaLand wants to merge 72 commits intotechops-recsys-lateral-hiring:mainfrom
NoaLand:main

Conversation

@NoaLand
Copy link
Copy Markdown

@NoaLand NoaLand commented Mar 10, 2026

Context & Objective

This PR completely modernizes the legacy C++ delivery codebase to serve as a high-quality, realistic assessment tool for Consultant+ level candidates.

The primary goal of this refactoring was to elevate the architectural design, C++ language standards, and project structure to industry best practices, while intentionally preserving (and highlighting) the core business logic "code smells" for candidates to identify during the interview.

Enterprise-Grade C++ Project Structure

  • Canonical C++ Layout (Pitchfork): Implemented strict physical separation of interface and implementation by introducing dedicated include/ and src/ directories across all modules.
  • Namespaced Includes: Headers are now packaged under enterprise-standard paths (e.g., #include <tw/delivery/service/CartService.h>), preventing header clashes and evaluating the candidate's familiarity with large-scale C++ codebases.
  • CMake Boundary Enforcement: Refactored CMakeLists.txt to strictly enforce module boundaries using target_include_directories with PUBLIC and PRIVATE visibility scopes.

Key Architectural & C++ Enhancements

  • Clean Architecture Implementation: Dismantled the monolithic rest/ directory and restructured the project into strict layers (core/, dto/, infra/adapters/, service/, app/).
  • Anti-Corruption Layer (ACL): Isolated the 3rd-party JSON library (nlohmann::json) inside infra/adapters/.
  • Modern C++ Memory Management:
    • Fixed fatal Object Slicing and memory leaks in the Product hierarchy by introducing std::shared_ptr and virtual destructors.
    • Applied the Sink-it pattern (std::move) and std::string_view for zero-copy efficiency.
    • Enforced the Rule of Zero by removing broken, manually-written copy constructors.
  • Command Dispatcher Pattern: Refactored main.cpp's messy switch-case into a scalable std::unordered_map router with robust stream state handling.

NoaLand added 30 commits March 9, 2026 11:24
…e smart pointer instead of base class in C++ to support subclass
NoaLand added 30 commits March 10, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant