Data Models
Comprehensive guide to UltraReach.ai's data models, their relationships, and how to work with them effectively in your applications.
Lead Model
{
"id": "lead_123",
"created_at": "2025-02-07T02:55:00Z",
"updated_at": "2025-02-07T02:55:00Z",
"status": "active",
"score": 85,
"contact": {
"first_name": "John",
"last_name": "Doe",
"email": "john@example.com",
"phone": "+1234567890"
},
"preferences": {
"property_types": ["apartment", "house"],
"price_range": {
"min": 300000,
"max": 500000
},
"locations": ["downtown", "suburbs"],
"bedrooms": { "min": 2, "max": 3 },
"bathrooms": { "min": 1, "max": 2 }
},
"engagement": {
"last_contact": "2025-02-06T00:00:00Z",
"total_interactions": 15,
"preferred_contact_time": "evening"
}
}Property Model
{
"id": "prop_456",
"created_at": "2025-02-07T02:55:00Z",
"updated_at": "2025-02-07T02:55:00Z",
"status": "active",
"type": "apartment",
"details": {
"price": 450000,
"bedrooms": 2,
"bathrooms": 2,
"square_feet": 1200,
"year_built": 2020
},
"location": {
"address": "123 Main St",
"city": "Example City",
"state": "EX",
"zip": "12345",
"coordinates": {
"latitude": 37.7749,
"longitude": -122.4194
}
},
"features": [
"parking",
"pool",
"gym"
],
"media": {
"photos": ["url1", "url2"],
"virtual_tour": "tour_url",
"floor_plan": "plan_url"
}
}Relationship Models
Property Match
{
"id": "match_789",
"lead_id": "lead_123",
"property_id": "prop_456",
"created_at": "2025-02-07T02:55:00Z",
"score": 92,
"match_factors": [
"price_range",
"location",
"bedrooms"
],
"status": "presented",
"lead_feedback": "interested"
}Interaction
{
"id": "int_101",
"lead_id": "lead_123",
"type": "message",
"created_at": "2025-02-07T02:55:00Z",
"channel": "email",
"content": "Inquiry about property",
"sentiment": "positive",
"ai_analysis": {
"intent": "information_request",
"urgency": "medium"
}
}Market Analysis
{
"id": "analysis_202",
"property_id": "prop_456",
"created_at": "2025-02-07T02:55:00Z",
"market_data": {
"median_price": 460000,
"price_trend": "+5%",
"days_on_market": 30,
"comparable_properties": [
"prop_457",
"prop_458"
]
},
"predictions": {
"estimated_value": 455000,
"appreciation_rate": "3.5%",
"sale_probability": 0.85
}
}Agent Assignment
{
"id": "assignment_303",
"lead_id": "lead_123",
"agent_id": "agent_789",
"created_at": "2025-02-07T02:55:00Z",
"status": "active",
"match_score": 88,
"match_factors": [
"expertise",
"location",
"language"
],
"performance": {
"response_time": "2h",
"satisfaction_score": 4.8
}
}Model Relationships
- •Lead → Properties (many-to-many)
- •Lead → Interactions (one-to-many)
- •Property → Analysis (one-to-many)
- •Lead → Agent (many-to-one)
Data Validation
- •Required fields validation
- •Data type checking
- •Format validation
- •Relationship integrity
Common Operations
GET/api/v1/leads/:id
POST/api/v1/properties
PUT/api/v1/matches/:id
Working with Models
Create
Create new instances with proper validation
Query
Fetch and filter data efficiently
Update
Modify existing records safely
Delete
Handle deletions with care