Master Guides

Getting Started

Build and run your first full-stack Master app in a few minutes.

This guide takes you from an empty folder to a running full-stack application: a Next.js frontend, a MasterController API, and a MasterRecord database — all wired together.

1. Install the CLI#

terminal
$ npm install -g master

Master requires Node.js 20 or newer. Verify the install:

terminal
$ master --version
$ master info

2. Create a new app#

terminal
$ master new my-app

This scaffolds the monorepo, installs dependencies, and initializes git. Choose your database with --db (defaults to SQLite — zero setup):

terminal
$ master new my-app --db postgres
$ master new my-app --db mysql
$ master new blog --skip-frontend # API only

3. Set up the database#

terminal
$ cd my-app
$ master db migrate

For SQLite this creates backend/db/appcontext.sqlite instantly. For MySQL/Postgres, edit the credentials in backend/config/environments/env.development.json first (keyed by the context name, AppContext):

env.development.json
{
  "AppContext": {
    "type": "postgres",
    "host": "127.0.0.1",
    "port": 5432,
    "database": "my_app_development",
    "user": "postgres",
    "password": ""
  }
}

4. Run it#

terminal
$ master dev

Both restart on change, and each process’s output is prefixed ([backend], [frontend]). The homepage calls the backend’s /health endpoint to prove the full stack is connected.

5. Build a feature#

Scaffold a complete resource — a model, a RESTful API controller, routes, and a Next.js page — with one command:

terminal
$ master generate scaffold post title:string body:text
$ master db new AddPosts
$ master db migrate

You now have a working /posts JSON API and a /posts page. Try it:

terminal
curl -X POST http://localhost:3001/posts \
  -H 'Content-Type: application/json' \
  -d '{"title":"Hello","body":"By the power of Grayskull"}'

curl http://localhost:3001/posts
How the pieces connect
The backend boots with setupServer() → startMVC() → start(). Controllers reply with this.returnJson(data). Models register in AppContext.js via this.dbset(Entity). The frontend calls the API through frontend/app/lib/api.ts.

What’s next?#