⚙️ Wright Server - A powerful middleware runtime built with Ktor for dynamic API mapping and transformation
Wright Server Ktor is a lightweight middleware application that provides dynamic API mapping, transformation, and routing capabilities. It acts as an intelligent proxy that can transform requests and responses between different API formats (SOAP to REST, REST to REST) while providing advanced data transformation capabilities.
- SOAP to REST transformation
- REST to REST mapping
- Dynamic routing based on request patterns
- Configurable endpoint mappings via YAML configuration
- Built-in transformation functions including:
- Cryptographic operations (RSA encryption/decryption, AES encryption)
- Data type conversions (string, int, double, boolean)
- String manipulation (case conversion, substring extraction)
- Date/time formatting and calculations
- Mathematical operations (sum, subtract)
- Conditional logic and expressions
- Name parsing (first name, last name extraction)
- OpenTelemetry integration for distributed tracing
- Jaeger-compatible span naming and correlation
- Structured logging with MDC correlation
- Health check endpoints for monitoring
- Configurable authentication (Bearer tokens, API keys)
- Proxy support with SSL verification options
- Environment-based configuration management
- Sensitive data masking capabilities
- Asynchronous processing with Kotlin coroutines
- HTTP client optimization with compression and connection pooling
- Configurable timeouts and retries
- Docker containerization ready
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Client App │───▶│ Wright Server │───▶│ Target API │
│ │ │ (Ktor) │ │ │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
▼
┌──────────────────┐
│ Mapping Engine │
│ + Transformations│
└──────────────────┘
- Java 11 or higher
- Docker (optional)
-
Clone the repository
git clone <repository-url> cd wright-server-ktor
-
Configure environment variables
# Edit docker-compose.yml and set: - BASE_URL=<your-target-api-url> - BEARER_TOKEN=<your-auth-token> - OTEL_EXPORTER_OTLP_ENDPOINT=<your-observability-endpoint>
-
Start the application
docker-compose up -d
-
Verify deployment
curl http://localhost:8080/health # Expected response: "Healthy! 🚀"
-
Build the project
./gradlew build
-
Run the application
./gradlew :server:run
ktor:
deployment:
port: 8080
contextPath: "" # API context path
middleware:
mappingConfigPath: "mapping/sample_mapping.yaml"
wright:
baseUrl: ${BASE_URL}
timeout: 120000
bearerToken: ${BEARER_TOKEN}
maxRetries: 3
logging:
logBodies: true
maskSensitive: false
crypto:
aesKey: "Your AES Key Here"
iv: "Your IV Here"
rsaPrivateKey: "Your RSA Private Key Here"
proxy:
enabled: ${PROXY_ENABLED:false}
host: ${PROXY_HOST:localhost}
port: ${PROXY_PORT:5559}
type: ${PROXY_TYPE:HTTP}
disableSslVerification: ${PROXY_DISABLE_SSL_VERIFICATION:false}The application uses YAML-based mapping configurations to define API transformations. See server/src/main/resources/mapping/sample_mapping.yaml for examples.
GET /health- Health check endpointGET /- Redirects to Swagger documentationPOST /{...}- Dynamic routing for all API transformations
The application supports dynamic routing where any POST request to any path will be processed based on the mapping configuration. The system automatically:
- Extracts request metadata (path, method, content type, SOAP action)
- Matches against configured mappings
- Transforms request data using defined schemas and transformation rules
- Forwards to target API
- Transforms response data back to client format
- Returns transformed response
Wright Server provides a comprehensive set of built-in transformation functions:
RSADecrypt(cipherText)- RSA decryptionAESEncrypt(plainText)- AES encryption
toString(value)- Convert to stringtoInt(value)- Convert to integertoDouble(value)- Convert to doubletoBool(value)- Convert to boolean
toUpper(value)/toLower(value)- Case conversiontakeLast6(value)- Extract last 6 charactersfirstName(fullName)/lastName(fullName)- Name parsinglen(value)- String length
sum(value1, value2, ...)- Additionsubtract(value1, value2, ...)- Subtraction
formatDate(source, inputFormat, outputFormat)- Date formattingtimeDiff(field1, field2, dateFormat)- Time difference calculation
takeIf(expression, trueValue, falseValue)- Conditional valuesexp(expression)- Expression evaluation
toISOAmountFormat(amount)- Currency formatting
wright-server-ktor/
├── server/ # Main Ktor application
│ ├── src/main/kotlin/
│ │ ├── Application.kt # Application entry point
│ │ ├── config/ # Configuration management
│ │ ├── core/ # Core mapping and transformation logic
│ │ ├── domain/ # Domain models
│ │ ├── model/ # Data models
│ │ ├── service/ # Business logic services
│ │ └── utils/ # Utility functions
│ └── src/main/resources/
│ ├── application.yaml
│ └── mapping/ # Mapping configurations
├── core/ # Shared core library
├── client/ # HTTP client library
└── docker-compose.yml # Docker configuration
# Build all modules
./gradlew build
# Run tests
./gradlew test
# Run specific module tests
./gradlew :server:test
# Build Docker image
docker build -t wright-server-ktor .The application is fully instrumented with OpenTelemetry for:
- Distributed tracing across service boundaries
- Span correlation with request/response cycles
- Custom span naming for better Jaeger filtering
- Context propagation for end-to-end tracing
- Structured logging with SLF4J
- MDC correlation with trace IDs
- Configurable log levels and body logging
- Sensitive data masking options
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the terms specified in the LICENSE file.
For questions, issues, or contributions, please refer to the project's issue tracker or contact the development team.