# Building an app

> The five build stages of an asasvirtuais app, from data modeling to workflows, and the project files that keep a coding agent on track.

Source: https://asasvirtuais.com/docs/building-an-app

Every asasvirtuais app is built in the same order. Rules coded at the start would change every time something simple
changes in the front-end, so the advanced parts come last.

1. **Data modeling, by feature.** Each feature's tables become packages: `packages/{model}/schema.ts`, the schemas in
   Zod. What the relational database already answers is not a column.
2. **Layout.** Routes, layouts and page skeletons, each page providing the tables it shows with the rows it fetched.
3. **Pages, forms and server actions.** Each page gets its forms (`CreateForm`, `UpdateForm`, `FilterForm`), its
   pagination, and the [server actions](https://asasvirtuais.com/docs/server-code.md) it needs.
4. **Middleware and authorization.** Authentication, authorization, and each table's
   [middleware](https://asasvirtuais.com/docs/middleware.md), once the features are defined.
5. **Workflows and custom features.** What needs a hand-written state management or a state machine. See
   [Workflows](https://asasvirtuais.com/docs/workflows.md).

A team working by hand runs the same order as a four-week sprint, presenting at the end of each week: planning and
setup, then stages 1 and 2, then stage 3, then stages 4 and 5. A coding agent develops much faster, but it follows the
same order.

## Recommended project files

Building with a coding agent works best when the project keeps its context in a few Markdown files:

| File | What it holds |
|---|---|
| `brief.md` | what the client asked for |
| `specs.md` | how it's built, technically, kept up to date as things change |
| `plan.md` | the initial plan for the project |
| `changelog.md` | what has been developed so far |
| `roadmap.md` | ideas for the future of the project |
| `README.md` | written at the end: what was done, how, and how to start using it |
| `AGENTS.md` | the framework rules, copied from `AGENTS.example.md` (explained in [The rules](https://asasvirtuais.com/docs/rules.md)) |

## Naming conventions

| Concept | Pattern | Example |
|---|---|---|
| Table | lowercase plural | `'todos'` |
| Fields | `{Field}Field` | `TitleField` |
| Hooks | `use{Model}s()`, `use{Model}()` | `useTodos()`, `useTodo()` |
| Providers | `{Model}sProvider` (table), `{Model}Provider` (row) | `TodosProvider`, `TodoProvider` |
| Forms | `Create{Model}`, `Update{Model}`, `Filter{Model}s`, `Delete{Model}` | `UpdateTodo` |
| One-click update | `{Verb}{Model}` | `ToggleTodo` |
| Components | `{Model}Item`, `Single{Model}` | `TodoItem` |

## Rather not build it yourself?

[Fast Track BTA](https://fasttrackbta.us) builds custom business tools and apps on asasvirtuais, following exactly
this process, and delivers in 1 to 5 business days. See [Hire us](https://asasvirtuais.com/docs/hire.md).
