Skip to content

Commit d33f708

Browse files
fix: some improvements
1 parent 3c8a364 commit d33f708

6 files changed

Lines changed: 85 additions & 60 deletions

File tree

‎README.md‎

Lines changed: 63 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Go Bootstrapper
1+
# BootstrapCLI
22

3-
**Go Bootstrapper** is a CLI tool that scaffolds production-ready Golang projects — no dependency headaches, no manual setup.
3+
**BootstrapCLI** is a CLI tool that scaffolds production-ready Golang projects — no dependency headaches, no manual setup.
44
Just run a command and get a fully configured project with linters, routers, and structure ready to code.
55

66
* * *
@@ -18,74 +18,94 @@ Once installed, confirm the installation:
1818

1919
## Quick Start 💨
2020

21-
Create a REST API project using **Gin**:
21+
```
22+
bootstrap new myapp --type=rest --router=gin --port=8080 --db=postgres
23+
```
2224

2325
```
24-
bootstrap new myapp --type=rest --router=gin --port=8080
26+
cd myapp && make tidy
2527
```
2628

27-
Create a project with **PostgreSQL** integration:
29+
Make sure that the docker and docker compose is installed in your local machine
30+
```
31+
docker compose up -d
32+
```
2833

34+
Before running ``make run`` make sure that you have running 'db' in docker, running with the same credentials as in .env file.
2935
```
30-
bootstrap new myapp --type=rest --router=gin --db=postgres
36+
make run
3137
```
3238

33-
* * *
3439

3540
## Example Project Structure
3641

3742
```
3843
myapp/
39-
├── Makefile
40-
├── README.md
41-
├── cmd/
42-
│ └── main.go
43-
├── internal/
44-
│ ├── config/
45-
│ │ └── config.go
46-
│ ├── handler/
47-
│ │ └── user_handler.go
48-
│ ├── router/
49-
│ │ └── routes.go
50-
│ └── db/ ← created only if --db flag is passed
51-
│ └── db.go
52-
└── go.mod
44+
├── cmd
45+
│ └── main.go
46+
├── docker-compose.yml
47+
├── go.mod
48+
├── go.sum
49+
├── internal
50+
│ ├── config
51+
│ │ ├── config.go
52+
│ │ └── config_test.go
53+
│ ├── db
54+
│ │ └── database.go
55+
│ ├── handler
56+
│ │ └── user_handler.go
57+
│ ├── model
58+
│ │ ├── registory.go
59+
│ │ └── user_model.go
60+
│ ├── repository
61+
│ │ └── user_repo.go
62+
│ ├── server
63+
│ │ ├── routes.go
64+
│ │ └── server.go
65+
│ └── service
66+
│ └── user_service.go
67+
├── Makefile
68+
├── project.yaml
69+
└── README.md
5370
5471
```
5572

56-
* * *
57-
5873
## CLI Options
74+
### `new`
5975

60-
| Flag | Description | Example |
61-
| --- | --- | --- |
62-
| --type | Type of project (rest, grpc, etc.) | --type=rest |
63-
| --router | Router framework (gin, chi, echo) | --router=gin |
64-
| --port | Application port | --port=8080 |
65-
| --db | Database integration | --db=postgres |
76+
Creates a new project with the specified configuration options.
6677

67-
* * *
78+
### Flags
6879

69-
## Why Go Bootstrapper?
80+
| Flag | Description | Example |
81+
|--------------|-------------------------------------------------|----------------------|
82+
| `--type` | Type of project (e.g., `rest`) | `--type=rest` |
83+
| `--router` | Router framework (`gin`, `chi`, `echo`, `fiber`) | `--router=gin` |
84+
| `--port` | Application port | `--port=8080` |
85+
| `--db` | Database integration | `--db=postgres` |
86+
| `--entities` | Add entities | `--entities=user` |
7087

71-
Developers often waste time repeating setup tasks — creating folders, configuring routers, writing Makefiles, adding linters, etc.
7288

73-
**Go Bootstrapper** automates all that.
74-
You focus on business logic — it handles the rest.
89+
### `apply`
90+
Create a new project using yaml file configurations
91+
| Flag | Description | Example |
92+
|--------------|------------------------------------------------- |----------------------|
93+
| `--yaml` | unique file name for the yaml file | `--yaml=project.yaml`|
7594

76-
It’s like:
95+
**BootstrapCLI** automates all that.
96+
You focus on business logic — it handles the rest.
7797

78-
> `create-react-app`, but for Golang �
98+
> Note: This is my first OSS project, I want to make a CLI tool(maybe webUI) which is not just generator tool which only generate
99+
> go code, but it will help developers to follow best practices, and assist during the project development. In future versions of the project i will add AI which will help developer to assist during their development and help in debugging + fixing error. I am adding AI not to generate code in there project but for assisting purpose only.
79100
80101
* * *
81102

82103
## Roadmap
83104

84-
* Add `--with-auth` flag for JWT + middleware setup
85-
* `add` command to make CLI tool more extensible to generate ``service``, ``handlers``, ``controllers``.
86-
* Commands like ``build``, ``test``, ``dev``, ``fmt`` to make it more developer friendly, ensuring production ready code.
87-
* ``init`` that will be used for letting users to choose their configurations via ``TUI``.
88-
105+
* Add CLI command that let users to write their project description, to generate the project automatically without using flags.
106+
* Command such as ``explain``, ``error`` , ``upgrade`` for the tool to make it progressive CLI tool.
107+
* Add support for ``auth``, ``logging`` , ``observability`` and so on if it make sense.
108+
* Add functionality in which users can switch to other options, for example postgres -> mongodb.
89109

90110
* * *
91111

@@ -94,12 +114,12 @@ It’s like:
94114
Contributions, feedback, and ideas are welcome!
95115
Feel free to open an issue or PR on [GitHub](https://github.com/upsaurav12/bootstrap).
96116

97-
Consider star the project 🙏
117+
Hope you like this project.
98118

99119
* * *
100120

101121
## License
102122

103-
Licensed under the **MIT License** © 2025 [Saurav Upadhyay](https://github.com/upsaurav12)
123+
Licensed under the **MIT License** © 2026 [Saurav Upadhyay](https://github.com/upsaurav12)
104124

105125
* * *

‎cmd/new.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ type TemplateData struct {
142142
OtherImports string
143143
UpperEntity []string
144144
ApiGroup func(entity string, get string, lowerentity string) string
145+
IsAPIGroup bool
145146
Get string
146147
FullContext string
147148
ToTheClient string
@@ -215,6 +216,7 @@ func buildTemplateData(projectName string,
215216
Returnable: frameworkConfig.Returnable,
216217
ReturnKeyword: frameworkConfig.ReturnKeyword,
217218
HTTPHandler: frameworkConfig.HTTPHandler,
219+
IsAPIGroup: frameworkConfig.IsAPIGroup,
218220
Entities: Entities,
219221
// UpperEntity: ,
220222
}
@@ -246,6 +248,7 @@ func buildTemplateData(projectName string,
246248
ReturnKeyword: frameworkConfig.ReturnKeyword,
247249
HTTPHandler: frameworkConfig.HTTPHandler,
248250
Entities: yamlConfig.Entities,
251+
IsAPIGroup: frameworkConfig.IsAPIGroup,
249252
}
250253
}
251254

‎pkg/framework/framework.go‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type FrameworkConfig struct {
2424
ReturnKeyword string
2525
HTTPHandler string
2626
Entities []string
27+
IsAPIGroup bool
2728
}
2829

2930
var FrameworkRegistory = map[string]FrameworkConfig{
@@ -38,6 +39,7 @@ var FrameworkRegistory = map[string]FrameworkConfig{
3839
Start: "gin.Default()",
3940
OtherImports: `"net/http"`,
4041
FullContext: "c *gin.Context",
42+
IsAPIGroup: true,
4143
ApiGroup: func(entity string, get string, lowerentity string) string {
4244
apiGroup := fmt.Sprintf(`
4345
{
@@ -80,18 +82,19 @@ var FrameworkRegistory = map[string]FrameworkConfig{
8082
"github.com/go-chi/render"
8183
"net/http"
8284
`,
85+
IsAPIGroup: false,
8386
ApiGroup: func(entity string, get string, lowerentity string) string {
8487
apiGroup := fmt.Sprintf(`
8588
r.Group(func(r chi.Router) {
86-
r.%s("/%s", handler.Get%ss)
89+
r.%s("/%s", %sHandler.Get%ss)
8790
})
88-
`, get, lowerentity, entity)
91+
`, get, lowerentity, lowerentity, entity)
8992

9093
return apiGroup
9194
},
9295
Get: "Get",
9396
FullContext: "w http.ResponseWriter, r *http.Request",
94-
ToTheClient: "json.NewEncoder(w).Encode(",
97+
ToTheClient: "render.JSON(w,r,",
9598
Response: "(w, r,",
9699
ImportRouter: `
97100
"encoding/json"
@@ -117,17 +120,16 @@ var FrameworkRegistory = map[string]FrameworkConfig{
117120
Router: "*echo.Echo",
118121
Start: "echo.New()",
119122
OtherImports: `"net/http"`,
120-
123+
IsAPIGroup: true,
121124
ApiGroup: func(entity, get, lowerentity string) string {
122125
return fmt.Sprintf(`
123-
api := r.Group("/api/v1")
124126
{
125127
%s := api.Group("/%s")
126128
{
127-
%s.%s("", handler.Get%ss)
129+
%s.%s("", %sHandler.Get%ss)
128130
}
129131
}
130-
`, lowerentity, lowerentity, lowerentity, get, entity)
132+
`, lowerentity, lowerentity, lowerentity, get, lowerentity, entity)
131133
},
132134

133135
Get: "GET",
@@ -162,17 +164,17 @@ var FrameworkRegistory = map[string]FrameworkConfig{
162164
Router: "*fiber.App",
163165
Start: "fiber.New()",
164166
OtherImports: `"net/http"`,
165-
167+
IsAPIGroup: true,
166168
ApiGroup: func(entity, get, lowerentity string) string {
167169
return fmt.Sprintf(`
168170
api := r.Group("/api/v1")
169171
{
170172
%s := api.Group("/%s")
171173
{
172-
%s.%s("", handler.Get%ss)
174+
%s.%s("", %sHandler.Get%ss)
173175
}
174176
}
175-
`, lowerentity, lowerentity, lowerentity, get, entity)
177+
`, lowerentity, lowerentity, lowerentity, get, lowerentity, entity)
176178
},
177179

178180
Get: "Get",

‎project.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ project:
22
name: "test1"
33
port: 8080
44
arch: "clean"
5-
router: "chi" # or gin / echo / fiber
5+
router: "chi"
6+
db: "postgres"
67

78
entities:
89
- user
910
- product
10-
- payment

‎templates/rest/clean/internal/handler/example_handler.go.tmpl‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ package handler
22

33
import (
44
"{{.ModuleName}}/internal/service"
5-
"net/http"
65

7-
"github.com/gin-gonic/gin"
6+
{{.ImportHandler}}
87
)
98

109
type {{.Entity}}Handler struct {
@@ -15,7 +14,7 @@ func New{{.Entity}}Handler(s *service.{{.Entity}}Service) *{{.Entity}}Handler {
1514
return &{{.Entity}}Handler{Service: s}
1615
}
1716

18-
func (h *{{.Entity}}Handler) Get{{.Entity}}s(c *gin.Context) {
17+
func (h *{{.Entity}}Handler) Get{{.Entity}}s({{.FullContext}}) {{.Returnable}}{
1918
{{.LowerEntity}}s, _ := h.Service.Get{{.Entity}}s()
20-
c.JSON(http.StatusOK, {{.LowerEntity}}s)
19+
{{.ReturnKeyword}} {{.ToTheClient}} {{.LowerEntity}}s)
2120
}

‎templates/rest/clean/internal/server/routes.go.tmpl‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ func (s *Server) RegisterRoutes() {{.HTTPHandler}} {
1616

1717
gormDB := s.db.GetDB()
1818

19-
19+
{{- if .IsAPIGroup }}
2020
api := r.Group("/api/v1")
21+
{{- end }}
2122

2223
{{ if .Entities }}
2324
{{ range $i, $entity := .Entities }}

0 commit comments

Comments
 (0)