-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
405 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
--- | ||
outline: deep | ||
title: Start a project | ||
description: Let's learn how to execute a project using Gen-G | ||
--- | ||
|
||
# How to use? | ||
|
||
## Folder Structure of the project | ||
|
||
```bash | ||
. | ||
├── README.md | ||
├── bootstrap | ||
│ ├── app.go | ||
│ └── module.go | ||
├── console | ||
│ ├── commands | ||
│ │ ├── migration.go | ||
│ │ ├── random.go | ||
│ │ ├── seed.go | ||
│ │ └── serve.go | ||
│ └── console.go | ||
├── docker | ||
│ ├── custom.cnf | ||
│ ├── db.Dockerfile | ||
│ ├── run.sh | ||
│ └── web.Dockerfile | ||
├── docker-compose.yml | ||
├── domain | ||
│ ├── dtos | ||
│ │ └── hello.dto.go | ||
│ ├── hello | ||
│ │ ├── hello.controller.go | ||
│ │ ├── hello.module.go | ||
│ │ ├── hello.repository.go | ||
│ │ ├── hello.route.go | ||
│ │ └── hello.service.go | ||
│ ├── middlewares | ||
│ │ └── module.go | ||
│ ├── models | ||
│ │ └── hello.model.go | ||
│ └── module.go | ||
├── go.mod | ||
├── go.sum | ||
├── main.go | ||
├── migrations | ||
│ ├── hello.go | ||
│ ├── migrator.go | ||
│ └── module.go | ||
├── pkg | ||
│ ├── framework | ||
│ │ ├── command.go | ||
│ │ ├── constants.go | ||
│ │ ├── env.go | ||
│ │ ├── logger.go | ||
│ │ ├── migration.go | ||
│ │ ├── module.go | ||
│ │ └── seed.go | ||
│ ├── infrastructure | ||
│ │ ├── module.go | ||
│ │ └── router.go | ||
│ ├── middlewares | ||
│ │ ├── command.go | ||
│ │ ├── module.go | ||
│ │ └── rate_limitter.go | ||
│ ├── module.go | ||
│ ├── responses | ||
│ │ └── response.go | ||
│ ├── services | ||
│ │ └── module.go | ||
│ └── utils | ||
│ ├── aws_error.go | ||
│ └── functional_programming.go | ||
└── seeds | ||
├── hello.go | ||
├── module.go | ||
└── seeder.go | ||
|
||
19 directories, 48 files | ||
``` | ||
|
||
## Folder Structure :file_folder: | ||
|
||
| Folder Path | Description | | ||
| -------------------------------- | ------------------------------------------------------------------------------------------------------------ | | ||
| `/bootstrap` | contains modules required to start the application | | ||
| `/console` | server commands, run `go run main.go -help` for all the available server commands | | ||
| `/docker` | `docker` files required for `docker compose` | | ||
| `/domain` | contains dtos, models, constants and folder for each domain with controller, repository, routes and services | | ||
| `/domain/constants` | global application constants | | ||
| `/domain/models` | ORM models | | ||
| `/domain/<name>` | controller, repository, routes and service for a `domain`. In this template `user` is a domain | | ||
| `/pkg` | contains setup for api_errors, infrastructure, middlewares, external services, utils | | ||
| `/pkg/api-errors` | server error handlers | | ||
| `/pkg/framework` | contains env parser, logger... | | ||
| `/pkg/infrastructure` | third-party services connections like `gmail`, `firebase`, `s3-bucket`, ... | | ||
| `/pkg/middlewares` | all middlewares used in the app | | ||
| `/pkg/responses` | different types of http responses are defined here | | ||
| `/pkg/services` | service layers, contains the functionality that compounds the core of the application | | ||
| `/pkg/types` | data types used throught the application | | ||
| `/pkg/utils` | global utility/helper functions | | ||
| `/seeds` | seeds for already migrated tables | | ||
| `/tests` | includes application tests | | ||
| `.env.example` | sample environment variables | | ||
| `dbconfig.yml` | database configuration file for `sql-migrate` command | | ||
| `docker-compose.yml` | `docker compose` file for service application via `Docker` | | ||
| `main.go` | entry-point of the server | | ||
| `Makefile` | stores frequently used commands; can be invoked using `make` command | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
outline: deep | ||
title: Scaffold a project | ||
description: Let's learn how to generate a project using Gen-G | ||
--- | ||
|
||
# How to use? | ||
|
||
## Generate a project using config | ||
|
||
Instead of using the following command. | ||
```bash | ||
geng new | ||
``` | ||
|
||
- Create a `geng.json` file which can contain following value: | ||
```jsonc | ||
{ | ||
"projectName": "todo app", | ||
"projectModuleName": "github.com/mukezhz/todo", | ||
"author": "Mukesh Kumar Chaudhary <[email protected]>", | ||
"projectDescription": "A simple todo project", | ||
"goVersion": "1.21" | ||
// "directory": ".", | ||
// "infrastructureName": [], | ||
// "serviceName": [] | ||
} | ||
``` | ||
|
||
Now enter the project generation command. | ||
```bash | ||
geng new | ||
``` | ||
|
||
You will get the similar output: | ||
```bash | ||
|
||
GENG: GENERATE GOLANG PROJECT | ||
|
||
██████╗ ███████╗███╗ ██╗ ██████╗ | ||
██╔════╝ ██╔════╝████╗ ██║ ██╔════╝ | ||
██║ ███╗█████╗ ██╔██╗ ██║█████╗██║ ███╗ | ||
██║ ██║██╔══╝ ██║╚██╗██║╚════╝██║ ██║ | ||
╚██████╔╝███████╗██║ ╚████║ ╚██████╔╝ | ||
╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝ | ||
|
||
|
||
|
||
The information you have provided: | ||
|
||
Project Name 💻: Todo App | ||
Project Module 📂: github.com/mukezhz/todo | ||
Project Description 📚: A simple todo project | ||
Go Version 🆚: 1.21 | ||
Author Detail 🤓: Mukesh Kumar Chaudhary <[email protected]> | ||
|
||
💻 Change directory to project: | ||
cd todo_app | ||
|
||
💾 Initalize git repository: | ||
git init | ||
|
||
📚 Sync dependencies: | ||
go mod tidy | ||
|
||
🕵 Copy .env.example to .env: | ||
cp .env.example .env | ||
|
||
🏃 Start Project 🏃: | ||
go run main.go app:serve | ||
|
||
Thank You For using 🙏🇳🇵🙏: | ||
``` | ||
|
||
**Note:** I have filled the project description, author name and go version. | ||
|
||
:tada: Now follow the instruction and run the project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
--- | ||
outline: deep | ||
title: Scaffold a project | ||
description: Let's learn how to generate a project using Gen-G | ||
--- | ||
|
||
# How to use? | ||
|
||
## Generate a project | ||
|
||
In order to generate a project you need to enter the following command: | ||
```bash | ||
geng new | ||
``` | ||
|
||
Once you enter the command it will ask you bunch of questions. | ||
|
||
- To enter Project Name * | ||
![enter project name](./enter-project-name.png) | ||
- To enter Project Module * | ||
![enter go module name](./enter-go-module-name.png) | ||
- To enter Author Detail [Optional] | ||
![author detail](./enter-author-detail.png) | ||
- To enter Project Description [Optional] | ||
![project description](./enter-project-description.png) | ||
- To enter Go Version [Optional] | ||
![go version](./enter-go-version.png) | ||
- To enter Project Directory [Optional] | ||
![project directory](./enter-project-directory.png) | ||
- To Select the infrastructure? **Use Space key to Select** [Optional] | ||
![select infrastructure](./select-infrastructure.png) | ||
|
||
### After filling all question you will get following output | ||
```bash | ||
|
||
GENG: GENERATE GOLANG PROJECT | ||
|
||
██████╗ ███████╗███╗ ██╗ ██████╗ | ||
██╔════╝ ██╔════╝████╗ ██║ ██╔════╝ | ||
██║ ███╗█████╗ ██╔██╗ ██║█████╗██║ ███╗ | ||
██║ ██║██╔══╝ ██║╚██╗██║╚════╝██║ ██║ | ||
╚██████╔╝███████╗██║ ╚████║ ╚██████╔╝ | ||
╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝ | ||
|
||
|
||
|
||
The information you have provided: | ||
|
||
Project Name 💻: Todo App | ||
Project Module 📂: github.com/mukezhz/todo | ||
Project Description 📚: | ||
Go Version 🆚: 1.20 | ||
Author Detail 🤓: | ||
|
||
💻 Change directory to project: | ||
cd todo_app | ||
|
||
💾 Initalize git repository: | ||
git init | ||
|
||
📚 Sync dependencies: | ||
go mod tidy | ||
|
||
🕵 Copy .env.example to .env: | ||
cp .env.example .env | ||
|
||
🏃 Start Project 🏃: | ||
go run main.go app:serve | ||
|
||
Thank You For using 🙏🇳🇵🙏: | ||
``` | ||
|
||
### Entered value | ||
|
||
Here I have entered the following value: | ||
1. project name: todo app | ||
2. go module name: github.com/mukezhz/todo | ||
3. author detail: [just pressed enter ie. empty] | ||
4. project description: [just pressed enter ie. empty] | ||
5. go version: [just pressed enter ie. empty] | ||
6. project directory: [just pressed enter ie. empty] | ||
7. select infrastructure: [just pressed enter ie. empty] | ||
|
||
**Note:** You can fill the optional value | ||
|
||
:tada: Now follow the instruction and run the project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.