# PriceMate Backend

Minimal Express + TypeScript backend for PriceMate.

## Setup

1. Install dependencies:
   ```bash
   cd backend
   npm install
   ```
2. Create `.env` from the example:
   ```bash
   cp .env.example .env
   ```
3. Add Firebase Admin credentials (choose one):
   - **Path to JSON file**: download a service account key file and set `FIREBASE_SERVICE_ACCOUNT_PATH` to its path (file is not committed), or
   - **JSON in env**: paste the entire JSON into `FIREBASE_SERVICE_ACCOUNT_JSON` (also not committed).

### Getting a Firebase service account key

In the Firebase Console:
1. Go to **Project settings** → **Service accounts**.
2. Click **Generate new private key**.
3. Save the JSON file locally and use one of the methods above to provide it to the backend.

## Development

Start the dev server with watch mode:
```bash
npm run dev
```

### Health check
```bash
curl http://localhost:3001/health
```

### Current user endpoint
Requires a Firebase ID token:
```bash
curl -H "Authorization: Bearer <FIREBASE_ID_TOKEN>" http://localhost:3001/api/me
```

## Build
```bash
npm run build
npm start
```
