Gong
Example of a generated application with gong
About Gong
Gong is about making fullstack development more fun and less boring.
What is fun and boring in full stack development ?
- Fun stuff:
- business logic and gui design.
- Boring stuff:
- database structure/access
- API controllers
- standard Angular Material Components
- documentation with UML diagrams
- Very boring stuff:
- maintaining boring stuff
Gong is a set of 2 compilers:
gongc
, a compiler that compiles the business logic written ingo
, extracts some elements in agong
language and generates the boring stuff ingo
andng
.gongdoc
, a compiler that generates the UML documentation, a web site to view UML diagrams fromgong
code (the subset ofgo
that is understood bgongc
).gongdoc
is similar togodoc
in its functionning ad also generatessvg
files from the diagram definition.
Gong stands for "go
+ ng
", a go backend and an angular frontend.
Prerequisite
All elements below are mandatory but vscode.
Go
gong has been tested with go version above 1.15
Swagger
swagger is a go program is used after each gongc
compilation to generate the project API in a yml
file.
It is mandatory to install it. On mac/linux, One way is
dir=$(mktemp -d)
git clone https://github.com/go-swagger/go-swagger "$dir"
cd "$dir"
go install ./cmd/swagger
on windows with powershell, creates and go into go-swagger
git clone https://github.com/go-swagger/go-swagger
go install ./go-swagger/cmd/swagger
setting up the path for swagger
on mac/linux
export PATH=$PATH:$(go env GOPATH)/bin:$HOME/go/bin
Angular
The ng
command is used by different gong programs.
npm install -g @angular/cli
Vscode
Vscode is usefull is handy because the tasks definitionq and debug configuration related to gong are provided in the repository.
No makefile is provided.
Description of a gong application
A go package (for instance <path>/go/models
) written following the gong
langage constraints can be compiled by the gongc
compiler into a stack of integrated components:
- a set of
go
packages for the backend - an
angular
library for the front end.
This stack can be packaged into a reusable gong
library to be used in another full stack developpemnent (a bookstore example is provided in the repository).
-
a
<path>/go/orm
package, leveraging gorm, the fantastic go ORM, for the persistance into GORM supported database (sqlite3 in memory, sqlite3 file, postgres, ...) -
a
<path>/go/controllers
package, leveraging the gin framework, an HTTP web framework written in Go (Golang) -
a
<path>/go/controllers/<path>.yaml
open api 2.0 interface definition (thks to go-swagger), it provides a RESTful interface for developing and consuming an API of the gong package -
a
<path>/ng/projects/<path>
angular service library for accessing gong object with some an angular material library with commonly used material components: table, editor, presentation, splitter presentation, arborescence presentation
if a gong variable data is created on the backend, a constraint is to register all instances on a store.
Bookstre, a gong application "Hello World!"
Bookstore is a simple fullstack application. most of its code is generated by gong
The bookstore code architecture is as follow.
go/ (the application backend, in go)
go.mod (file created by the command
`go mod init github.com/thomaspeugeot/gong/examples/bookstore/go`)
go.sum (idem)
docs.go (Descrption of the module, a boring part, generated by gongc)
cmd/ (a fun part, hand written by the programmer)
main.go (the backend logic)
models/ (fun part, hand written by the programmer, parsed by gongc)
Area.go (contains struct Area)
Editor.go (contains struct Editor)
Book.go (contains struct Book)
controllers/ (boring part, all generated by gongc, ...
... based on the gin framework)
bookstoreapi.yml (the description of the api, usefull for tests with Postman or openapi...
... is used by openapi generator to generate api controllers ...)
errors.go (controllers error codes)
Area.go (controller for struct Area)
Editor.go (controller for struct Editor)
Book.go (controller for struct Book)
orm/ (boring part, all generated by gong ...
... based on the gorm framework)
Area.go (orm for struct Area)
Editor.go (orm for struct Editor)
Book.go (orm for struct Book)
setup.go (setup of the connection to the sqllite3 db)
ng/ (the application front end, in angular ...
... this directory was created by `ng new ng`)
projects/bookstore/src/ (the boring parts, ng material components generated by gongc)
area-adder/
areas-tables/
books-table/
book-adder/
...... (misc. files generated by gongc)
src/app
app.component.html (the fun part)
Gong elements
The gong langage
Here a svg of the gong langage s sbset of go
A gong stack
All the elements of gong stack