# Team Work

> Several developers on one API Maker project - one account per developer with its own user path, secrets and branch, database names masked per developer, and the compare editor before a push.

Source: https://docs.apimaker.dev/v4/docs/features/team-work.html

A team shares one Git repository. Each developer works in an account of their own, on databases of their own, and pushes to a branch for a pull request — or several developers sync one account at the same time from their editors. The tools of the admin panel make both easy.

## Developer accounts

One admin user per developer. Each developer signs in with their own account, pulls the branch of the team, works, and pushes. The APIs of each account answer under its own user path.

- Video: [Developer Accounts: A Workspace for Every Developer on One Server](https://apimaker.dev/videos/developer-accounts) (3 min)

| | |
|---|---|
| Who creates them | The root user, on the **Accounts** page : name, email, API path, password, active. **Insert Default Data** (checked by default) adds sample custom APIs, schemas, hooks and migration scripts ; the default secret, group and API user are made either way. **Clone** copies one. |
| Unique | The API path and the email. |
| Own to each account | Its secrets, its Git branch and credentials, its masked database names, its sandbox processes, its Redis cache. |
| Shared | The Git repository, and through it every item of the project. |
| From a script | The [management API](https://docs.apimaker.dev/v4/docs/am-resources/operate-api-maker-using-api.html) creates, changes and deletes admin users. |

A developer joins :

1. The root user creates the account and gives the credentials.
2. The developer sets the Git URL and commit email in their **User info**, pulls the branch of the team, and adds the connection strings and keys of their own databases to their secret.
3. When the database names of their machine differ from the ones in the code, they [mask](https://docs.apimaker.dev/v4/docs/features/team-work.html#mask-database-names) them.
4. They work under `/api/…/<their path>/…`, test with their own API users, and push to a branch of their own for a pull request.

## Several developers on one account

Several developers can work on the same account at the same moment, each in their own editor : every one runs the [local client](https://docs.apimaker.dev/v4/docs/features/developer-tools.html#several-developers) with the sync token of the account.

| | |
|---|---|
| How many | Up to 50 local clients of an account at a time. |
| What travels | What one of them saves reaches the others and the admin panel within a second, as the server saved it. Each line of their terminals says who made the change. |
| Who is connected | The bar of the admin panel shows the local clients of the account : their faces and their count, then, in its menu, each computer, folder and address, and since when. |
| Security | Each one connects encrypted and proves the sync token without sending it ; a new sync token disconnects all of them. |

## Mask database names

The code names the databases the way production does : `shop`. On a developer machine the same database may be `shop_dev`, or two developers may share one server with `shop_alice` and `shop_bob`. Masking maps one to the other, for one account, so nobody edits a database name before a pull request.

- Video: [Database Name Masking: One Name in Code, Any Database per Developer](https://apimaker.dev/videos/database-name-masking) (3 min)

| | |
|---|---|
| Where | Profile → **User info** → masked databases : instance, database name, masked database name. |
| Scope | The account of the developer only. Git, schemas, settings and code keep the name of the project. |
| Effect | Every API, hook, migration and query of the account runs on the masked name : the name in the URL and in the code stays the one of the project. |

| Instance | Database name (in the code) | Masked database name (on this server) |
|---|---|---|
| `mysql8` | `shop` | `shop_alice` |

- Add one row per database whose name differs. Names not listed are used as they are.
- Table meta, migrations, and plain queries which name the database in the API also go through the mapping ; SQL text you write yourself does not.

## Compare code

The Git panel lists every item the account changed since the last pull, with its kind of change, and opens each one in a compare editor.

| | |
|---|---|
| Where | The Git panel → **Git status of commit**. |
| Per file | **Compare** or **Open in compare editor** : the version of the branch next to the version of the account, the differences highlighted line by line. |
| All at once | **View all changes in one diff**. |
| Undo | **Revert** puts the file back to the branch ; several files at once with **Revert selected**. |

- The versions of a custom API, a hook or a listener are files of the item in Git, so a change of version shows in the same list.

## Related

- [Git integration](https://docs.apimaker.dev/v4/docs/Git/git.html) · [Secrets](https://docs.apimaker.dev/v4/docs/secrets/secrets.html) · [Developer tools](https://docs.apimaker.dev/v4/docs/features/developer-tools.html)
