RapidGo
No results found

Directory Structure

Understand the RapidGo starter project layout.

A freshly scaffolded RapidGo project has the following structure:

myapp/
├── cmd/
│   └── main.go              # Entry point — hook wiring
├── app/
│   ├── providers/           # Service providers (config, db, router, etc.)
│   ├── helpers/             # Utility functions
│   ├── services/            # Business logic layer
│   ├── jobs/                # Queue job handlers
│   ├── schedule/            # Scheduled task definitions
│   └── plugins.go           # Plugin registration
├── routes/
│   ├── web.go               # Web (HTML) routes
│   ├── api.go               # API routes
│   └── ws.go                # WebSocket routes
├── http/
│   ├── controllers/         # Request handlers
│   ├── requests/            # Form request validation (optional)
│   └── responses/           # Response structs (optional)
├── database/
│   ├── models/              # GORM model definitions
│   ├── migrations/          # Database migration files
│   └── seeders/             # Database seeders
├── resources/
│   ├── views/               # Go HTML templates
│   ├── static/              # CSS, JS, images
│   └── lang/                # Translation JSON files
├── storage/
│   ├── database/            # SQLite database files
│   ├── cache/               # File cache
│   ├── logs/                # Log files
│   ├── sessions/            # File-based sessions
│   └── uploads/             # User uploads
├── tests/
│   ├── unit/                # Unit tests
│   └── integration/         # Integration tests
├── plugins/                 # Custom plugins
├── .env.example             # Environment template
├── Dockerfile               # Docker build
├── docker-compose.yml       # Docker Compose stack
├── Makefile                 # Build shortcuts
└── go.mod                   # Go module definition

Key Files

cmd/main.go

The entry point wires your application to the framework using 6 hooks:

func main() {
    cli.SetBootstrap(...)        // Register service providers
    cli.SetRoutes(...)           // Register routes
    cli.SetJobRegistrar(...)     // Register queue job handlers
    cli.SetScheduleRegistrar(...)// Register scheduled tasks
    cli.SetModelRegistry(...)    // Register models for AutoMigrate
    cli.SetSeeder(...)           // Register database seeders
    cli.Execute()                // Run the CLI
}

app/providers/

Service providers follow the Register/Boot lifecycle pattern. Each provider binds services into the IoC container during Register() and can resolve other services during Boot().

routes/

Route files are split by concern: web.go for HTML pages, api.go for JSON APIs, and ws.go for WebSocket endpoints.

database/migrations/

Each migration file contains an init() function that registers the migration with a version string and Up/Down functions.