Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ c.out
# This pattern will ignore any folders starting with "new_project"
new_project*/

.env

# IDE and OS specific files
.vscode/
.idea/
Expand Down
68 changes: 36 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
# Go Bootstrapper
# 🐹⚡ Go Bootstrapper

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

* * *
## Installation

## ✨ Features

* 🏗 **Create new Golang projects instantly** — skip the boilerplate setup.

* ⚡ **Framework-ready templates** — built-in support for `Gin`, `Chi`, and more.

* 📂 **Standardized structure** — organized directories: `cmd/`, `internal/`, `router/`, etc.

* 🔮 **Extensible design** — bring your own templates or modify existing ones.

* 🧱 **Preconfigured tooling** — includes Makefile, linters, and testing setup (coming soon).


* * *

## 📦 Installation

Install globally using `go install`:

Expand All @@ -16,7 +32,7 @@ Once installed, confirm the installation:

* * *

## Quick Start 💨
## 🚀 Quick Start

Create a REST API project using **Gin**:

Expand All @@ -32,30 +48,15 @@ bootstrap new myapp --type=rest --router=gin --db=postgres

* * *

## Example Project Structure
## 📁 Example Project Structure

```
myapp/
├── Makefile
├── README.md
├── cmd/
│ └── main.go
├── internal/
│ ├── config/
│ │ └── config.go
│ ├── handler/
│ │ └── user_handler.go
│ ├── router/
│ │ └── routes.go
│ └── db/ ← created only if --db flag is passed
│ └── db.go
└── go.mod

myapp/ ├── Makefile ├── README.md ├── cmd/ │ └── main.go ├── internal/ │ ├── config/ │ │ └── config.go │ ├── handler/ │ │ └── user_handler.go │ ├── router/ │ │ └── routes.go │ └── db/ ← created only if --db flag is passed │ └── db.go └── go.mod
```

* * *

## CLI Options
## ⚙️ CLI Options

| Flag | Description | Example |
| --- | --- | --- |
Expand All @@ -66,7 +67,7 @@ bootstrap new myapp --type=rest --router=gin --db=postgres

* * *

## Why Go Bootstrapper?
## 💡 Why Go Bootstrapper?

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

Expand All @@ -75,31 +76,34 @@ You focus on business logic — it handles the rest.

It’s like:

> `create-react-app`, but for Golang
> `create-react-app`, but for Golang 🐹

* * *

## Roadmap
## 🛣️ Roadmap

* Add `--with-auth` flag for JWT + middleware setup
* `add` command to make CLI tool more extensible to generate ``service``, ``handlers``, ``controllers``.
* Commands like ``build``, ``test``, ``dev``, ``fmt`` to make it more developer friendly, ensuring production ready code.
* ``init`` that will be used for letting users to choose their configurations via ``TUI``.

* Add Docker & Docker Compose templates

* Support for Fiber, Echo, and gRPC

* Generate Swagger / OpenAPI docs

* Add custom template registry (`bootstrap add template`)


* * *

## Contributing
## 🤝 Contributing

Contributions, feedback, and ideas are welcome!
Feel free to open an issue or PR on [GitHub](https://github.com/upsaurav12/bootstrap).

Consider star the project 🙏

* * *

## License
## 📄 License

Licensed under the **MIT License** © 2025 [Saurav Upadhyay](https://github.com/upsaurav12)

* * *
* * *
8 changes: 8 additions & 0 deletions api/requestDocker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package api

type DockerRequest struct {
}

func RequestToDocker(prompt string) {

}
80 changes: 80 additions & 0 deletions api/requestGroq.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package api

import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"

"github.com/joho/godotenv"
)

type ChatMessage struct {
Role string `json:"role"`
Content string `json:"content"`
}

type GroqChatRequest struct {
Model string `json:"model"`
Messages []ChatMessage `json:"messages"`
}

func CallingApiToGroq(prompt string) (string, error) {

_ = godotenv.Load()

url := os.Getenv("GROQ_API_URL")
key := os.Getenv("GROQ_API_KEY")

if url == "" || key == "" {
return "", fmt.Errorf("missing GROQ_API_URL or GROQ_API_KEY")
}

body := GroqChatRequest{
Model: "llama-3.1-8b-instant",
Messages: []ChatMessage{
{Role: "user", Content: prompt},
},
}

jsonBody, _ := json.Marshal(body)

req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonBody))
if err != nil {
return "", err
}

req.Header.Set("Authorization", "Bearer "+key)
req.Header.Set("Content-Type", "application/json")

resp, err := http.DefaultClient.Do(req)
if err != nil {
return "", err
}
defer resp.Body.Close()

// READ RAW BODY FIRST
rawBody, _ := io.ReadAll(resp.Body)
// fmt.Println("RAW RESPONSE:", string(rawBody))

// Decode into struct
var result struct {
Choices []struct {
Message struct {
Content string `json:"content"`
} `json:"message"`
} `json:"choices"`
}

if err := json.Unmarshal(rawBody, &result); err != nil {
return "", err
}

if len(result.Choices) == 0 {
return "", fmt.Errorf("no choices returned → request was invalid")
}

return result.Choices[0].Message.Content, nil
}
31 changes: 31 additions & 0 deletions cmd/ai.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
"github.com/upsaurav12/bootstrap/api"
)

var aiCmd = cobra.Command{
Use: "ai",
Short: "user enters the prompt to the ai",
Long: "user enters the prompt to the ai",
Run: func(cmd *cobra.Command, args []string) {
result, err := api.CallingApiToGroq(userPrompt)
if err != nil {
fmt.Println("error: ", err)
}

fmt.Println("result: ", result)
},
}

var userPrompt string

func init() {

rootCmd.AddCommand(&aiCmd)

aiCmd.Flags().StringVar(&userPrompt, "prompt", " ", "user enter the prompt")
}
9 changes: 9 additions & 0 deletions cmd/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cmd

import "github.com/spf13/cobra"

var initCmd = &cobra.Command{}

func init() {

}
6 changes: 3 additions & 3 deletions cmd/new.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*

Copyright © 2025 NAME HERE <EMAIL ADDRESS>
Copyright © 2025 Saurav Upadhyay [email protected]

*/

Expand Down Expand Up @@ -64,9 +64,7 @@ func createNewProject(projectName string, projectRouter string, template string,
fmt.Fprintf(out, "Error creating directory: %v\n", err)
return
}
// Print the template that was passed

// Always add README + Makefile from common
renderTemplateDir("common", projectName, TemplateData{
ModuleName: projectName,
PortName: projectPort,
Expand Down Expand Up @@ -134,6 +132,8 @@ func renderTemplateDir(templatePath, destinationPath string, data TemplateData)
return err
}

fmt.Println("path for tmpl: ", filepath.Base(path))

// Write file
outFile, err := os.Create(targetPath)
if err != nil {
Expand Down
27 changes: 26 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
module github.com/upsaurav12/bootstrap

go 1.23.6
go 1.24.0

toolchain go1.24.6

require (
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/bubbles v0.21.0 // indirect
github.com/charmbracelet/bubbletea v1.3.10 // indirect
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
github.com/charmbracelet/lipgloss v1.1.0 // indirect
github.com/charmbracelet/x/ansi v0.10.1 // indirect
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sahilm/fuzzy v0.1.1 // indirect
github.com/spf13/cobra v1.9.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/stretchr/testify v1.10.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/sys v0.36.0 // indirect
golang.org/x/text v0.3.8 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading