Skip to content

Repository files navigation

fndn

A CLI scaffolding tool for Go backend projects. Bootstrap your Go projects with clean architecture, best practices, and a solid foundation — all generated in seconds.

Release Go Build License Ask DeepWiki

Prerequisites

Go >= v1.26.8

Installation

Install the tool to your system with go install, or download a binary from the releases page:

go install github.com/daffadon/fndn@latest

To pin a version:

go install github.com/daffadon/fndn@v0.8.3

Get started

go run github.com/daffadon/fndn@v0.8.3 init .

* . generates in the current directory.

Or see all commands:

go run github.com/daffadon/fndn@v0.8.3 --help

Note

The first generation takes longer than expected, depending on the Go build cache, module cache, and internet speed.

After the project is generated, you can add a config for another tech stack with:

go run github.com/daffadon/fndn@v0.8.3 generate [command]

command: framework, database, mq, cache, storage

Features

  • Clean architecture scaffolding
  • Customizable tech stack
  • Interactive CLI with Bubble Tea
  • Docker and containerization ready
  • Go modules setup

The tech stack

Generation runs in default mode or custom mode, with the freedom to choose the framework, database, message queue, in-memory store, and object storage you need. Default mode uses the first tech stack from each section.

Supported tech stacks
  • Framework

Gin Fiber Echo Chi Gorilla/mux

  • Database

Postgresql MariaDB ClickHouse MongoDB FerretDB Neo4J

  • Message Queue

Nats RabbitMQ Kafka Amazon SQS

  • Cache

Redis Valkey Dragonfly Redict

  • Object Storage

Rustfs Seaweedfs Minio

  • Deployment

Docker

Config Reference

What fndn does for you (v0.*)

It generates a folder structure that uses clean architecture as reference. If you're not familiar with the scheme, don't worry, let's talk about it.

Project Folder Structure
project
├── cmd
│   ├── bootstrap
│   │   └── bootstrap.go
│   ├── di
│   │   └── container.go
│   ├── server
│   │   └── server.go
│   └── main.go
├── config
│   ├── cache
│   │   └── redis.go
│   ├── env
│   │   └── env.go
│   ├── logger
│   │   └── zerolog.go
│   ├── mq
│   │   ├── nats-server.conf
│   │   └── nats.go
│   ├── router
│   │   └── http.go
│   └── storage
│       ├── minio.go
│       └── postgresql.go
├── internal
│   ├── domain
│   │   ├── dto
│   │   │   └── todo.go
│   │   ├── handler
│   │   │   ├── http.go
│   │   │   └── todo.go
│   │   ├── repository
│   │   │   └── todo.go
│   │   └── service
│   │       └── todo.go
│   ├── infra
│   │   ├── cache
│   │   │   └── redis.go
│   │   ├── mq
│   │   │   └── jetstream_infra.go
│   │   └── storage
│   │       ├── minio.go
│   │       └── querier.go
│   └── pkg
│       └── .gitkeep
├── script
│   ├── build-binary.sh
│   └── docker-build.sh
├── .air.toml
├── .env.example
├── .gitignore
├── Dockerfile
├── Makefile
├── README.md
├── VERSION
├── config.local.yaml
├── docker-compose.yml
├── go.mod
└── go.sum

The folder structure is grouped by its usage:

  1. cmd: where the commands exist to run the application. There are several folders for bootstrapping, dependency injection, and constructing the server. main.go is the entrypoint for all of those.
  2. config: stores all the configs; connection to 3rd party services, instantiation of dependencies, configuration for the http server, and certificates for tls. Furthermore you can add more like grpc server config, log emitter, or any other configuration.
  3. internal: the place where you put your app business logic that should not be exposed. This is a special folder for golang because the module can't be imported from anywhere even when the repository is publicly accessible. see more
  4. script: shell scripts to build the app. There are two scripts, one to build the binary and one to build the docker image.

Several generated files you can change for your app:

  1. .air.toml: Check your repository readme for special notes if it's not working on windows
  2. .env.example: check your repository readme for what you should do with this file
  3. Dockerfile: this generated Dockerfile uses multistage and distroless. So in case you want to do something to your containerized app and need a shell, you can change the base image of the second stage.
  4. config.local.yaml: check your repository readme for what you should do with this file
  5. docker-compose.yml: this is for production purposes. For development, this file is purposed to run the 3rd party services for your app.

How to read the code

                                                 |----> config/*.go (except /env)
(cmd)                                            |
main.go -> bootstrap/bootstrap.go -> di/di.go ---|----> internal/domain/*.go (except /dto)
    |                                            |
    |                                            |----> internal/infra/*.go
    |----> server.go
              |
              |(/internal)
              |
              |---> handler/http.go -> handler/todo.go -> service/todo.go -> repository/todo.go

Note

All of the dependencies are injected in the cmd/di/container.go. So, calling the infra in the repository/todo.go is not shown.

Troubleshoot

Air is not working on wsl

Note

If you use windows and generate the project using wsl, the hot reload won't work. Better you use the fndn for windows in this case or if its already generated, you can change the .air.toml in bin and cmd to become like below and run air from windows, not from wsl.

bin = "./tmp/main.exe"
cmd = "go build -o ./tmp/main.exe ./cmd"

go run command can't be stopped on wsl

Note

In windows environment, sometimes go run command can't be stopped. It's because the compatibility. Just use powershell to run the app and don't use the wsl.

FerretDB is not working as expected

Note

Due to limitation, you can't use any database. Instead use, postgres database. If you find a similar log with the below log in your postgres db, change the database to postgres (i've made this default, but in case you change the database name in docker-compose.yml, change your database).

/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/20-install.sql
psql:/docker-entrypoint-initdb.d/20-install.sql:1: NOTICE: installing required extension "documentdb_core"
psql:/docker-entrypoint-initdb.d/20-install.sql:1: NOTICE: installing required extension "pg_cron"
2025-09-30 06:23:15.653 UTC [76] ERROR: can only create extension in database postgres
psql:/docker-entrypoint-initdb.d/20-install.sql:1: ERROR: can only create extension in database postgres
DETAIL: Jobs must be scheduled from the database configured in cron.database_name, since the pg_cron background worker reads job descriptions from this database.
HINT: Add cron.database_name = 'database_name' in postgresql.conf to use the current database.

About

fndn — Bootstrap your Go projects with clean architecture, best practices, and a solid foundation — all generated in seconds.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages