Skip to Content

Quick Start

This guide walks you through creating a new Gofasta project, starting the server, and generating your first resource.

Step 1: Create a Project

gofasta new myapp

Or with a full Go module path:

gofasta new github.com/myorg/myapp

This creates a complete project with ~78 files:

Creating project... Running go mod init... Copying 78 template files... Installing dependencies... Generating Wire DI code... Generating GraphQL resolvers... Done! Project created at ./myapp

Step 2: Start the Server

cd myapp

Option A: Docker (recommended) — starts the app and PostgreSQL together:

make up

Option B: Host machine — requires a local PostgreSQL instance:

docker compose up db -d # Start just the database make dev # Run with hot reload

Your app is now running:

EndpointURL
REST APIhttp://localhost:8080/api/v1/
GraphQLhttp://localhost:8080/graphql
GraphQL Playgroundhttp://localhost:8080/graphql-playground
Health Checkhttp://localhost:8080/health

Step 3: Generate a Resource

Create a full Product resource with one command:

gofasta g scaffold Product name:string price:float

This generates 11 files and patches 4 existing files:

Generated fileWhat it is
app/models/product.model.goDatabase model
db/migrations/000006_create_products.up.sqlCreate table migration
db/migrations/000006_create_products.down.sqlDrop table migration
app/repositories/interfaces/product_repository.goRepository interface
app/repositories/product.repository.goRepository implementation
app/services/interfaces/product_service.goService interface
app/services/product.service.goService implementation
app/dtos/product.dtos.goRequest/response DTOs
app/di/providers/product.goWire DI provider
app/rest/controllers/product.controller.goREST controller
app/rest/routes/product.routes.goRoute definitions

It also automatically patches:

  • app/di/container.go — adds ProductService and ProductController fields
  • app/di/wire.go — adds ProductSet to the Wire build
  • app/rest/routes/index.routes.go — registers Product routes
  • cmd/serve.go — wires ProductController into the route config

Step 4: Run Migrations

gofasta migrate up

Step 5: Test Your API

# Create a product curl -X POST http://localhost:8080/api/v1/products \ -H "Content-Type: application/json" \ -d '{"name": "Widget", "price": 9.99}' # List all products curl http://localhost:8080/api/v1/products # Get a single product curl http://localhost:8080/api/v1/products/{id} # Update a product curl -X PUT http://localhost:8080/api/v1/products/{id} \ -H "Content-Type: application/json" \ -d '{"name": "Updated Widget", "price": 19.99}' # Delete a product curl -X DELETE http://localhost:8080/api/v1/products/{id}

Supported Field Types

TypeGo typeSQL type (Postgres)GraphQL type
stringstringVARCHAR(255)String
textstringTEXTString
intintINTEGERInt
floatfloat64DECIMAL(10,2)Float
boolboolBOOLEANBoolean
uuiduuid.UUIDUUIDID
timetime.TimeTIMESTAMPDateTime

SQL types are automatically adapted for MySQL, SQLite, SQL Server, and ClickHouse based on the database.driver in your config.yaml.

Next Steps

Last updated on