# Pawn Jewelry Shop Backend

Express + MySQL backend for the React Native app.

## Setup

1. Create the database schema:

```bash
mysql -u root -p < database.sql
```

For an existing database created before the customer profile fields were added, run:

```bash
mysql -u root -p pawn_jewelry_shop < database-migrations/001_customer_profile_fields.sql
```

2. Install backend dependencies:

```bash
npm install
```

3. Create backend environment config:

```bash
copy .env.example .env
```

4. Update `.env` with your MySQL credentials and JWT secret.

5. Seed the first owner account:

```bash
npm run seed-owner
```

6. Start the API:

```bash
npm run dev
```

Set a custom port before starting the server:

```bash
$env:PORT=3001
npm run dev
```

Android emulator should use `http://10.0.2.2:4000`.
iOS simulator can use `http://localhost:4000`.

Customer photos are stored in `backend/uploads/customer-photos` and ID proof images are stored in `backend/uploads/id-proofs`. The API serves them from `/uploads/...`.

## API Response Shape

All endpoints return:

```json
{
  "success": true,
  "message": "",
  "data": {}
}
```
