Getting Started
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#
$ npm install -g master
Master requires Node.js 20 or newer. Verify the install:
$ master --version$ master info
2. Create a new app#
$ master new my-app
This scaffolds the monorepo, installs dependencies, and initializes git. Choose your database with --db (defaults to SQLite — zero setup):
$ master new my-app --db postgres$ master new my-app --db mysql$ master new blog --skip-frontend # API only
3. Set up the database#
$ 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):
{
"AppContext": {
"type": "postgres",
"host": "127.0.0.1",
"port": 5432,
"database": "my_app_development",
"user": "postgres",
"password": ""
}
}4. Run it#
$ master dev
- API → http://localhost:3001
- Web → http://localhost:3000
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:
$ 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:
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/postssetupServer() → 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.