Giter VIP home page Giter VIP logo

modelgen's Introduction

modelgen

CircleCI Status GoDoc Go Report Card Build Status CircleCI Status standar-readme compliant

Application to create (start app) go webservice with 3-Tier Architecture.

The Generated Application includes :-

  • Go mod
  • Configuration file
  • Dockerfile
  • DAL,BLL,DTO,API and API_Tests for every Database Table
  • Compatible with mysql postgres mssql sqlite oracle
  • Using GORM as ORM

Installation

$ go get -u github.com/tarekbadrshalaan/modelgen
$ vi config.json
  
  {
    "AppName"               :   "Application",
    "Module"                :   "{{github.com/packagepath}}",
    "DBConnectionString"    :   "{{Database ConnectionString}}",
    "DBEngine"              :   "{{Database Engine}}",
    "WebAddress"            :   "0.0.0.0",
    "WebPort"               :   7070
  }

$ modelgen 
$ cd Application/
$ go build .
  go: finding github.com/tarekbadrshalaan/goStuff/configuration latest
  go: finding github.com/jinzhu/inflection latest
$ ./Application

Example

pg_restore -U postgres -d dvdrental ~/dvdrental.tar
  • Run postgres into docker container:
# run the container
- docker run --rm -it --name pg -p 5454:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -e POSTGRES_DB=dvdrental -v $(pwd):/mydata postgres

# open the pg container shell command
- docker exec -it pg bash

# restore the database
- cd mydata
- pg_restore -U postgres -d dvdrental dvdrental.tar

# review the data in postgres
- psql -h localhost -U postgres
- \c dvdrental;
- select * from actor;
  • Run pgadmin4 into docker container:
# run the container
docker run --rm -it -p 5151:80 --name=pnl -e "[email protected]" -e "PGADMIN_DEFAULT_PASSWORD=admin" dpage/pgadmin4

# open pgadmin4 in browser
http://localhost:5151

# login
email: [email protected]
pass: admin

# register - server
- Name: {pick any name}
- Host: 172.17.0.1 {or use docker inspect}
  $ docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container-ID>
- port: 5454
- DB=dvdrental
- user: postgres
- pass: postgres
  • Run the application.
$ vi config.json
  {
    "AppName"               :   "Application",
    "Module"                :   "github.com/Application",
    "DBConnectionString"    :   "host=127.0.0.1 port=5432 user=postgres password=postgres dbname=dvdrental sslmode=disable",
    "DBEngine"              :   "postgres",
    "WebAddress"            :   "0.0.0.0",
    "WebPort"               :   7070
  }
  
$ modelgen 
$ cd Application/
  ├──> Application
    ├──> config.json
    ├──> go.mod 
    ├──> main.go
    ├──> Dockerfile
    db
    │	├──> database.go
    api
    │	├──> ActorAPI.go
    │ ...
    bll
    │	├──> ActorBLL.go
    │ ...
    dal
    │	├──> ActorDAL.go
    │ ...
    dto
    │	├──> ActorDTO.go
    │ ...
    test
    │	├──> Actor_test.go
    │ ...
    │	├──> test.json
    ─────────────────────────────

Docker

# build docker image
docker build -t concept-api .
# run docker container 
docker run --rm -it -p 7070:7070 --env-file .env --network host concept-api

Concept

  • in standard you can find the expected result of the generator.

Contributing

PRs accepted.

License

License: MIT

modelgen's People

Contributors

tarekbadrshalaan avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.