3.7 KiB
3.7 KiB
API Gateway Consolidation Plan
This document outlines the plan for consolidating the duplicate directory structure in the api-gateway module, specifically merging the src/main and src/jvmMain directories.
1. File Analysis
1.1 Duplicate Files
The following files exist in both directories:
| File | Action | Reasoning |
|---|---|---|
| Application.kt | Merge into src/jvmMain | src/jvmMain version has better configuration handling, but src/main has more complete module setup |
| config/AuthorizationConfig.kt | Keep src/jvmMain version | Assuming identical content |
| config/DatabaseConfig.kt | Keep src/jvmMain version | Assuming identical content |
| config/MonitoringConfig.kt | Keep src/jvmMain version | Confirmed identical content |
| config/OpenApiConfig.kt | Keep src/jvmMain version | Assuming identical content |
| config/SecurityConfig.kt | Keep src/jvmMain version | Assuming identical content |
| config/SerializationConfig.kt | Keep src/jvmMain version | Assuming identical content |
| routing/AuthRoutes.kt | Keep src/jvmMain version | Assuming identical content |
1.2 Files Unique to src/main
The following files exist only in src/main:
| File | Action | Reasoning |
|---|---|---|
| auth/AuthorizationHelper.kt | Move to src/jvmMain | Contains important authorization functionality not present in src/jvmMain |
| routing/RoutingConfig.kt | Move to src/jvmMain | Contains critical routing configuration not present in src/jvmMain |
| config/configureSwagger.kt | Check if needed | Not referenced in src/jvmMain, but referenced in src/main Application.kt |
1.3 Files Unique to src/jvmMain
The following files exist only in src/jvmMain:
| File | Action | Reasoning |
|---|---|---|
| auth/ApiKeyAuth.kt | Keep | Provides API key authentication |
| auth/JwtAuth.kt | Keep and enhance | Provides JWT authentication, but should be enhanced with functionality from AuthorizationHelper.kt |
| config/MigrationSetup.kt | Keep | Handles database migrations |
| migrations/* (4 files) | Keep | Handle migrations for different contexts |
| module.kt | Merge with Application.kt | Contains module definition but needs to be enhanced with functionality from src/main |
| validation/RequestValidator.kt | Keep | Provides request validation |
2. Implementation Steps
2.1 Merge Application.kt and module.kt
- Start with the src/jvmMain Application.kt
- Incorporate the module configuration from src/main Application.kt
- Ensure all necessary components are configured:
- Database
- Serialization
- Monitoring
- Security
- OpenAPI/Swagger
- Routing
2.2 Move Unique Files from src/main to src/jvmMain
- Move AuthorizationHelper.kt to src/jvmMain/kotlin/at/mocode/gateway/auth/
- Move RoutingConfig.kt to src/jvmMain/kotlin/at/mocode/gateway/routing/
- Check if configureSwagger.kt is needed and move if necessary
2.3 Update References
- Update imports in all files to reflect the new structure
- Ensure all configuration functions are called in the module function
2.4 Remove src/main Directory
After all files have been consolidated and the application has been verified to work correctly, remove the src/main directory.
3. Testing
After consolidation, the following tests should be performed:
- Build the project to ensure there are no compilation errors
- Run the application to ensure it starts correctly
- Test key functionality to ensure it works as expected:
- Authentication
- Authorization
- API endpoints
- Database operations
4. Documentation Update
Update the project documentation to reflect the new structure:
- Update README.md if it references the old structure
- Update any other documentation that mentions the directory structure