|
|
|
|
@@ -33,25 +33,39 @@ A LeafLink-style cannabis marketplace platform built with Laravel, featuring bus
|
|
|
|
|
|
|
|
|
|
| Layer | Technology |
|
|
|
|
|
|-------|------------|
|
|
|
|
|
| **Backend** | Laravel 12 |
|
|
|
|
|
| **Backend** | Laravel 12 (PHP 8.4) |
|
|
|
|
|
| **Frontend** | Blade Templates + Tailwind CSS |
|
|
|
|
|
| **UI Framework** | DaisyUI + Nexus Theme |
|
|
|
|
|
| **Database** | PostgreSQL |
|
|
|
|
|
| **Database** | PostgreSQL 17 |
|
|
|
|
|
| **Cache/Queue** | Redis 7 |
|
|
|
|
|
| **Authentication** | Laravel Breeze |
|
|
|
|
|
| **Admin Panel** | Filament |
|
|
|
|
|
| **Permissions** | Spatie Laravel Permission |
|
|
|
|
|
| **PDF Generation** | Spatie Laravel PDF (Puppeteer) |
|
|
|
|
|
| **Testing** | Pest |
|
|
|
|
|
| **Assets** | Vite |
|
|
|
|
|
| **Containerization** | Docker + Laravel Sail |
|
|
|
|
|
| **Versioning** | CalVer (YYYY.MM-commit) |
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## 📋 Quick Start
|
|
|
|
|
|
|
|
|
|
### **Prerequisites**
|
|
|
|
|
- PHP 8.2+
|
|
|
|
|
- Node.js 18+
|
|
|
|
|
|
|
|
|
|
**Choose your development approach:**
|
|
|
|
|
|
|
|
|
|
**Option A: Docker (Recommended)**
|
|
|
|
|
- Docker Desktop or Colima
|
|
|
|
|
- Docker Compose
|
|
|
|
|
- Git
|
|
|
|
|
|
|
|
|
|
**Option B: Local PHP**
|
|
|
|
|
- PHP 8.4+
|
|
|
|
|
- Node.js 22+
|
|
|
|
|
- Composer 2.x
|
|
|
|
|
- Docker & Docker Compose (for PostgreSQL and Mailpit services)
|
|
|
|
|
- PostgreSQL 17
|
|
|
|
|
- Redis 7
|
|
|
|
|
|
|
|
|
|
### 1. **Clone & Install**
|
|
|
|
|
```bash
|
|
|
|
|
@@ -67,47 +81,54 @@ cp .env.example .env
|
|
|
|
|
php artisan key:generate
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**Configure your `.env`:**
|
|
|
|
|
### 3. **Choose Your Development Environment**
|
|
|
|
|
|
|
|
|
|
#### **Option A: Docker with Laravel Sail (Recommended)**
|
|
|
|
|
|
|
|
|
|
Laravel Sail provides a complete containerized environment with PostgreSQL, Redis, and Mailpit.
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# Start all services
|
|
|
|
|
./vendor/bin/sail up -d
|
|
|
|
|
|
|
|
|
|
# Run migrations
|
|
|
|
|
./vendor/bin/sail artisan migrate --seed
|
|
|
|
|
|
|
|
|
|
# Start asset compilation
|
|
|
|
|
./vendor/bin/sail npm run dev
|
|
|
|
|
|
|
|
|
|
# Visit: http://localhost
|
|
|
|
|
# Mailpit (emails): http://localhost:8025
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**Sail Commands:**
|
|
|
|
|
```bash
|
|
|
|
|
./vendor/bin/sail artisan ... # Run artisan commands
|
|
|
|
|
./vendor/bin/sail composer ... # Run composer
|
|
|
|
|
./vendor/bin/sail npm ... # Run npm
|
|
|
|
|
./vendor/bin/sail php ... # Run PHP scripts
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**Optional:** Create an alias for convenience:
|
|
|
|
|
```bash
|
|
|
|
|
alias sail='./vendor/bin/sail'
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### **Option B: Local PHP Development**
|
|
|
|
|
|
|
|
|
|
Configure `.env` for local services:
|
|
|
|
|
```env
|
|
|
|
|
APP_NAME="Cannabrands"
|
|
|
|
|
APP_URL=http://localhost:8000
|
|
|
|
|
|
|
|
|
|
DB_CONNECTION=pgsql
|
|
|
|
|
DB_HOST=127.0.0.1
|
|
|
|
|
DB_PORT=5432
|
|
|
|
|
DB_DATABASE=cannabrands_app
|
|
|
|
|
DB_USERNAME=root
|
|
|
|
|
DB_PASSWORD=example
|
|
|
|
|
|
|
|
|
|
MAIL_MAILER=smtp
|
|
|
|
|
DB_HOST=127.0.0.1 # or localhost
|
|
|
|
|
REDIS_HOST=127.0.0.1
|
|
|
|
|
MAIL_HOST=127.0.0.1
|
|
|
|
|
MAIL_PORT=1025
|
|
|
|
|
MAIL_USERNAME=null
|
|
|
|
|
MAIL_PASSWORD=null
|
|
|
|
|
# Mailpit for local email testing
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 3. **Database Setup**
|
|
|
|
|
```bash
|
|
|
|
|
# Start Docker services (PostgreSQL + Mailpit)
|
|
|
|
|
docker compose -f docker-compose.dev.yml up -d
|
|
|
|
|
|
|
|
|
|
# Run migrations and seed data
|
|
|
|
|
php artisan migrate --seed
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 4. **Asset Compilation**
|
|
|
|
|
```bash
|
|
|
|
|
npm run dev
|
|
|
|
|
# or for production: npm run build
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 5. **Start Development**
|
|
|
|
|
Start development:
|
|
|
|
|
```bash
|
|
|
|
|
php artisan serve
|
|
|
|
|
# Visit: http://localhost:8000
|
|
|
|
|
npm run dev
|
|
|
|
|
|
|
|
|
|
# View sent emails at: http://localhost:8025 (Mailpit)
|
|
|
|
|
# Visit: http://localhost:8000
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
@@ -152,10 +173,19 @@ php artisan serve
|
|
|
|
|
|
|
|
|
|
## 🔧 Development Commands
|
|
|
|
|
|
|
|
|
|
Commands work with both Sail and local PHP. Prefix with `./vendor/bin/sail` when using Sail.
|
|
|
|
|
|
|
|
|
|
### **Database**
|
|
|
|
|
```bash
|
|
|
|
|
php artisan migrate:fresh --seed # Reset database
|
|
|
|
|
php artisan migrate # Run pending migrations
|
|
|
|
|
php artisan migrate:status # Check migration status
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### **Sail-specific shortcuts:**
|
|
|
|
|
```bash
|
|
|
|
|
make migrate # Run migrations (Sail)
|
|
|
|
|
make fresh # Fresh database with seeds (Sail)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### **Testing**
|
|
|
|
|
@@ -168,6 +198,13 @@ php artisan notifications:test 1 # Test notification system
|
|
|
|
|
```bash
|
|
|
|
|
php artisan optimize:clear # Clear all caches
|
|
|
|
|
php artisan config:cache # Cache configuration
|
|
|
|
|
php artisan route:cache # Cache routes
|
|
|
|
|
php artisan view:cache # Cache views
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### **Versioning**
|
|
|
|
|
```bash
|
|
|
|
|
php artisan version:update # Update CalVer version
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
@@ -198,23 +235,65 @@ php artisan config:cache # Cache configuration
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## 🐳 Development Services
|
|
|
|
|
## 🐳 Docker & Containerization
|
|
|
|
|
|
|
|
|
|
The project uses Docker Compose for development services:
|
|
|
|
|
### **Laravel Sail (Local Development)**
|
|
|
|
|
|
|
|
|
|
Sail provides a complete containerized environment:
|
|
|
|
|
|
|
|
|
|
| Service | Port | Purpose |
|
|
|
|
|
|---------|------|---------|
|
|
|
|
|
| **PostgreSQL** | 5432 | Primary database |
|
|
|
|
|
| **Mailpit** | 8025 (UI), 1025 (SMTP) | Email testing and viewing |
|
|
|
|
|
| **Laravel App** | 80, 5173 | PHP 8.4 application + Vite dev server |
|
|
|
|
|
| **PostgreSQL 17** | 5432 | Primary database |
|
|
|
|
|
| **Redis 7** | 6379 | Cache, sessions, queues |
|
|
|
|
|
| **Mailpit** | 8025 (UI), 1025 (SMTP) | Email testing |
|
|
|
|
|
|
|
|
|
|
**Management commands:**
|
|
|
|
|
```bash
|
|
|
|
|
# Start services
|
|
|
|
|
docker compose -f docker-compose.dev.yml up -d
|
|
|
|
|
|
|
|
|
|
# Stop services
|
|
|
|
|
docker compose -f docker-compose.dev.yml down
|
|
|
|
|
./vendor/bin/sail up -d # Start all services
|
|
|
|
|
./vendor/bin/sail down # Stop all services
|
|
|
|
|
./vendor/bin/sail ps # Check service status
|
|
|
|
|
./vendor/bin/sail logs # View logs
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**Useful Makefile targets:**
|
|
|
|
|
```bash
|
|
|
|
|
make dev # Start Sail containers
|
|
|
|
|
make dev-stop # Stop Sail containers
|
|
|
|
|
make build # Rebuild Sail image
|
|
|
|
|
make migrate # Run migrations
|
|
|
|
|
make fresh # Fresh database with seeds
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### **Production Deployment**
|
|
|
|
|
|
|
|
|
|
Production uses optimized Docker containers with:
|
|
|
|
|
- Multi-stage builds for minimal image size
|
|
|
|
|
- Nginx + PHP-FPM for performance
|
|
|
|
|
- Supervisor for queue workers
|
|
|
|
|
- Health check endpoints
|
|
|
|
|
- Automated deployment scripts
|
|
|
|
|
|
|
|
|
|
**Deploy to production:**
|
|
|
|
|
```bash
|
|
|
|
|
./scripts/deploy.sh
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
See `docker-compose.production.yml` and `Dockerfile` for production configuration.
|
|
|
|
|
|
|
|
|
|
### **Known Limitations**
|
|
|
|
|
|
|
|
|
|
**ARM64 (Apple Silicon) PDF Generation:**
|
|
|
|
|
- Puppeteer's Chrome binaries are x86_64 only
|
|
|
|
|
- PDF generation will NOT work in Sail on ARM Macs
|
|
|
|
|
- **Workarounds:**
|
|
|
|
|
- Test PDFs on x86_64 production servers
|
|
|
|
|
- Use alternative PDF libraries locally (TCPDF, Dompdf)
|
|
|
|
|
- Run with `--platform linux/amd64` (slower emulation)
|
|
|
|
|
- Production deployment on x86_64 servers works perfectly
|
|
|
|
|
|
|
|
|
|
See `CLAUDE.md` for detailed server requirements.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## 📚 Documentation
|
|
|
|
|
@@ -230,7 +309,48 @@ docker compose -f docker-compose.dev.yml down
|
|
|
|
|
|
|
|
|
|
## 🚀 Deployment
|
|
|
|
|
|
|
|
|
|
### **Production Checklist**
|
|
|
|
|
### **Docker Deployment (Recommended)**
|
|
|
|
|
|
|
|
|
|
**Prerequisites:**
|
|
|
|
|
- Docker & Docker Compose installed on server
|
|
|
|
|
- `.env` file configured with production values
|
|
|
|
|
- Git repository access
|
|
|
|
|
|
|
|
|
|
**Quick Deploy:**
|
|
|
|
|
```bash
|
|
|
|
|
./scripts/deploy.sh
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
This script will:
|
|
|
|
|
1. Pull latest code from git
|
|
|
|
|
2. Build production Docker image
|
|
|
|
|
3. Start containers with health checks
|
|
|
|
|
4. Run database migrations
|
|
|
|
|
5. Cache configuration files
|
|
|
|
|
6. Verify application health
|
|
|
|
|
|
|
|
|
|
**Manual Docker Deployment:**
|
|
|
|
|
```bash
|
|
|
|
|
# Build production image
|
|
|
|
|
docker build -t cannabrands/app:latest -f Dockerfile .
|
|
|
|
|
|
|
|
|
|
# Start production containers
|
|
|
|
|
docker-compose -f docker-compose.production.yml up -d
|
|
|
|
|
|
|
|
|
|
# Run migrations
|
|
|
|
|
docker-compose -f docker-compose.production.yml exec -T app php artisan migrate --force
|
|
|
|
|
|
|
|
|
|
# Cache configurations
|
|
|
|
|
docker-compose -f docker-compose.production.yml exec -T app php artisan config:cache
|
|
|
|
|
docker-compose -f docker-compose.production.yml exec -T app php artisan route:cache
|
|
|
|
|
docker-compose -f docker-compose.production.yml exec -T app php artisan view:cache
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### **Traditional Deployment**
|
|
|
|
|
|
|
|
|
|
For non-Docker deployments:
|
|
|
|
|
|
|
|
|
|
**Production Checklist:**
|
|
|
|
|
- [ ] Set `APP_ENV=production` and `APP_DEBUG=false`
|
|
|
|
|
- [ ] Configure production database
|
|
|
|
|
- [ ] Set up SMTP for notification emails
|
|
|
|
|
@@ -239,14 +359,38 @@ docker compose -f docker-compose.dev.yml down
|
|
|
|
|
- [ ] Set up SSL certificate
|
|
|
|
|
- [ ] Configure file storage for document uploads
|
|
|
|
|
|
|
|
|
|
### **Key Production Commands**
|
|
|
|
|
**Key Commands:**
|
|
|
|
|
```bash
|
|
|
|
|
composer install --no-dev --optimize-autoloader
|
|
|
|
|
npm run build
|
|
|
|
|
php artisan config:cache
|
|
|
|
|
php artisan route:cache
|
|
|
|
|
php artisan view:cache
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### **Environment Variables**
|
|
|
|
|
|
|
|
|
|
**Production `.env` template:**
|
|
|
|
|
```env
|
|
|
|
|
APP_ENV=production
|
|
|
|
|
APP_DEBUG=false
|
|
|
|
|
APP_URL=https://your-domain.com
|
|
|
|
|
|
|
|
|
|
DB_CONNECTION=pgsql
|
|
|
|
|
DB_HOST=pgsql # or your database host
|
|
|
|
|
DB_PORT=5432
|
|
|
|
|
DB_DATABASE=cannabrands
|
|
|
|
|
DB_USERNAME=sail
|
|
|
|
|
DB_PASSWORD=your-secure-password
|
|
|
|
|
|
|
|
|
|
CACHE_STORE=redis
|
|
|
|
|
SESSION_DRIVER=redis
|
|
|
|
|
QUEUE_CONNECTION=redis
|
|
|
|
|
REDIS_HOST=redis # or your Redis host
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
See `.env.production.example` for complete configuration template.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## 🔒 Security Notes
|
|
|
|
|
@@ -284,6 +428,6 @@ php artisan view:cache
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**Last Updated**: August 2025
|
|
|
|
|
**Version**: 1.0 (Phase 1)
|
|
|
|
|
**Last Updated**: October 2025
|
|
|
|
|
**Version**: 2025.10 (CalVer)
|
|
|
|
|
**License**: Proprietary
|
|
|
|
|
|