From 152f1e6a217ef6ada22b18369ee81ae0c43cb93a Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Fri, 26 Dec 2025 03:40:20 +0000
Subject: [PATCH] Convert backend to Drogon HTTP API server
Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
---
BUILD.md | 8 +-
README.md | 3 +-
backend/CMakeLists.txt | 4 +-
backend/README.md | 59 +++++++++--
backend/conanfile.py | 2 +-
backend/config.json | 43 ++++++++
backend/src/controllers/MergeController.cc | 112 +++++++++++++++++++++
backend/src/controllers/MergeController.h | 49 +++++++++
backend/src/main.cpp | 102 ++++++-------------
9 files changed, 294 insertions(+), 88 deletions(-)
create mode 100644 backend/config.json
create mode 100644 backend/src/controllers/MergeController.cc
create mode 100644 backend/src/controllers/MergeController.h
diff --git a/BUILD.md b/BUILD.md
index 7bd84eb..d0172c5 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -19,7 +19,7 @@ WizardMerge/
### C++ Backend
-The backend implements the core three-way merge algorithm.
+The backend implements the core three-way merge algorithm with an HTTP API server using Drogon.
**Prerequisites:**
- C++17 compiler (GCC 7+, Clang 6+, MSVC 2017+)
@@ -33,11 +33,13 @@ cd backend
./build.sh
```
-**Usage:**
+**Run the server:**
```bash
-./build/wizardmerge-cli base.txt ours.txt theirs.txt output.txt
+./build/wizardmerge-cli
```
+The HTTP server will start on port 8080. Use the POST /api/merge endpoint to perform merges.
+
See [backend/README.md](backend/README.md) for details.
### TypeScript Frontend
diff --git a/README.md b/README.md
index 55b4fc2..2cc2789 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,8 @@ WizardMerge uses a multi-frontend architecture with a high-performance C++ backe
- **Location**: `backend/`
- **Build System**: CMake + Ninja
- **Package Manager**: Conan
-- **Features**: Three-way merge algorithm, conflict detection, auto-resolution
+- **Web Framework**: Drogon
+- **Features**: Three-way merge algorithm, conflict detection, auto-resolution, HTTP API
### Frontend (TypeScript/Next.js)
- **Location**: `frontend/`
diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt
index 0050524..b250072 100644
--- a/backend/CMakeLists.txt
+++ b/backend/CMakeLists.txt
@@ -7,6 +7,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Find dependencies via Conan
+find_package(Drogon CONFIG REQUIRED)
find_package(GTest QUIET)
# Library sources
@@ -23,9 +24,10 @@ target_include_directories(wizardmerge
# Executable
add_executable(wizardmerge-cli
src/main.cpp
+ src/controllers/MergeController.cc
)
-target_link_libraries(wizardmerge-cli PRIVATE wizardmerge)
+target_link_libraries(wizardmerge-cli PRIVATE wizardmerge Drogon::Drogon)
# Tests (if GTest is available)
if(GTest_FOUND)
diff --git a/backend/README.md b/backend/README.md
index 32ac40b..1200a90 100644
--- a/backend/README.md
+++ b/backend/README.md
@@ -1,6 +1,6 @@
# WizardMerge C++ Backend
-This is the C++ backend for WizardMerge implementing the core merge algorithms.
+This is the C++ backend for WizardMerge implementing the core merge algorithms with a Drogon-based HTTP API.
## Build System
@@ -8,6 +8,7 @@ This is the C++ backend for WizardMerge implementing the core merge algorithms.
- **Package Manager**: Conan
- **CMake**: Version 3.15+
- **C++ Standard**: C++17
+- **Web Framework**: Drogon
## Building
@@ -36,8 +37,8 @@ cd build
cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
ninja
-# Run the executable
-./wizardmerge-cli base.txt ours.txt theirs.txt output.txt
+# Run the HTTP server
+./wizardmerge-cli
```
## Testing
@@ -53,12 +54,16 @@ ninja test
backend/
├── CMakeLists.txt # CMake build configuration
├── conanfile.py # Conan package definition
+├── config.json # Drogon server configuration
├── include/ # Public headers
│ └── wizardmerge/
│ └── merge/
│ └── three_way_merge.h
├── src/ # Implementation files
│ ├── main.cpp
+│ ├── controllers/
+│ │ ├── MergeController.h
+│ │ └── MergeController.cc
│ └── merge/
│ └── three_way_merge.cpp
└── tests/ # Unit tests
@@ -69,16 +74,48 @@ backend/
- Three-way merge algorithm (Phase 1.1 from ROADMAP)
- Conflict detection and marking
- Auto-resolution of common patterns
-- Command-line interface
+- HTTP API server using Drogon framework
+- JSON-based request/response
-## Usage
+## API Usage
+
+### Start the server
```sh
-wizardmerge-cli