← back to Handbag Auth Nextjs

SERVER_DEPLOYMENT.md

227 lines

# 🚀 Handbag Authentication Platform - Server Deployment Complete!

## ✅ Status: LIVE & RUNNING

Your Next.js handbag authentication platform is now running on your server with PM2!

## 🌐 Access URLs

- **Public URL**: http://45.61.58.125:7990
- **Local URL**: http://localhost:7990

⚠️ **Note**: Port 3000 is reserved for Cloudflare - never use it!

## 📊 PM2 Status

```bash
pm2 list | grep handbag
```

Shows:
- **handbag-nextjs** - Port 3000 (New Next.js app) ✅ ONLINE
- **handbag-auth** - Port 7989 (Old Express app) - Still running if needed

## 🔧 Management Commands

### View Status
```bash
pm2 status handbag-nextjs
```

### View Logs (Real-time)
```bash
pm2 logs handbag-nextjs
```

### View Logs (Last 100 lines)
```bash
pm2 logs handbag-nextjs --lines 100
```

### Restart
```bash
pm2 restart handbag-nextjs
```

### Stop
```bash
pm2 stop handbag-nextjs
```

### Start
```bash
pm2 start handbag-nextjs
```

### Monitor
```bash
pm2 monit
```

## 🔄 Auto-Start on Reboot

PM2 is configured to automatically start on server reboot:
- ✅ PM2 startup script installed
- ✅ Process list saved
- ✅ Will survive server restarts

## 📁 Project Location

```
/root/Projects/handbag-auth-nextjs/
```

## 🔌 Port Configuration

- **Application Port**: 7990
- **Firewall**: Port 7990 is open (already configured)
- **Note**: Port 3000 is RESERVED for Cloudflare - never use!

## 🗄️ Database

- **Type**: SQLite
- **Location**: `./data/handbags.db`
- **Status**: Empty (ready for data import)

## 🎯 Next Steps

### 1. Populate Database

To add handbag listings, you can:

**Option A: Import from old database**
```bash
cd /root/Projects/handbag-auth-nextjs
cp /root/Projects/handbag-authentication/data/handbags.db ./data/
pm2 restart handbag-nextjs
```

**Option B: Run crawlers**
```bash
# From the old project
cd /root/Projects/handbag-authentication
npm run crawler
```

### 2. Test the Application

Visit these pages:
- **Home**: http://45.61.58.125:3000
- **Camera**: http://45.61.58.125:3000/camera
- **API Stats**: http://45.61.58.125:3000/api/stats
- **API Listings**: http://45.61.58.125:3000/api/listings?limit=10

### 3. Configure API Keys

Make sure you have these in `.env.local`:
```bash
cd /root/Projects/handbag-auth-nextjs
nano .env.local
```

Required:
```
DATABASE_URL="file:./data/handbags.db"
GEMINI_API_KEY=your_gemini_key_here
```

Optional:
```
OPENAI_API_KEY=your_openai_key_here
SLACK_WEBHOOK_URL=your_slack_webhook
```

After editing, restart:
```bash
pm2 restart handbag-nextjs
```

## 🔍 Troubleshooting

### Check if running
```bash
pm2 list | grep handbag-nextjs
```

### Check logs for errors
```bash
pm2 logs handbag-nextjs --err --lines 50
```

### Restart if needed
```bash
pm2 restart handbag-nextjs
```

### View detailed info
```bash
pm2 describe handbag-nextjs
```

### Test connectivity
```bash
curl http://localhost:3000
curl http://45.61.58.125:3000
```

## 📱 Features Available

✅ Responsive UI with Tailwind CSS
✅ Mobile camera access for handbag scanning
✅ AI-powered image analysis (Google Gemini)
✅ Search and filtering
✅ Deal detection
✅ API endpoints for listings, deals, stats
✅ SQLite database with Prisma ORM
✅ Production-optimized build
✅ PM2 process management
✅ Auto-restart on crash
✅ Auto-start on server reboot

## 🆚 Comparison with Old App

| Feature | Old (Express) | New (Next.js) | Port |
|---------|---------------|---------------|------|
| Framework | Express.js | Next.js 15 | - |
| UI | EJS Templates | React + Tailwind | - |
| Port | 7989 | 3000 | ✅ |
| Status | Running | Running | ✅ |
| Type Safety | No | Full TypeScript | ✅ |
| ORM | SQLite (raw) | Prisma | ✅ |
| Mobile | Basic | Optimized | ✅ |
| Build | None | Optimized | ✅ |

## 🎉 Deployment Summary

✅ **Application built for production**
✅ **Running on PM2 (process ID: 78)**
✅ **Accessible at port 3000**
✅ **Auto-start enabled**
✅ **Firewall configured**
✅ **Database initialized**
✅ **Production-ready**

## 📞 Support

For issues:
1. Check PM2 logs: `pm2 logs handbag-nextjs`
2. Restart if needed: `pm2 restart handbag-nextjs`
3. Check database exists: `ls -la data/handbags.db`
4. Verify port is open: `sudo ufw status | grep 3000`

## 🔐 Security Notes

- API keys are stored in `.env.local` (not committed to git)
- Database is local SQLite file
- No external dependencies for database
- CORS configured for security
- Input validation on all endpoints

---

**Deployment completed**: November 14, 2025
**Server**: 45.61.58.125
**Port**: 3000
**Process Manager**: PM2
**Status**: ✅ ONLINE & RUNNING