Skip to content

Vipin-Sharma/MSG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MSG (Microservice Generator) sonar status build status

Key tech used:

  • Java 18

  • JSQLParser

  • JavaPoet

Usages Instructions

Provide input to the program as follows:

  1. Add your SQL into resources directory file name: sample_sql.sql. Sometimes we need to hardcode some values in SQL, for that we can use syntax like: sql SELECT * FROM table WHERE country = 'HARDCODE_AS_STRING{India}' and customer_id = 'HARDCODE_AS_{300}' and first_name = 'John' Here we have hardcoded country as India, customer_id as 300. first_name will be passed as parameter to the rest API. first_name will be replaced with first_name = ? in SQL.

  2. Add your DDLs into resources directory file name: sample_ddl.sql

  3. In java file name: MicroserviceGenerator.java update variable businessPurposeOfSQL with the business purpose of API that you want to generate.

*In case you want to try this out you can use existing SQL and DDLs, no need to make any changes anywhere, just run the program MicroserviceGenerator.java and generate Spring boot microservice, this is explained in next section. To test the generated Rest API you need database which can be setup from instruction given at .dev/README.md*

Building the application from source

Run the following command to generate a runnable jar:

mvn package

A jar named MSG-1.0-SNAPSHOT.jar will be generated in the target directory.

Generating the microservice application:

There are two ways you can run MSG:

  1. From sources with Maven:

    mvn spring-boot:run -Dspring-boot.run.arguments="--destination /tmp/test"
  2. Running the jar:

    java -jar MSG-1.0-SNAPSHOT.jar --destination /tmp/test

Run MSG to generate the microservice application. The microservice application will be generated in the destination defined in the command line, or in the user home directory in case the destination is not defined.

User home for 3 Major OS:

  • Windows: C:\Users\[username]

  • Linux: /home/[username]

  • Mac: /Users/[username]

At the end of program execution, you will see the message having directory path of generated spring boot application. e.g.

Generated spring boot application is available at: /Users/nitinkumarsharma/BusinessData

Running and testing the generated spring boot application.

  1. cd /home/<user>/<project-name>

  2. mvn clean package spring-boot:run

Limitations:

  1. TODO This is tested against MS SQL Server, need to add support for other databases, it should be straightforward, just add files Similar to SQLServerDataTypeEnum for other databases and code should be able to understand DB type when we start the application to choose correct DB specific Enum class.

  2. TODO: Schema name is ignored in ReadDDL class so Table names should be unique across all schemas. This is a limitation right now, should be fixed.

  3. TODO: Table name is case-sensitive right now, ddl file and SQL should have same case, should be fixed.

  4. TODO Add support for aggregate functions in select clause is not available.

  5. WIP Need to add support for all data types and write tests.

Here is the list of features that new contributor can help:

Project specific code conventions:

TODO

Benefits

  1. Boost Dev Productivity #nocode.

  2. Reduce time spent on writing code.

  3. Reduce time spent on writing tests.

  4. Reduce time spent on writing documentation.

  5. Reduce time spent on writing code review.

  6. Bug free code, no time wasted on bug fixing. Study shows that debugging take more time than writing code.

About

MicroService Generator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages