How psmri/amrit-db works
Project type and purpose
• This is a backend‐only Spring Boot microservice whose sole responsibility is to manage and run Flyway database migrations across multiple schemas.
• It has no frontend/UI layers; it exposes a minimal REST API (e.g., a VersionController) and runs automatically at startup.
File structure
• Top‐level build and CI files: pom.xml, mvnw, GitHub workflows.
• src/main/java: Spring Boot application entry point, config packages, controller, service, data model.
• src/main/resources/db/migration: four schema subfolders containing versioned SQL scripts.
• src/main/environment: environment‐specific property templates.
• src/test: basic SpringBootTest.
Extract key points from the README
• Uses Java 17, Maven 3.6+, MySQL 8.
• Four mandatory databases: db_iemr, db_reporting, db_identity, db_1097_identity.
• Flyway handles schema versioning and migration at startup.
• CI pipelines include build on PR, packaging, SAST checks.
Main components
a. AMRIT-DB Spring Boot Application (single deployable JAR)
• Subcomponents:
• Application Core (AmritDbApplication, ServletInitializer)
• Configuration Layer (DatasourceConfig, FlywayConfig, JdbcTemplateConfig, FlywayMigrator)
• Service Layer (VersionService)
• Controller Layer (VersionController)
• Data Layer (FlywaySchemaVersion model, JdbcTemplate integration)
b. Database Server (MySQL instance)
• Four logical schemas: db_iemr, db_reporting, db_identity, db_1097_identity
c. Flyway Migration Scripts
• Organized under src/main/resources/db/migration/<schema>/V*.sql
d. External Systems/Tools
• GitHub Actions CI pipelines
• Developers’ local IDE and Maven build
• Swagger UI (runtime endpoint)
Relationships & data flows
• On startup, Spring Boot loads application.properties + environment overrides → initializes DataSource beans → triggers FlywayConfig → FlywayMigrator reads migration scripts for each schema → applies pending migrations to MySQL schemas.
• VersionController → VersionService → JdbcTemplate queries flyway_schema_history.
• CI pipelines run mvn clean install → package → run tests → SAST → (optionally) deploy artifact.
Architectural patterns & principles
• Layered (Controller → Service → Data).
• Configuration‐first approach (externalize properties per environment).
• Convention-based migration (Flyway folder structure and naming).
• Single‐responsibility microservice (DB schema management only).
Details
• Maven wrapper and pom.xml as inputs to the CI build.
• Swagger UI endpoint as optional runtime interface.