karsto / glew

A glorified project generator. Give it some models, out comes a low level api and vue admin ui.
0 stars 0 forks source link

glew

time tracker

glew is a (in development / unstable) rapid prototyping and development tool, used to create starter web boiler-plate projects with CRUD+ functionality. The goal is to be able to create a set of convention following models, feed it to glew, and have developer friendly flexible starter code ready produced. Its basically a glorified project template that makes some assumptions and 3rd party library choices to provide more functionality. It's designed to be a best practices basic starting point REST api generator.

The basic functionality out of the box:

For each model set provided a "feature" will be created. Each Feature has the following functionality:

Why

Library Choices

glew relies heavily on 3rd party libraries for abstracting code and is mostly glue code between the libraries. Most of the applications data specific functionality is driven by the struct via tags.

These are the primary dependencies and what they are responsible for:

Library Handles
gin base web framework
validator input validation
sqlx sql interface
pgx postgres driver
rql dynamic web queries
swag swagger generator
migrate db migration
viper configuration
cobra cli
ladon authorization
authboss authentication
vue.js base ui framework
vue-router ui router
vee-validate ui inline validation
vuex ui state store
bulma base css framework
buefy buefy + bulma components

Limitations

Repo Structure

Output Application Structure

The product of this application is a cli project folder with the following layout:

Getting Started

You can run glew in two ways, in code or as a cli.

Cli

touch models.go

git clone https://github.com/kartso/glew.git
go install
glew

In code

type TestModel struct {
    StringField string    `db:"string_field" json:"stringField"`
    NumField    int       `db:"num_field" json:"numField"`
    ID          int       `db:"id" json:"id"`
    Code        string    `db:"code" json:"code"`
    TimeField   time.Time `db:"time_field" json:"timeField"`
}
type CreateTestModel struct {
    StringField string    `db:"string_field" json:"stringField"`
    NumField    int       `db:"num_field" json:"numField"`
    ID          int       `db:"id" json:"id"`
    Code        string    `db:"code" json:"code"`
    TimeField   time.Time `db:"time_field" json:"timeField"`
}
type UpdateTestModel struct {
    StringField string    `db:"string_field" json:"stringField"`
    NumField    int       `db:"num_field" json:"numField"`
    ID          int       `db:"id" json:"id"`
    Code        string    `db:"code" json:"code"`
    TimeField   time.Time `db:"time_field" json:"timeField"`
}

func main() {
    /*
        CONFIG
        destDir - the output directory from this run
        appName - the name of the application and docker runtime
        importPath - application go import directory, aka the directory of the app to reference itself
    */
    app := pkg.NewApp(pkg.Frontend{}, pkg.Backend{}, pkg.DB{})

    destDir := "out"
    appName := "testApp"
    importPath := "github.com/karsto/glew/out"

    verticals := []pkg.VerticalMeta{}

    vertical, _ := app.GenerateVerticalMeta(TestModel{}, "TestVertical", CreateTestModel{}, UpdateTestModel{})

    verticals = append(verticals, vertical)

    ctx := pkg.BaseAPPCTX{
        ImportPath: importPath,
    }

    features := pkg.NewConfig()
    files, _ := app.GenerateApp(features, destDir, appName, verticals, ctx)

    err = pkg.WriteFiles(files, destDir)
    if err != nil {
        panic(err)
    }

Model Definitions

TODO: