This project demonstrates a full-stack architecture where a native C++ string conversion engine is exposed through a .NET REST API and consumed by a modern frontend UI. It adheres to production-grade deployment standards, including environment isolation and artifact promotion workflows.
- Implements multiple string conversion strategies (Alternating Case, Capitalize Words, Snake Case, etc.).
- Built as a shared library using CMake:
- Windows →
ProcessString.dll - macOS →
libProcessString.dylib - Linux →
libProcessString.so
- Windows →
- Uses P/Invoke to call the exported C++ DLL functions.
- Provides REST endpoints (e.g.,
/api/WordCase/convert) for frontend consumption. - Built and published with
dotnet publish.
- Provides a user interface to input text and select conversion type.
- Calls the .NET REST API endpoints to perform conversions.
- Built with
npm run build→ outputs static files indist/.
The project is designed to be built in sequence:
1.Build C++ DLL
mkdir -p CaseConversionAPI/CppLib/build
cd CaseConversionAPI/CppLib/build
cmake ..
cmake --build . --config Release
2.Build .NET API
dotnet restore CaseConversionAPI/DotNetAPI
dotnet publish CaseConversionAPI/DotNetAPI -c Release -o ./publish
cp CaseConversionAPI/CppLib/build/libProcessString.* ./publish/3.Build Frontend
cd string-conversion-ui
npm install
npm run buildThe project exposes a C++ string conversion engine to the .NET REST API using a DLL and P/Invoke.
ProcessStringDLL.cpp acts as a bridge between:
- C++ conversion logic
- C# service layer
- REST API controller
It dispatches user input to the appropriate conversion strategy using Factory + Strategy pattern.
extern "C" PROCESSSTRING_API const char* processStringDLL(const char* input, int choice);input→ C-string input textchoice→ integer representing conversion type
- Converted string (C-style pointer)
- Returns original input if invalid choice
| Choice | Conversion |
|---|---|
| 1 | Alternating Case |
| 2 | Capitalize Words |
| 3 | Lower Case |
| 4 | Upper Case |
| 5 | Sentence Case |
| 6 | Toggle Case |
| 7 | Reverse |
| 8 | Remove Vowels |
| 9 | Remove Spaces |
| 10 | Invert Words |
| 11 | Snake Case |
| 12 | Kebab Case |
| 13 | Leet Speak |
- Strategy Pattern
- Factory Pattern
- Client Dispatcher
REST API (C#)
↓
ProcessStringService (P/Invoke)
↓
processStringDLL (C++)
↓
Factory → Strategy → Client
↓
Converted StringThe C++ project builds a shared library:
- Windows →
ProcessString.dll - macOS →
libProcessString.dylib - Linux →
libProcessString.so
This library is loaded by the C# service using P/Invoke.
The .NET service calls the DLL:
[DllImport("ProcessString")]
private static extern IntPtr processStringDLL(string input, int choice);This enables the REST API to use native C++ performance-critical logic.
C++ Conversion Engine
↑
DLL Export Layer
↑
C# P/Invoke Wrapper
↑
ProcessStringService
↑
WordCaseController
↑
REST API +---------------------+
| Frontend (React) |
| Vite + TypeScript |
+----------+----------+
|
REST API call
|
+----------v----------+
| REST API (C#) |
| WordCaseController|
+----------+----------+
|
P/Invoke
|
+----------v----------+
| ProcessStringDLL | <-- DLL wrapper
+----------+----------+
|
+----------v----------+
| Core C++ Logic |
| (Factory + Strategy)|
+----------+----------+
|
+-----------------+-----------------+
| |
+--------v--------+ +----------v--------+
| main.cpp CLI | | Google Tests |
| Local testing | | Unit testing |
+-----------------+ +-------------------+
- C++ (conversion logic, built with CMake)
- .NET 8 (REST API wrapper, P/Invoke)
- React + Vite + TypeScript (frontend UI)
- GitHub Actions (CI/CD pipeline)
- Azure App Service + GitHub Pages (deployment targets)
- Create Dockerfile (Project Root)
# ---------- Build C++ ----------
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
RUN apt-get update && apt-get install -y \
build-essential \
cmake
WORKDIR /src
COPY . .
# Clean old CMake cache
RUN rm -rf CaseConversionAPI/CppLib/build
# Build C++ shared library
RUN cmake -S CaseConversionAPI/CppLib -B CaseConversionAPI/CppLib/build -DCMAKE_BUILD_TYPE=Release
RUN cmake --build CaseConversionAPI/CppLib/build --parallel
# Publish .NET API
RUN dotnet publish CaseConversionAPI/DotNetAPI -c Release -o /app/publish
# Copy shared library
RUN cp CaseConversionAPI/CppLib/build/lib/libProcessStringDLL.so /app/publish/
# ---------- Runtime ----------
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app/publish .
EXPOSE 8080
ENTRYPOINT ["dotnet", "DotNetAPI.dll"]2.Start Docker Desktop
Make sure Docker Desktop is running. You can use commmand in terminal to start the ddocker
open -a Docker3.Build Docker image
From the project root (where the Dockerfile exists):
docker build -t case-conversion-api .4.Run container
docker run -p 8080:8080 case-conversion-apiYou should see:
Now listening on: http://[::]:8080
5.Open Swagger UI Open in browser:
http://localhost:8080/
To run Frontend + Backend together, use Docker Compose.
1.Update Frontend API URL
ENsure the react frontned calls:
http://localhost:8080/api/WordCase/convert2.Create docker-compose.yml (Project Root)
version: "3.9"
services:
backend:
build: .
container_name: case-api
ports:
- "8080:8080"
restart: unless-stopped
frontend:
image: node:20
container_name: case-ui
working_dir: /app
volumes:
- ./string-conversion-ui:/app
ports:
- "5173:5173"
command: sh -c "npm install && npm run dev -- --host"
depends_on:
- backend3.Run Full Stack
docker compose up --buildThis will start:
- Backend → http://localhost:8080
- Frontend → http://localhost:5173
This project supports multi-environment deployment using Docker Compose and image promotion.
The system follows
Development → Staging → Production- Build once in dev
- Promote the same Docker image forward
- Avoid rebuilding for each environment
| Environment | Tag |
|---|---|
| Dev | dev |
| Staging | staging |
| Production | latest |
nitishhsinghhh/case-api:dev
nitishhsinghhh/case-api:staging
nitishhsinghhh/case-api:latestUsed for local development with hot reload and debugging.
Run Dev
docker compose -f docker-compose.dev.yml up --buildFeatures
- Builds image locally
- Uses ASPNETCORE_ENVIRONMENT=Development
- Frontend runs with npm run dev
- Debug logs enabled
Used for production-like validation before release
Promote Image from Dev
docker tag nitishhsinghhh/case-api:dev nitishhsinghhh/case-api:staging
docker push nitishhsinghhh/case-api:stagingRun Staging
docker compose -f docker-compose.staging.yml up -dFeatures
- Uses pre-built Docker image
- Uses ASPNETCORE_ENVIRONMENT=Staging
- No local builds
- Simulates production behavior
Used for final deployment.
Promote Image from Staging
docker tag nitishhsinghhh/case-api:staging nitishhsinghhh/case-api:latest
docker push nitishhsinghhh/case-api:latestRun Production
docker compose -f docker-compose.prod.yml up -dFeatures
- Uses stable image (latest)
- Uses ASPNETCORE_ENVIRONMENT=Production
- Restart policies enabled
- Health checks enabled
# Step 1: Build in Dev
docker compose -f docker-compose.dev.yml up --build -d
docker push nitishhsinghhh/case-api:dev
# Step 2: Promote to Staging
docker tag nitishhsinghhh/case-api:dev nitishhsinghhh/case-api:staging
docker push nitishhsinghhh/case-api:staging
docker compose -f docker-compose.staging.yml up -d
# Step 3: Promote to Production
docker tag nitishhsinghhh/case-api:staging nitishhsinghhh/case-api:latest
docker push nitishhsinghhh/case-api:latest
docker compose -f docker-compose.prod.yml up -d| File | Purpose |
|---|---|
docker-compose.dev.yml |
Local development |
docker-compose.staging.yml |
Pre-production testing |
docker-compose.prod.yml |
Production deployment |
- Single artifact promotion (same image across environments)
- Environment-specific configuration via ASPNETCORE_ENVIRONMENT
- No rebuilds after dev
- Isolation of environments
Developer → Dev Build → Docker Image
↓
Staging
↓
Production +---------------------+
| Frontend (React) |
| Vite + TypeScript |
| (Docker) |
+----------+----------+
|
HTTP (REST)
|
+----------v----------+
| .NET REST API |
| ASP.NET Core |
| (Docker) |
+----------+----------+
|
P/Invoke
|
+----------v----------+
| C++ Shared Library |
| libProcessString |
+----------+----------+
|
+----------v----------+
| Factory + Strategy |
| Conversion Engine |
+---------------------++-------------------+ +-------------------+
| Frontend | -----> | Backend API |
| React + Vite | | .NET + C++ DLL |
| Port 5173 | | Port 8080 |
+-------------------+ +-------------------+ Browser
↓
React UI (Docker)
↓
HTTP REST Call
↓
ASP.NET Core API (Docker)
↓
P/Invoke
↓
C++ Shared Library
↓
Strategy Pattern Conversion
↓
Response back to UI