Skip to content

Base Template

The base template is the foundation of every FORGE application. It is always included, regardless of which additional templates you select. It provides the essential features that every production application needs: user management, authentication, role-based access control, an admin dashboard, content management, and more.

What is Included

┌──────────────────────────────────────────────────────────┐
│                     BASE TEMPLATE                        │
├──────────────────────────────────────────────────────────┤
│                                                          │
│  Authentication        Admin Dashboard                   │
│  ├─ Login              ├─ Dashboard overview             │
│  ├─ Registration       ├─ User management                │
│  ├─ Password reset     ├─ Role management                │
│  └─ OTP (optional)     ├─ Permission management          │
│                        ├─ Content management              │
│  User Management       ├─ Menu management                │
│  ├─ CRUD operations    ├─ Media library                  │
│  ├─ Profile editing    ├─ Lookup tables                  │
│  ├─ Avatar upload      ├─ Translation management         │
│  └─ Role assignment    ├─ API key management             │
│                        ├─ Settings                       │
│  Role & Permission     └─ Audit log                      │
│  ├─ Role CRUD                                            │
│  ├─ Permission assign  Web Application                   │
│  └─ Middleware checks  ├─ Home page                      │
│                        ├─ Content pages (by slug)        │
│  Multi-Language        ├─ User profile                   │
│  ├─ JSONB translations ├─ Dynamic navigation             │
│  ├─ RTL support        └─ Language switcher              │
│  └─ Per-request locale                                   │
│                                                          │
└──────────────────────────────────────────────────────────┘

Usage

bash
# Create a new project with the base template (default)
forge new --name=myapp

# Explicitly specify the base template
forge new --name=myapp --template=base

# With full options
forge new \
  --name=myapp \
  --backend=rust \
  --frontend=nextjs \
  --template=base \
  --auth=email_password \
  --default-lang=en \
  --languages=en,ar

Database Tables

The base template creates the following database tables through versioned SQL migrations:

Core Tables (Authentication and Authorization)

TableMigrationDescription
users00002_create_users_tableUser accounts with email, mobile, password, status, avatar
roles00003_create_roles_tableNamed roles with translatable display names
permissions00004_create_permissions_tableGranular permissions grouped by module
role_user00005_create_role_user_tableMany-to-many pivot between users and roles
permission_role00006_create_permission_role_tableMany-to-many pivot between permissions and roles
password_resets00007_create_password_resets_tablePassword reset tokens with expiration
otp_codes00008_create_otp_codes_tableOne-time password codes for mobile verification

System Tables

TableMigrationDescription
languages00001_create_languages_tableSupported languages with code, name, direction
settings00009_create_settings_tableKey-value application settings with encryption support
translations00010_create_translations_tableUI translation strings keyed by group and key
api_keys00011_create_api_keys_tableThird-party API keys with rate limiting
audit_logs00012_create_audit_logs_tableActivity audit trail with user, action, resource, details

Content Tables

TableMigrationDescription
media00013_create_media_tablePolymorphic file uploads with metadata
contents00014_create_contents_tableCMS content pages with translatable title, body, slug
menus00015_create_menus_tableNavigation menu items with hierarchy and ordering
lookups00017_create_lookups_tableConfigurable key-value lookup tables

Migration numbering

Migrations are numbered sequentially (00001 through 00017). When additional templates are added, their migrations start at higher numbers (e.g., 00020 for CRM) to avoid conflicts.

Permissions Generated

The base template seeds the following permissions, all assigned to the default admin role:

User Management

PermissionDescription
users.viewView user list and details
users.createCreate new users
users.editEdit existing users
users.deleteDelete users

Role Management

PermissionDescription
roles.viewView role list and details
roles.createCreate new roles
roles.editEdit roles and assign permissions
roles.deleteDelete non-system roles

Content Management

PermissionDescription
contents.viewView content pages
contents.createCreate new content pages
contents.editEdit content pages
contents.deleteDelete content pages
PermissionDescription
menus.viewView navigation menus
menus.createCreate menu items
menus.editEdit menu items
menus.deleteDelete menu items

Media Management

PermissionDescription
media.viewView media library
media.uploadUpload files and images
media.deleteDelete media files

System Permissions

PermissionDescription
settings.viewView application settings
settings.editModify application settings
translations.viewView translation strings
translations.editEdit translation strings
api_keys.viewView API keys
api_keys.createCreate API keys
api_keys.deleteRevoke API keys
audit.viewView audit log entries
lookups.viewView lookup tables
lookups.createCreate lookup entries
lookups.editEdit lookup entries
lookups.deleteDelete lookup entries

Admin Pages Generated

The base template generates the following admin dashboard pages:

admin.myapp.test/
├── /                           # Dashboard with statistics overview
├── /login                      # Admin login page

├── /users                      # User list (data table, search, filters)
├── /users/create               # Create user form
├── /users/[id]                 # User detail view
├── /users/[id]/edit            # Edit user form

├── /roles                      # Role list
├── /roles/create               # Create role with permission assignment
├── /roles/[id]/edit            # Edit role permissions

├── /contents                   # Content page list
├── /contents/create            # Create content (rich text editor)
├── /contents/[id]              # Content detail view
├── /contents/[id]/edit         # Edit content

├── /menus                      # Menu item list
├── /menus/create               # Create menu item
├── /menus/[id]/edit            # Edit menu item

├── /lookups                    # Lookup table list
├── /lookups/create             # Create lookup entry
├── /lookups/[id]/edit          # Edit lookup entry

├── /media                      # Media library (grid/list view)

├── /settings                   # Application settings
├── /translations               # Translation string editor
├── /api-keys                   # API key management
└── /audit                      # Audit log viewer

Each admin page includes:

  • Data tables with sorting, pagination, search, and column visibility
  • Form validation using React Hook Form with Zod schemas
  • Permission gates that hide UI elements the user cannot access
  • Responsive layout with collapsible sidebar navigation
  • Dark mode support via next-themes
  • RTL support for right-to-left languages

Web Pages Generated

The base template generates the following public web pages:

myapp.test/
├── /                           # Home page with dynamic content
├── /[slug]                     # Dynamic content pages (e.g., /about, /contact)

├── /login                      # User login
├── /register                   # User registration
├── /password/forgot            # Forgot password
├── /password/reset             # Reset password

└── /profile                    # User profile (protected)
    ├── /profile/edit           # Edit profile
    └── /profile/password       # Change password

Web pages include:

  • Dynamic navigation driven by menus created in the admin panel
  • Language switcher with locale persistence in cookies
  • Content pages rendered from the CMS with SEO metadata
  • Authentication flows with JWT token management
  • RTL layout that switches automatically based on the active language

API Endpoints

The base template generates a complete REST API:

bash
POST   /api/v1/auth/login              # Login with email/password
POST   /api/v1/auth/register           # Register new account
POST   /api/v1/auth/refresh            # Refresh JWT token
POST   /api/v1/auth/logout             # Logout (invalidate token)
POST   /api/v1/auth/password/forgot    # Request password reset
POST   /api/v1/auth/password/reset     # Reset password with token
POST   /api/v1/auth/otp/send           # Send OTP code
POST   /api/v1/auth/otp/verify         # Verify OTP code
bash
GET    /api/v1/profile                 # Get current user profile
PUT    /api/v1/profile                 # Update profile
PUT    /api/v1/profile/password        # Change password
POST   /api/v1/profile/avatar          # Upload avatar
bash
GET    /api/v1/admin/users             # List users (paginated)
POST   /api/v1/admin/users             # Create user
GET    /api/v1/admin/users/:id         # Get user details
PUT    /api/v1/admin/users/:id         # Update user
DELETE /api/v1/admin/users/:id         # Delete user
bash
GET    /api/v1/admin/roles             # List roles
POST   /api/v1/admin/roles             # Create role
GET    /api/v1/admin/roles/:id         # Get role with permissions
PUT    /api/v1/admin/roles/:id         # Update role
DELETE /api/v1/admin/roles/:id         # Delete role
bash
GET    /api/v1/admin/contents          # List content pages
POST   /api/v1/admin/contents          # Create content page
GET    /api/v1/admin/contents/:id      # Get content page
PUT    /api/v1/admin/contents/:id      # Update content page
DELETE /api/v1/admin/contents/:id      # Delete content page
bash
GET    /api/v1/contents/:slug          # Get published content by slug
GET    /api/v1/menus                   # Get navigation menus
GET    /api/v1/lookups/:type           # Get lookup values by type
GET    /api/v1/languages               # Get supported languages
GET    /api/v1/translations/:lang      # Get translations for locale

Seeded Data

When the database is seeded, the base template creates:

DataDetails
Admin useradmin@myapp.test / admin123
Regular useruser@myapp.test / user123
Admin roleAll permissions assigned
User roleBasic permissions (profile, content viewing)
LanguagesBased on --languages flag (default: English)
TranslationsUI strings for all configured languages
SettingsDefault application settings
PermissionsAll permissions listed above

Change default passwords

The seeded credentials are for development only. Always change the admin password before deploying to any shared or production environment.

Default Configuration

The base template generates a forge.yaml configuration file:

yaml
app:
  name: myapp
  display_name: My Application
  version: 1.0.0

backend:
  framework: rust
  port: 8080

frontend:
  framework: nextjs
  web_port: 3000
  admin_port: 3001

database:
  driver: postgresql
  host: localhost
  port: 5432
  name: myapp

auth:
  method: email_password
  jwt_expiry: 60m
  refresh_expiry: 7d

languages:
  default: en
  list:
    - { code: en, name: English, direction: ltr }

domains:
  web: myapp.test
  admin: admin.myapp.test
  api: api.myapp.test

providers:
  sms: null
  email: smtp
  storage: local
  payments: null

Next Steps

Released under the MIT License.