# Asset Browser

A self-hosted web application for browsing and managing assets pulled from Syncro MSP. Provides role-based access for technicians and clients, barcode label generation, and a label queue for batch printing.

Built by Carmichael Computing.

---

## Requirements

- Node.js 22 or higher
- PM2 (`npm install -g pm2`)
- A Syncro MSP account with API access
- A reverse proxy (nginx recommended) for production

---

## Installation

**1. Clone the repository and install dependencies**

```
git clone https://git.farmtowntech.com/setonc/asset_browser.git
cd asset_browser
npm install
```

**2. Configure environment**

```
cp .env.example .env
```

Edit `.env` and fill in the following:

- `SESSION_SECRET` — a long random string, generate one with:
  ```
  node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"
  ```
- `SYNCRO_BASE_URL` — your Syncro API base URL, e.g. `https://yoursubdomain.syncromsp.com/api/v1`
- `SYNCRO_API_KEY` — your Syncro API key

**3. Configure the client**

Edit `public/config.js` and update the `syncro` block with your Syncro subdomain and base URL.

**4. Update the PM2 config**

Edit `ecosystem.config.js` and set `cwd` to the absolute path of the installation directory, and update `name` if desired.

**5. Create the first admin user**

```
npm run create-user
```

Follow the prompts. Choose the `superduperadmin` role for full access.

**6. Start the server**

```
pm2 start ecosystem.config.js
pm2 save
```

The server listens on port 3000 by default. Point your reverse proxy at it.

---

## User Management

The `create-user` script handles all user management from the command line:

```
npm run create-user                   # create a new user (interactive)
npm run create-user list              # list all users
npm run create-user deactivate <id>   # deactivate a user
npm run create-user reset <id>        # reset a user's password
```

---

## Roles

| Role             | Access                                      |
|------------------|---------------------------------------------|
| superduperadmin  | Full access including server management     |
| admin            | User management and all standard features   |
| tech             | Asset browsing, label printing              |
| client           | Read-only access scoped to their company    |
