Skip to content

Vipin-Sharma/MSG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MSG - Microservice Generator

Code Quality & Metrics

Quality Gate Status Coverage Maintainability Rating Reliability Rating Security Rating Duplicated Lines (%)

Click badges for detailed analysis and metrics on SonarCloud

From SQL to Service - Eliminating microservices boilerplate, one API at a time πŸš€

MSG transforms a single SQL statement into a complete, production-ready Spring Boot microservice with REST APIs, DTOs, DAOs, and configuration in seconds.

🎯 What is MSG?

Modern microservices development involves repetitive boilerplate code creation. MSG eliminates this by generating complete Spring Boot microservices directly from SQL statements using a metadata-driven approach.

Core Capabilities

  • SELECT β†’ GET APIs with query parameters
  • INSERT β†’ POST APIs with validated request bodies
  • UPDATE β†’ PUT APIs with path variables and request bodies
  • DELETE β†’ DELETE APIs with query parameters
  • Complete Projects β†’ Maven structure, dependencies, and configuration

Key Differentiators

  • Metadata-driven: Uses database metadata, not SQL parsing
  • Type-safe: Generates strongly-typed DTOs with validation
  • Production-ready: Includes error handling and proper HTTP semantics
  • Enterprise standards: Follows Spring Boot and clean code conventions

πŸš€ Quick Start

Prerequisites

  • Java 21 or later
  • Maven 3.8+
  • SQL Server database
  • Docker (recommended for database setup)

1. Database Setup (One Command)

# Linux/Mac
./setup-db.sh

# Windows  
setup-db.bat

# Manual
docker-compose up -d --build

This sets up SQL Server with sample Sakila database (599 customers, 1000 films, 16k+ rentals).

2. Generate Your First Microservice

# Clone and compile
git clone <repository-url>
cd MSG
mvn clean compile

# Generate SELECT API
mvn exec:java -Dexec.mainClass="com.jfeatures.msg.codegen.MicroServiceGenerator" \
  -Dexec.args="--name Customer --destination ./output --sql-file sample_parameterized_sql.sql"

# Test the generated service
cd ./output
mvn spring-boot:run

3. Test Your API

# Test GET endpoint
curl "http://localhost:8080/api/customer?active=Y&customerId=123"

πŸ”§ Core Commands

Generate All CRUD Operations

# SELECT API (GET endpoints)
mvn exec:java -Dexec.mainClass="com.jfeatures.msg.codegen.MicroServiceGenerator" \
  -Dexec.args="--name Customer --destination ./output --sql-file sample_parameterized_sql.sql"

# INSERT API (POST endpoints)  
mvn exec:java -Dexec.mainClass="com.jfeatures.msg.codegen.MicroServiceGenerator" \
  -Dexec.args="--name Customer --destination ./output --sql-file sample_insert_parameterized.sql"

# UPDATE API (PUT endpoints)
mvn exec:java -Dexec.mainClass="com.jfeatures.msg.codegen.MicroServiceGenerator" \
  -Dexec.args="--name Customer --destination ./output --sql-file sample_update_parameterized.sql"

# DELETE API (DELETE endpoints)
mvn exec:java -Dexec.mainClass="com.jfeatures.msg.codegen.MicroServiceGenerator" \
  -Dexec.args="--name Customer --destination ./output --sql-file sample_delete_parameterized.sql"

πŸ“ SQL File Requirements

Place SQL files in src/main/resources/ with parameterized queries:

-- sample_parameterized_sql.sql (SELECT)
SELECT c.customer_id, c.first_name, c.last_name 
FROM customer c 
WHERE c.active = ? AND c.created_date >= ?

-- sample_insert_parameterized.sql (INSERT)  
INSERT INTO customer (first_name, last_name, email) 
VALUES (?, ?, ?)

-- sample_update_parameterized.sql (UPDATE)
UPDATE customer SET first_name = ?, email = ? 
WHERE customer_id = ?

-- sample_delete_parameterized.sql (DELETE)
DELETE FROM customer WHERE customer_id = ? AND active = ?

πŸ—οΈ Generated Code Structure

generated-microservice/
β”œβ”€β”€ pom.xml
β”œβ”€β”€ src/main/java/com/jfeatures/msg/{domain}/
β”‚   β”œβ”€β”€ Application.java
β”‚   β”œβ”€β”€ controller/{Domain}Controller.java
β”‚   β”œβ”€β”€ dao/{Domain}DAO.java  
β”‚   β”œβ”€β”€ dto/{Domain}DTO.java
β”‚   └── config/DatabaseConfig.java
└── src/main/resources/application.properties

πŸ“– Documentation

πŸŽ‰ Success Stories

MSG transforms microservices development by:

  • 90% Less Boilerplate: Eliminates repetitive CRUD code writing
  • Type-Safe APIs: Generates strongly-typed DTOs and controllers
  • Production Ready: Includes validation, error handling, and proper HTTP semantics
  • Rapid Prototyping: From SQL to running service in minutes

πŸ‘₯ Contributing

We welcome contributions! Please see our Developer Guide for:

  • Development setup and workflow
  • Architecture overview and design principles
  • Adding new features and SQL statement types
  • Code standards and pull request process

πŸ“ License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.


Created with clean code principles and architectural excellence in mind.

MSG - Building the future of microservices generation πŸš€

About

MicroService Generator

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6

Languages