Files
smoothschedule/CLAUDE.md

166 lines
4.8 KiB
Markdown

# SmoothSchedule - Multi-Tenant Scheduling Platform
## Quick Reference
### Project Structure
```
/home/poduck/Desktop/smoothschedule2/
├── frontend/ # React + Vite + TypeScript frontend
│ └── CLAUDE.md # Frontend-specific docs
├── smoothschedule/ # Django backend (RUNS IN DOCKER!)
│ └── CLAUDE.md # Backend-specific docs
└── legacy_reference/ # Old code for reference (do not modify)
```
### Development URLs
- **Frontend:** `http://demo.lvh.me:5173` (or any business subdomain)
- **Platform Frontend:** `http://platform.lvh.me:5173`
- **Backend API:** `http://lvh.me:8000/api/`
Note: `lvh.me` resolves to `127.0.0.1` - required for subdomain cookies to work.
## CRITICAL: Backend Runs in Docker
**NEVER run Django commands directly.** Always use Docker Compose:
```bash
cd /home/poduck/Desktop/smoothschedule2/smoothschedule
# Run migrations
docker compose -f docker-compose.local.yml exec django python manage.py migrate
# Django shell
docker compose -f docker-compose.local.yml exec django python manage.py shell
# View logs
docker compose -f docker-compose.local.yml logs -f django
# Any management command
docker compose -f docker-compose.local.yml exec django python manage.py <command>
```
## Key Configuration Files
### Backend (Django)
| File | Purpose |
|------|---------|
| `smoothschedule/docker-compose.local.yml` | Docker services config |
| `smoothschedule/.envs/.local/.django` | Django env vars (SECRET_KEY, etc.) |
| `smoothschedule/.envs/.local/.postgres` | Database credentials |
| `smoothschedule/config/settings/local.py` | Local Django settings |
| `smoothschedule/config/settings/base.py` | Base Django settings |
| `smoothschedule/config/urls.py` | URL routing |
### Frontend (React)
| File | Purpose |
|------|---------|
| `frontend/.env.development` | Vite env vars |
| `frontend/vite.config.ts` | Vite configuration |
| `frontend/src/api/client.ts` | Axios API client |
| `frontend/src/types.ts` | TypeScript interfaces |
| `frontend/src/i18n/locales/en.json` | Translations |
## Key Django Apps
| App | Location | Purpose |
|-----|----------|---------|
| `schedule` | `smoothschedule/smoothschedule/schedule/` | Resources, Events, Services |
| `users` | `smoothschedule/smoothschedule/users/` | Authentication, User model |
| `tenants` | `smoothschedule/smoothschedule/tenants/` | Multi-tenancy (Business model) |
## Common Tasks
### After modifying Django models:
```bash
cd /home/poduck/Desktop/smoothschedule2/smoothschedule
docker compose -f docker-compose.local.yml exec django python manage.py makemigrations
docker compose -f docker-compose.local.yml exec django python manage.py migrate
```
### After modifying frontend:
Frontend hot-reloads automatically. If issues, restart:
```bash
cd /home/poduck/Desktop/smoothschedule2/frontend
npm run dev
```
### Debugging 500 errors:
```bash
cd /home/poduck/Desktop/smoothschedule2/smoothschedule
docker compose -f docker-compose.local.yml logs django --tail=100
```
### Testing API directly:
```bash
curl -s "http://lvh.me:8000/api/resources/" | jq
```
## Git Branch
Currently on: `feature/platform-superuser-ui`
Main branch: `main`
## Production Deployment
### Quick Deploy
```bash
# From your local machine
cd /home/poduck/Desktop/smoothschedule2
./deploy.sh poduck@smoothschedule.com
```
### Initial Server Setup (one-time)
```bash
# Setup server dependencies
ssh poduck@smoothschedule.com 'bash -s' < server-setup.sh
# Setup DigitalOcean Spaces
ssh poduck@smoothschedule.com
./setup-spaces.sh
```
### Production URLs
- **Main site:** `https://smoothschedule.com`
- **Platform dashboard:** `https://platform.smoothschedule.com`
- **Tenant subdomains:** `https://*.smoothschedule.com`
- **Flower (Celery):** `https://smoothschedule.com:5555`
### Production Management
```bash
# SSH into server
ssh poduck@smoothschedule.com
# Navigate to project
cd ~/smoothschedule
# View logs
docker compose -f docker-compose.production.yml logs -f
# Run migrations
docker compose -f docker-compose.production.yml exec django python manage.py migrate
# Create superuser
docker compose -f docker-compose.production.yml exec django python manage.py createsuperuser
# Restart services
docker compose -f docker-compose.production.yml restart
# View status
docker compose -f docker-compose.production.yml ps
```
### Environment Variables
Production environment configured in:
- **Backend:** `smoothschedule/.envs/.production/.django`
- **Database:** `smoothschedule/.envs/.production/.postgres`
- **Frontend:** `frontend/.env.production`
### DigitalOcean Spaces
- **Bucket:** `smoothschedule`
- **Region:** `nyc3`
- **Endpoint:** `https://nyc3.digitaloceanspaces.com`
- **Public URL:** `https://smoothschedule.nyc3.digitaloceanspaces.com`
See [DEPLOYMENT.md](DEPLOYMENT.md) for detailed deployment guide.