# 🚀 GPSF-MIS Quick Reference

## One Command Setup

```bash
docker-compose up -d
```

## Access Points

| Service       | URL                                 | Credentials                |
| ------------- | ----------------------------------- | -------------------------- |
| Frontend      | http://localhost:3001               | admin@gmail.com / 12345678 |
| Backend API   | http://localhost:3002               | -                          |
| Prisma Studio | http://localhost:5555               | -                          |
| API Docs      | http://localhost:3002/api/v1/docs   | -                          |
| Health Check  | http://localhost:3002/api/v1/health | -                          |

## Common Commands

### Using Make (Recommended)

```bash
make up           # Start all services
make down         # Stop all services
make logs         # View logs
make build        # Rebuild services
make ps           # Show status
make migrate      # Run migrations
make seed         # Seed database
```

### Using Docker Compose

```bash
docker-compose up -d              # Start
docker-compose down               # Stop
docker-compose logs -f            # Logs
docker-compose ps                 # Status
docker-compose restart backend    # Restart service
```

### Using the Script

```bash
./start.sh        # Automated startup with checks
```

## Service Management

### View Logs

```bash
docker-compose logs -f backend
docker-compose logs -f frontend
docker-compose logs -f postgres
```

### Restart a Service

```bash
docker-compose restart backend
docker-compose restart frontend
```

### Access Container Shell

```bash
docker exec -it gpsf-mis-backend sh
docker exec -it gpsf-mis-frontend sh
docker exec -it gpsf-mis-postgres psql -U khonvakhim -d GPSF_MIS_DB
```

## Database Operations

### Manual Migration

```bash
docker exec -it gpsf-mis-backend npx prisma migrate deploy
```

### Manual Seeding

```bash
docker exec -it gpsf-mis-backend npm run prisma:seed
```

### Prisma Studio

Prisma Studio runs automatically with docker-compose and is accessible at:

```bash
http://localhost:5555
```

Or use the make command to open it in your browser:

```bash
make studio
```

### Full Reset (⚠️ Deletes all data)

```bash
docker-compose down -v
docker-compose up -d
```

## Troubleshooting

### Check Service Health

```bash
docker-compose ps
curl http://localhost:3006/health
```

### View All Logs

```bash
docker-compose logs -f
```

### Rebuild After Code Changes

```bash
docker-compose up -d --build
```

### Clean Everything

```bash
docker-compose down -v
docker system prune -a
```

## Environment Variables

Edit `.env` file to customize:

- Database credentials
- JWT secret
- Email settings
- Seeding options
- API ports

## File Structure

```
GPSF-MIS/
├── docker-compose.yml      # Main orchestration
├── .env                     # Configuration
├── start.sh                 # Startup script
├── Makefile                 # Convenience commands
├── DOCKER-README.md         # Full documentation
├── backend/
│   ├── Dockerfile
│   └── docker-entrypoint.sh
└── frontend/
    └── Dockerfile
```

## Default Configuration

- **Database**: PostgreSQL 18 on port 5432
- **Backend**: NestJS on port 3002
- **Frontend**: Next.js on port 3000
- **Auto-migration**: ✅ Enabled
- **Auto-seeding**: ✅ Enabled (first run)

## Production Notes

1. Change `.env` sensitive values:
   - `DB_PASSWORD`
   - `JWT_SECRET`
   - `RESEND_API_KEY`

2. Set `SEED_DATABASE=false` after initial setup

3. Use `backend/docker-compose.prod.yml` for production deployment

---

For detailed documentation, see [DOCKER-README.md](DOCKER-README.md)
