Universal relational database metadata extractor built with Spring Boot and Clean Architecture.
This project provides a REST service that connects to relational databases, extracts metadata objects (tables, views, indexes, stored procedures, functions, sequences), and generates DDL scripts organized by schema.
- Supports PostgreSQL, Oracle, SQL Server, Azure SQL Server, MariaDB
- HTTP Basic Authentication for secure credential handling
- Schema and object type filtering
- Clean Architecture for maintainability and testability
- OpenAPI documentation via Swagger UI
- Configurable output directory structure
The project follows Clean Architecture with four layers:
- Domain: Core business entities and value objects
- Application: Use cases and port interfaces
- Infrastructure: Database-specific implementations and file system writer
- Interface Adapters: REST controllers, DTOs, security, and exception handlers
- Java 21
- Maven 3.8+
mvn clean compilemvn spring-boot:runThe application will start on port 8080. Swagger UI will be available at http://localhost:8081/swagger-ui.html.
Send a POST request to /api/extract with Basic Authentication header and JSON body:
{
"dbType": "postgresql",
"host": "localhost",
"port": 5432,
"database": "testdb",
"projectDir": "/tmp/output",
"schemas": ["public"],
"objectTypes": ["tables", "views"]
}src/main/java/pe/openstrategy/databaseproject/
├── domain/ # Core business models
├── application/ # Use cases and ports
├── infrastructure/ # Database and file system implementations
└── interfaceadapters/ # Web controllers and DTOs
- Implement
DatabaseMetadataExtractorinterface ininfrastructure/database/<engine>/ - Add JDBC driver dependency to
pom.xml - Register the implementation via configuration
Run unit tests:
mvn testIntegration tests require Testcontainers and will spin up actual database instances.
See src/main/resources/application.yml for configuration options.
- Credentials are transmitted via HTTP Basic Authentication (Base64 encoded)
- Authorization headers are never logged
- Input validation prevents injection attacks
- Error messages do not expose internal details
Internal use only.