Laravel 10 REST API backend for the Nexa platform, providing authentication, campaign management, real-time chat, payment processing, and administrative features.
- Overview
- Features
- Requirements
- Installation
- Configuration
- Database Setup
- Real-time (Laravel Reverb)
- API Documentation
- Development
- Testing
- Deployment
The Nexa Backend is built with Laravel 10 and provides a comprehensive REST API for:
- User authentication and authorization (Laravel Sanctum)
- Campaign creation and management
- Real-time chat functionality (Laravel Reverb)
- Payment processing (Stripe integration)
- Admin dashboard and user management
- Portfolio management for creators
- Contract and offer management
- Student verification system
-
Authentication & Authorization
- Email/password authentication
- Google OAuth integration
- Role-based access control (Admin, Creator, Brand, Student)
- Account status management (Active, Blocked, Removed)
- Password reset functionality
-
Campaign Management
- Campaign creation and editing
- Campaign approval workflow
- Bid management
- Campaign applications
- Campaign timeline tracking
-
Real-time Chat
- Reverb integration
- Message history
- Typing indicators
- Read receipts
- File attachments
-
Payment Processing
- Stripe payment integration
- Subscription management
- Withdrawal processing
- Payment method management
- Automatic payment processing
-
Admin Features
- Dashboard with metrics
- User management (Creators, Brands, Students)
- Campaign approval/rejection
- Guide management
- Brand rankings
- Withdrawal verification
-
Additional Features
- Portfolio management
- Contract management
- Offer system
- Review system
- Notification system
- Student verification
- Guide system
- PHP >= 8.1 with extensions:
- BCMath, Ctype, Fileinfo, JSON, Mbstring, OpenSSL, PDO, Tokenizer, XML
- PostgreSQL >= 13 (Supabase recomendado)
- Redis (for caching and queues)
-
Install PHP dependencies:
composer install
-
Copy environment file:
cp .env.example .env
-
Generate application key:
php artisan key:generate
-
Create storage link:
php artisan storage:link
-
Set up storage directories:
php artisan storage:setup-directories
Edit .env file with your configuration:
# Application
APP_NAME="Nexa Platform"
APP_ENV=local
APP_KEY=base64:... # Generated by php artisan key:generate
APP_DEBUG=true
APP_URL=http://localhost:8000
APP_TIMEZONE=UTC
# Database (PostgreSQL / Supabase)
DB_CONNECTION=pgsql
DB_HOST=your-supabase-host.supabase.co
DB_PORT=5432
DB_DATABASE=postgres
DB_USERNAME=postgres
DB_PASSWORD=your-password
# Redis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
# Mail (AWS SES)
MAIL_MAILER=ses
MAIL_FROM_ADDRESS=noreply@nexacreators.com.br
MAIL_FROM_NAME="${APP_NAME}"
# AWS Configuration
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
AWS_DEFAULT_REGION=us-east-1
AWS_SES_REGION=us-east-1
# Stripe
STRIPE_SECRET=sk_test_your_stripe_secret_key
STRIPE_PUBLISHABLE_KEY=pk_test_your_stripe_publishable_key
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret
# Pusher (optional, for broadcasting)
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
# Session & Cache
SESSION_DRIVER=redis
CACHE_DRIVER=redis
QUEUE_CONNECTION=redis
# Sanctum
SANCTUM_STATEFUL_DOMAINS=localhost:5173,localhost:3000
SESSION_DOMAIN=localhost-
Create the database:
CREATE DATABASE nexa_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
Run migrations:
php artisan migrate
-
Seed the database (optional):
php artisan db:seed
O Nexa utiliza Laravel Reverb para funcionalidades em tempo real (Chat).
Development:
php artisan reverb:start --debugProduction:
php artisan reverb:startPara mais detalhes sobre a configuração, consulte a documentação oficial do Laravel Reverb.
http://localhost:8000/api
All protected routes require a Bearer token in the Authorization header:
Authorization: Bearer {token}
POST /api/login- User loginPOST /api/register- User registrationPOST /api/logout- User logoutPOST /api/forgot-password- Request password resetPOST /api/reset-password- Reset passwordGET /api/auth/google- Google OAuth redirectGET /api/auth/google/callback- Google OAuth callback
GET /api/campaigns- List campaignsPOST /api/campaigns- Create campaignGET /api/campaigns/{id}- Get campaign detailsPUT /api/campaigns/{id}- Update campaignDELETE /api/campaigns/{id}- Delete campaignPOST /api/campaigns/{id}/apply- Apply to campaignGET /api/campaigns/{id}/bids- Get campaign bids
GET /api/chat/rooms- Get user's chat roomsGET /api/chat/rooms/{roomId}/messages- Get messagesPOST /api/chat/rooms- Create chat roomPOST /api/chat/messages- Send messagePOST /api/chat/mark-read- Mark messages as read
POST /api/payment/process- Process paymentPOST /api/stripe/create-payment-intent- Create Stripe payment intentPOST /api/stripe/webhook- Stripe webhook handlerGET /api/subscription/plans- Get subscription plans
# Run migrations
php artisan migrate
# Rollback last migration
php artisan migrate:rollback
# Create new migration
php artisan make:migration create_table_name
# Run seeders
php artisan db:seed
# Clear cache
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear
# Optimize for production
php artisan config:cache
php artisan route:cache
php artisan view:cache
# Generate IDE helper
php artisan ide-helper:generate
php artisan ide-helper:models
php artisan ide-helper:metaThe backend follows a Simplified Domain-Driven Design (DDD) architecture. For a detailed guide, see ARCHITECTURE.md.
app/
├── Domain/ # Core Business Logic (DDD)
│ ├── Campaign/ # Campaign Domain (Services, Actions)
│ ├── Payment/ # Payment Domain
│ ├── Contract/ # Contract Domain
│ └── Notification/ # Notification Domain
├── Http/
│ ├── Controllers/ # API Controllers (grouped by Domain)
│ │ ├── Auth/
│ │ ├── Campaign/
│ │ └── Payment/
├── Models/ # Eloquent Models (grouped by Domain)
│ ├── User/
│ ├── Campaign/
│ └── Payment/
database/ ├── migrations/ # Database migrations ├── seeders/ # Database seeders └── factories/ # Model factories
routes/ ├── api.php # API routes └── auth.php # Authentication routes
config/ # Configuration files storage/ # File storage public/ # Public assets
## 🧪 Testing
```bash
# Run all tests
php artisan test
# Run specific test file
php artisan test tests/Feature/AdminControllerTest.php
# Run with coverage
php artisan test --coverage
-
Environment Configuration:
APP_ENV=production APP_DEBUG=false
-
Optimize Application:
php artisan config:cache ...
-
Run Migrations:
php artisan migrate --force
- PHP 8.1+ with required extensions
- Composer
- PostgreSQL 13+
- Redis
- Web server (Nginx/Apache)
- SSL certificate (for HTTPS)
- All API routes are protected with Laravel Sanctum
- Admin routes require admin role middleware
- Rate limiting on authentication routes
- CSRF protection for web routes
- Input validation on all requests
- SQL injection protection via Eloquent ORM
- XSS protection via Blade templating
This project is licensed under the MIT License.
- Fork the repository
- Create a feature branch
- Make your changes
- Write tests
- Submit a pull request
For issues and questions, please open an issue on the repository.
Note: Certifique-se de configurar todas as variáveis de ambiente no arquivo .env. O Laravel Reverb deve estar rodando para as funcionalidades de chat em tempo real funcionarem.