Quickstart: build in code

An Appbricx app is a folder of plain files: SQL for the database and its access rules, React for the pages, TypeScript for server actions and workflows. Pull it into your editor, change it, and push: every check answers at the file and line, and an apply builds the dev app in seconds. Your agent edits the same files.

What you need

  • An Appbricx account and a personal access token with the read and apply scopes (Workspace settings, Coding agents; see access tokens).
  • The appbricx binary for pull and push (see CLI), or curl: both call the same developer API.
  • npm, only if you add npm packages from your machine.

1. Point the CLI at your workspace

export APPBRICX_API=https://appbricx.com/api/dev/v1
export APPBRICX_TOKEN=apx_pat_…

2. Start a project

Start from the code-first starter (companies book team experiences from hosts; ops confirm), named after your brand. It creates the project and builds it in dev:

curl -sS -X POST "$APPBRICX_API/templates/team-outings/use" \
  -H "Authorization: Bearer $APPBRICX_TOKEN" -H 'content-type: application/json' \
  -d '{"name": "Offsite Co", "params": {"brand_name": "Offsite Co"}}'
# → {"applied": true, "created": true, "project": {"id": "3b7e…", …}, "summary": {…demo sign-ins…}}

export PROJECT=3b7e…

Or create an empty project (POST $APPBRICX_API/projects with {"name": "…"}) and push your own files.

3. Pull it

appbricx pull "$PROJECT" offsite/
# pulled 24 files (draft rev 1) to offsite/
cd offsite && git init && git add -A && git commit -m "Start from team-outings"

What you get:

app.config.ts            brand, sign-in, roles and their profile tables, config names
db/schema/*.sql          tables: experience, slot, booking, the profiles
db/access/*.sql          row-level security: who reads and changes which rows
db/queries/*.sql         named queries with typed params
db/seeds/demo.sql        demo rows (re-runnable)
routes/index.tsx         /                 public, server-rendered
routes/experiences/[id].tsx                /experiences/:id
routes/bookings.tsx      /bookings         hr and ops only
routes/_layout.tsx       the header around every page
components/              ExperienceCard.tsx (+ its CSS)
server/bookings.ts       confirmBooking, leaveFeedback: typed actions
workflows/booking.ts     email on confirm, a daily digest for ops
messages/email|notify/   templates with typed vars
styles/app.css           your CSS, after Tailwind

Every file kind is described in project files.

4. Make a change

Give experiences a duration. Add the column in SQL:

-- db/schema/experience.sql (inside create table experience)
  duration_minutes int not null default 120,

A create table if not exists you change is migrated, not recreated: the apply adds the column and keeps every row. Show it on the experience page; the row is typed from the schema, so row.duration_minutes is a number:

// routes/experiences/[id].tsx
<p>{row.duration_minutes} minutes · ₹{row.price} a person</p>

5. Push, check, apply

appbricx push "$PROJECT" . --check

The draft now equals your folder, and the check runs the SQL lint, strict TypeScript against your tables, templates and config, and the platform's lint rules. A typo comes back where it is:

"errors": ["routes/experiences/[id].tsx:22: Property 'duration_minute' does not exist on type 'ExperienceRow'. Did you mean 'duration_minutes'?"]

Fix it, then build dev:

appbricx push "$PROJECT" . --apply

The answer has the dev link (https://dev-offsite-co.apps.appbricx.com), the plan's statements and a demo sign-in per role (host, hr, ops). Open it and sign in as each. Drops (a column or table you removed) are not run by an apply: they come back as warnings until you pass allow_destructive.

push deletes draft files your folder doesn't have, so pull first when an agent or a teammate may have changed the draft. Dot-files and node_modules are never sent.

6. Add a package

appbricx add recharts
appbricx push "$PROJECT" . --check

add writes package.json and package-lock.json with versions at least 7 days old; the build installs exactly the lockfile. React and the @appbricx/* packages come with the platform.

7. Deploy

Read the plan first, then deploy (your token needs the deploy scope):

curl -sS -X POST "$APPBRICX_API/projects/$PROJECT/deploy/plan" \
  -H "Authorization: Bearer $APPBRICX_TOKEN" -H 'content-type: application/json' -d '{"subdomain": "offsite"}'

curl -sS -X POST "$APPBRICX_API/projects/$PROJECT/deploy" \
  -H "Authorization: Bearer $APPBRICX_TOKEN" -H 'content-type: application/json' -d '{"subdomain": "offsite"}'

The migration is rehearsed on a copy of production and verified there; a red report stops the release with production untouched. Then production is snapshotted and switched over to https://offsite.apps.appbricx.com. A deploy that is still running answers {"status": "running"}: call it again to wait for the same run.

Working with git

  • A preview per branch. appbricx push "$PROJECT" . --preview sends what git sees to a preview of its own (database cloned from dev, its own address), named after the branch, and leaves the dev draft alone. --preview --delete removes it when the branch is merged. Run it from a pre-push hook or a CI job.
  • Versions. Every apply is a version with its author. Diff any two, label one or restore it (GET …/versions/compare?from=prod&to=dev, or ask your agent).
  • Agents and people together. An agent's code and project_files tools edit the same draft you push. Pull before you push.

Related