# AI Tender Copilot - Setup Guide

## Database Status

**PostgreSQL Database Created:**
- Database: `munafasaai`
- User: `munafasaai`
- Host: `127.0.0.1:5433`
- Tables: 26 tables created

## Quick Start

### 1. Configure Environment Variables

Edit `.env` file and add your API keys:
- `CLERK_PUBLISHABLE_KEY` & `CLERK_SECRET_KEY` - Get from [Clerk Dashboard](https://dashboard.clerk.com/)
- `OPENAI_API_KEY` - Get from [OpenAI Platform](https://platform.openai.com/api-keys)
- `STRIPE_SECRET_KEY` & `STRIPE_WEBHOOK_SECRET` - Get from [Stripe Dashboard](https://dashboard.stripe.com/)
- `RESEND_API_KEY` - Get from [Resend](https://resend.com/api-keys)

### 2. Start the Application

```bash
# Start API server (port 8080)
pnpm --filter @workspace/api-server run dev

# In another terminal, start frontend
pnpm --filter @workspace/tender-copilot run dev
```

Or use the start script:
```bash
./start.sh
```

## Project Structure

```
munafasaai.com/
├── artifacts/
│   ├── api-server/       # Express backend (port 8080)
│   └── tender-copilot/   # React frontend
├── lib/
│   ├── db/               # Drizzle ORM schema
│   ├── api-spec/         # OpenAPI specification
│   └── api-client-react/ # Generated React hooks
├── setup.sh              # Setup script
├── start.sh              # Start script
└── .env                  # Environment variables
```

## Common Commands

```bash
# Install dependencies
pnpm install --ignore-scripts

# Push database schema changes
pnpm --filter @workspace/db run push

# Type checking
pnpm run typecheck

# Generate API from OpenAPI spec
pnpm --filter @workspace/api-spec run codegen
```

## Database Connection

```
postgresql://munafasaai:munafasaai_password_2026@127.0.0.1:5433/munafasaai
```

## Notes

- The project uses pnpm workspaces with supply-chain protection (1-day minimum release age)
- PostgreSQL is running on port 5433 (not default 5432)
- The uploads directory is created automatically at `artifacts/api-server/uploads/`
