# Aircall Server

A standalone server for handling Aircall metrics and data processing.

## Setup

1. Install dependencies:
```bash
npm install
```

2. Set up environment variables:
```bash
cp .env.example .env
```
Then edit `.env` with your configuration.

Required environment variables:
- `AIRCALL_API_ID`: Your Aircall API ID
- `AIRCALL_API_TOKEN`: Your Aircall API Token
- `MONGODB_URI`: MongoDB connection string
- `REDIS_URL`: Redis connection string
- `AIRCALL_PORT`: Server port (default: 3002)

## Running the Server

### Development
```bash
npm run dev
```

### Production
Using PM2:
```bash
pm2 start ecosystem.config.js --env production
```

## API Endpoints

### GET /api/aircall/metrics/:timeRange
Get Aircall metrics for a specific time range.

Parameters:
- `timeRange`: One of ['today', 'yesterday', 'last7days', 'last30days', 'last90days']

### GET /api/aircall/health
Get server health status.

## Architecture

The server uses:
- Express.js for the API
- MongoDB for data storage
- Redis for caching
- Winston for logging 