9.7 KiB
MCC (Mail, Calendar, Contacts) Specification
This document outlines the data models for the MCC system, which is designed to be a self-hosted alternative to Google's Mail, Calendar, and Contacts services with full control over data.
Overview
The MCC system consists of three main components:
- Mail: A messaging system that can be used for email as well as chat
- Calendar: A calendar system for managing events and appointments
- Contacts: A contact management system
All components are integrated with the circle.User
model, which serves as the primary user model for the system.
Data Models
User Model
The user model is defined in circle/user.v
and has been enhanced with additional fields for MCC functionality:
// User represents a member of a circle
pub struct User {
base.Base
pub mut:
name string // name of the member as used in this circle
description string // optional description which is relevant to this circle
role Role // role of the member in the circle
contact_ids []u32 // IDs of contacts linked to this member
wallet_ids []u32 // IDs of wallets owned by this member which are relevant to this circle
pubkey string // public key of the member as used in this circle
// Additional fields needed for MCC functionality
email string // Primary email address
timezone string // User's preferred timezone
preferences UserPreferences // User preferences for MCC
}
// UserPreferences represents user preferences for MCC
pub struct UserPreferences {
pub mut:
default_calendar_id u32 // Default calendar ID
default_view string // Default view (day, week, month)
email_signature string // Default email signature
theme string // UI theme preference
notifications bool // Enable/disable notifications
}
Mail Models
The mail models are defined in mcc/message.v
:
// Message represents an email message
pub struct Message {
base.Base
pub mut:
id u32 // Database ID
message_id string // Unique identifier for the email
conversation_id string // ID for grouping messages in the same thread
folder string // The folder this email belongs to (inbox, sent, drafts, etc.)
labels []string // Google-style labels for organization
message string // The email body content
attachments []Attachment // Any file attachments
send_time ourtime.OurTime
date i64 // Unix timestamp when the email was sent/received
size u32 // Size of the message in bytes
read bool // Whether the email has been read
flagged bool // Whether the email has been flagged/starred
priority string // Priority level (high, normal, low)
// Header information
subject string
from []u32 // List of user IDs who sent the email
sender []u32
reply_to []u32
to []u32
cc []u32
bcc []u32
in_reply_to u32
// Additional fields
draft bool // Whether this is a draft message
scheduled_send ourtime.OurTime // Time to send if scheduled
}
// Attachment represents an email attachment
pub struct Attachment {
pub mut:
filename string
content_type string
hash string // Hash of the attachment data
size u32 // Size in bytes
content []byte // Optional, for storing small attachments directly
}
Calendar Models
The calendar models are defined in mcc/calendar.v
:
// Calendar represents a collection of events
pub struct Calendar {
base.Base
pub mut:
name string // Name of the calendar
description string // Description of the calendar
color string // Color for the calendar
owner_id u32 // User who owns this calendar
timezone string // Default timezone for this calendar
visibility string // Public, private, etc.
shared_with []CalendarShare // Users this calendar is shared with
}
// CalendarShare represents calendar sharing permissions
pub struct CalendarShare {
pub mut:
user_id u32 // User ID this calendar is shared with
permission string // Read, write, owner, etc.
}
// CalendarEvent represents a calendar event with all its properties
pub struct CalendarEvent {
base.Base
pub mut:
calendar_id u32 // ID of the calendar this event belongs to
title string // Event title
description string // Event details
location string // Event location
start_time ourtime.OurTime
end_time ourtime.OurTime // End time
all_day bool // True if it's an all-day event
recurrence string // RFC 5545 Recurrence Rule (e.g., "FREQ=DAILY;COUNT=10")
attendees []Attendee // List of attendees
organizer u32 // The user who created the event
status string // "CONFIRMED", "CANCELLED", "TENTATIVE"
color string // User-friendly color categorization
reminders []Reminder // Reminders for this event
timezone string // Timezone for this specific event
visibility string // Public, private, etc.
attachments []Attachment // Attachments for this event
}
// Reminder represents a reminder for an event
pub struct Reminder {
pub mut:
event_id u32 // Event this reminder is for
time ourtime.OurTime // When to send the reminder
method string // How to deliver the reminder (email, notification, etc.)
}
// Attendee represents an attendee of an event
pub struct Attendee {
pub mut:
user_id u32 // User ID of the attendee
email string // Email of the attendee (for external attendees)
name string // Name of the attendee
response string // "ACCEPTED", "DECLINED", "TENTATIVE", "NEEDS-ACTION"
optional bool // Whether attendance is optional
comment string // Attendee's comment
}
Contacts Models
The contacts models are defined in mcc/contacts.v
:
// Contact represents a contact with all their information
pub struct Contact {
base.Base
pub mut:
name string // Display name of the contact
first_name string
last_name string
nickname string
email []ContactEmail // Multiple email addresses with labels
phone []ContactPhone // Multiple phone numbers with labels
address []ContactAddress // Multiple addresses with labels
company string
job_title string
notes string
birthday ourtime.OurTime
website []string
social_profiles []SocialProfile
photo string // Path or URL to contact photo
groups []u32 // IDs of groups this contact belongs to
custom_fields []CustomField // User-defined fields
}
// ContactEmail represents an email address with a label
pub struct ContactEmail {
pub mut:
email string
label string // Home, Work, Other, etc.
primary bool
}
// ContactPhone represents a phone number with a label
pub struct ContactPhone {
pub mut:
number string
label string // Mobile, Home, Work, etc.
primary bool
}
// ContactAddress represents a physical address with a label
pub struct ContactAddress {
pub mut:
street string
city string
state string
postal_code string
country string
label string // Home, Work, Other, etc.
primary bool
}
// SocialProfile represents a social media profile
pub struct SocialProfile {
pub mut:
platform string // Facebook, Twitter, LinkedIn, etc.
username string
url string
}
// CustomField represents a user-defined field
pub struct CustomField {
pub mut:
label string
value string
}
// ContactGroup represents a group of contacts
pub struct ContactGroup {
base.Base
pub mut:
name string
description string
contacts []u32 // IDs of contacts in this group
owner_id u32 // User who owns this group
shared_with []u32 // Users this group is shared with
}
Integration Points
The MCC system integrates with the existing system in the following ways:
-
User Integration:
- Uses
circle.User
as the primary user model - The
biz.User
model has been deprecated and should not be used
- Uses
-
Cross-Component Integration:
- Calendar events can reference contacts as attendees
- Emails can reference calendar events (for invitations)
- Contacts can be used in email addressing
-
Base Integration:
- All models extend the
base.Base
struct for common fields - Consistent ID and timestamp handling
- All models extend the
System Architecture
+----------------+ +----------------+ +----------------+
| | | | | |
| Mail System |<----->| User System |<----->| Contact System |
| | | | | |
+----------------+ +----------------+ +----------------+
^ ^ ^
| | |
v v v
+----------------+ +----------------+ +----------------+
| | | | | |
| Calendar System|<----->| Base System |<----->| Group System |
| | | | | |
+----------------+ +----------------+ +----------------+
This specification provides a comprehensive data model for creating a self-hosted alternative to Google's Mail, Calendar, and Contacts services, with a focus on data ownership and control.