Skip to content

Commit

Permalink
feat: add docs of project scaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
mukezhz committed Jul 8, 2024
1 parent b8e223f commit 4d62ffb
Show file tree
Hide file tree
Showing 16 changed files with 405 additions and 8 deletions.
11 changes: 10 additions & 1 deletion docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineConfig, HeadConfig } from "vitepress";

// https://vitepress.dev/reference/site-config
export default defineConfig({

title: "GENG",
description: "A tool to generate golang web project.",
themeConfig: {
Expand All @@ -25,7 +26,15 @@ export default defineConfig({
collapsed: false,
items: [
{ text: "How to use?", link: "/how-to-use" },
// { text: "Getting Started", link: "/getting-started" },
{ text: "Generate a project", link: "/generate-project" },
{ text: "Generate a project using config", link: "/generate-project-config" },
{ text: "Start the project", link: "/start-project" },
{ text: "Project Folder structure", link: "/folder-structure" },
{ text: "Generate a module", link: "/generate-module" },
{
text: "Generate a infrastructure",
link: "/generate-infrastructure",
},
],
},
{
Expand Down
Binary file added docs/enter-author-detail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/enter-go-module-name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/enter-go-version.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/enter-project-description.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/enter-project-directory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/enter-project-name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 109 additions & 0 deletions docs/folder-structure.md
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 |
77 changes: 77 additions & 0 deletions docs/generate-project-config.md
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
86 changes: 86 additions & 0 deletions docs/generate-project.md
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
41 changes: 40 additions & 1 deletion docs/how-to-use.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,43 @@ outline: deep

# How to Use

#
## Guide

Gen-G is designed with user-friendliness as a priority, making it straightforward to use. Like most command-line interface (CLI) tools, it follows a specific pattern:

```bash
geng command [flag]
```

You can get the list of command using:

```bash
geng help
```

### Output
```bash
geng is a CLI library for Go that empowers applications.

Usage:
geng [command]

Available Commands:
completion Generate the autocompletion script for the specified shell
gen Create a new domain
help Help about any command
infra Add a new infrastructure
migrate migrate the project
new Create a new project
run Run the project
seed Seed the project
service Add a new Service
start Execute the project

Flags:
-h, --help help for geng

Use "geng [command] --help" for more information about a command.
```

Please refer to the dedicated section of each command.
12 changes: 6 additions & 6 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ hero:
link: /roadmap

features:
- title: Feature A
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
- title: Feature B
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
- title: Feature C
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
- title: Generate Go Project
details: Gen-G will help you to generate a starter for go gin project
- title: Generate a module
details: Gen-G will help you to generate module which will setup DI
- title: Generate from bru file
details: Gen-G will help you to generate module from Bru file
---

Binary file added docs/module-name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/project-name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/select-infrastructure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4d62ffb

Please sign in to comment.