CRM Service
The CRM (Customer Relationship Management) service manages customer data, email campaigns, contact history, and customer segmentation for each tenant.
Architecture
Tenant Frontend ──┐
Webshop Service ──┤──▶ CRM Backend (Laravel 12)
Webhook Service ──┘ │
├──▶ PostgreSQL (crm schema)
├──▶ Redis (cache, queued emails)
├──▶ RabbitMQ (customer events)
└──▶ SMTP (email delivery)
Key Features
Customer Management
- Customer profiles with contact details
- Purchase history aggregation from Webshop
- Customer segmentation and tagging
- Notes and interaction history
Email Campaigns
- Campaign creation with template editor
- Audience targeting via segments
- Scheduled and immediate sending
- Open/click tracking
Communication
- Email templates with variable substitution
- Automated transactional emails (order confirmation, shipping, etc.)
- Customer notification preferences
API Endpoints
Base URL: https://{tenant}.vecton.hu/api/crm (production) | http://localhost:8012/api (dev)
Customers
| Method | Endpoint | Description |
|---|---|---|
| GET | /customers | List customers (paginated, searchable) |
| GET | /customers/{id} | Get customer details |
| POST | /customers | Create customer |
| PUT | /customers/{id} | Update customer |
| GET | /customers/{id}/orders | Customer's order history |
| GET | /customers/{id}/activity | Customer interaction log |
Segments
| Method | Endpoint | Description |
|---|---|---|
| GET | /segments | List customer segments |
| POST | /segments | Create segment with rules |
| GET | /segments/{id}/customers | Customers in segment |
Campaigns
| Method | Endpoint | Description |
|---|---|---|
| GET | /campaigns | List email campaigns |
| POST | /campaigns | Create campaign |
| POST | /campaigns/{id}/send | Send campaign |
| GET | /campaigns/{id}/stats | Campaign analytics |
Events
| Event | Trigger | Consumers |
|---|---|---|
customer.created | New customer registered | Analytics, Webhook |
customer.updated | Customer data changed | Webhook |
campaign.sent | Email campaign sent | Analytics |
email.opened | Email opened (tracking pixel) | Analytics |
email.clicked | Link clicked in email | Analytics |
Database Schema
| Table | Description |
|---|---|
customers | Customer profiles |
customer_addresses | Shipping/billing addresses |
customer_tags | Customer segmentation tags |
segments | Segment definitions with rules |
campaigns | Email campaigns |
campaign_recipients | Campaign target list |
email_templates | Reusable email templates |
interactions | Customer interaction log |
Configuration
| Variable | Description | Default |
|---|---|---|
APP_URL | Service base URL | http://localhost:8012 |
DB_SCHEMA | Database schema | crm |
MAIL_MAILER | Email driver | smtp |
MAIL_FROM_ADDRESS | Default sender email | noreply@vecton.hu |
Development
cd tenant/tenant-backend-crm
composer install
php artisan migrate --seed
php artisan serve --port=8012