Folder Structure

Every Nimbus app follows a consistent directory layout inspired by Laravel conventions. When you run nimbus new myapp, the CLI scaffolds the structure below.

Top-level Overview

myapp/
  app/
    controllers/
    middleware/
    models/
    jobs/
  bin/
    server.go
  config/
    config.go
    env.go
    app.go
    database.go
  database/
    migrations/
    seeders/
  start/
    kernel.go
    routes.go
  resources/
    views/
      layout.nimbus
      home.nimbus
    css/
    js/
  public/
  .env
  .env.example
  main.go
  go.mod
  go.sum

app/

Contains your application logic, organized by concern.

app/controllers/

Controller structs that handle HTTP requests. Each controller is a Go struct with methods like Index, Show, Store, Update, and Destroy. Controllers receive a *http.Context and return an error.

app/middleware/

Custom middleware functions for your application. Nimbus ships with built-in middleware (Logger, Recover, CORS, CSRF, RateLimit), but app-specific middleware such as authentication checks or request transformations go here.

app/models/

GORM model structs that map to database tables. Each file typically defines one model and its relationships.

bin/

The application boot file. bin/server.go is the HTTP server entrypoint โ€” it loads configuration, creates the Nimbus app, registers middleware (via the kernel), wires up routes, and connects to the database.

// bin/server.go
func Boot() *nimbus.App {
    config.Load()
    app := nimbus.New()
    start.RegisterMiddleware(app)
    start.RegisterRoutes(app)
    _, _ = database.Connect(config.Database.Driver, config.Database.DSN)
    return app
}

config/

Application configuration files. Values are loaded from environment variables via .env using godotenv.

  • config.go โ€” Loads .env and calls each config loader.
  • env.go โ€” Helper functions: env(), envInt(), envBool().
  • app.go โ€” General settings: port, environment, app name.
  • database.go โ€” Database driver and DSN configuration.

start/

The start/ directory holds files that run during application startup, mirroring Laravel-style boot organization.

  • kernel.go โ€” Registers middleware with the server or the router. This is the only place where middleware is configured.
  • routes.go โ€” Defines all HTTP routes for the application.

database/

Database-related files for managing schema and seed data.

database/migrations/

Migration files that define schema changes. Nimbus uses GORM AutoMigrate or manual migration files to version your database schema.

database/seeders/

Seeder files that populate your database with sample or default data for development and testing.

resources/views/

Template files using the .nimbus extension. These are HTML files with template directives for layouts, data binding, and control flow. Views are rendered by calling c.View("name", data) from a controller or handler.

  • layout.nimbus โ€” Base layout wrapping all pages.
  • home.nimbus โ€” Homepage template.

public/

Static assets served directly by the web server. Place CSS, JavaScript, images, fonts, and other files that should be publicly accessible here.

Root Files

  • main.go โ€” Minimal bootstrap entrypoint. Imports bin.Boot() and calls app.Run(). You should not need to modify this file.
  • .env โ€” Environment variables (PORT, APP_ENV, DB_DRIVER, DB_DSN, etc.).
  • .env.example โ€” Template of available environment variables for new developers.
  • go.mod / go.sum โ€” Go module files managing dependencies.

Laravel Comparison

If you are coming from Laravel, here is how the Nimbus structure maps:

Laravel-style conceptNimbusPurpose
server.tsmain.goUntouched entry point
bin/server.tsbin/server.goBoot, config, DB
start/kernel.tsstart/kernel.goMiddleware only
start/routes.tsstart/routes.goRoute definitions
config/*.tsconfig/*.goEnvironment-driven config
app/controllers/app/controllers/HTTP controllers
app/middleware/app/middleware/Custom middleware
resources/views/views/Templates