Studio (Admin Panel)
Auto-generated admin panel for your GORM models. Get CRUD interfaces, search, filtering, pagination, and relationship browsing with zero configuration.
Setup
import "github.com/CodeSyncr/nimbus/studio"
app.Use(studio.New())
// Admin panel at /studio
What Studio Generates
Studio automatically discovers all GORM models and generates:
- CRUD interfaces — Create, read, update, delete for every model
- Database statistics — Row counts, table sizes
- Search and filtering — Full-text search across model fields
- Pagination — Navigate large datasets
- Relationship browsing — Navigate between related models
Configuration
app.Use(studio.New(studio.Config{
Prefix: "/admin", // URL prefix (default: /studio)
Models: []any{&User{}, &Product{}, &Order{}}, // Explicit model list
ReadOnly: false, // Set true to disable writes
}))
Real-Life Example: E-Commerce Admin
// Register Studio with specific models
app.Use(studio.New(studio.Config{
Prefix: "/admin",
Models: []any{
&models.User{},
&models.Product{},
&models.Order{},
&models.Category{},
&models.Review{},
},
}))
// Protect with auth middleware
admin := app.Router.Group("/admin")
admin.Use(auth.RequireAuth())
admin.Use(auth.RequireRole("admin"))
Best Practices
- Always protect Studio routes with authentication middleware
- Use
ReadOnly: truefor production monitoring dashboards - Specify explicit
Modelslist rather than exposing all tables - Change the default prefix from
/studioto something less predictable in production