Skip to content

Refactor Contacts API to Relationship Management System with Normalized Database Schema#229

Merged
credevator merged 5 commits intomainfrom
copilot/fix-228
Aug 19, 2025
Merged

Refactor Contacts API to Relationship Management System with Normalized Database Schema#229
credevator merged 5 commits intomainfrom
copilot/fix-228

Conversation

Copy link
Contributor

Copilot AI commented Aug 17, 2025

This PR implements a complete refactoring of the Contacts API into a comprehensive Relationship Management system with a normalized database architecture, addressing the need for better data organization and privacy controls.

Key Changes

Database Normalization

Replaced the monolithic contacts table with 6 specialized, normalized tables:

  • person_profiles - Core profile information (name, basic details)
  • person_contact_info - Email, phone, addresses with individual privacy settings
  • person_professional_info - Job history, organizations, work details
  • person_personal_info - Birthday, preferences, family information
  • person_life_events - Important dates, milestones, life tracking
  • person_belongings - Items, possessions, relationship context
  • person_relationships - Rich bidirectional relationship mapping

API Restructuring

Added 19 new endpoints under /relationship-management/ including:

  • Full CRUD operations for person profiles
  • Specialized endpoints for each information category
  • Advanced relationship management with categories (family, professional, social)
  • Granular privacy controls per information type

Enhanced Features

  • Minimal Profile Creation: Can create profiles with just a name
  • Privacy by Default: All information is private unless explicitly shared
  • Tenant-Aware Sharing: Selective information sharing within tenant boundaries
  • Rich Relationship Types: Support for family, professional, and social relationships with strength ratings
  • Life Event Tracking: Comprehensive milestone and important date management
  • Belongings Context: Track items relevant to relationship understanding

Frontend Integration

  • Complete TypeScript type definitions for all new models
  • Full service layer with helper methods for common operations
  • Privacy control utilities and relationship creation helpers
  • Backward-compatible service structure

Example Usage

// Create a minimal profile
const profile = await relationshipManagementService.createPersonProfile({
  first_name: "Alice"
});

// Add detailed information with privacy controls
await relationshipManagementService.createPersonContactInfo(profile.id, {
  email: "alice@example.com",
  visibility: "tenant_shared"  // Shareable with team
});

await relationshipManagementService.createPersonPersonalInfo(profile.id, {
  date_of_birth: "1990-05-15",
  visibility: "private"  // Keep private
});

// Create rich relationships
await relationshipManagementService.createFamilyRelationship(
  aliceId, bobId, "sister", "My older sister"
);

Migration & Compatibility

  • Existing /contacts endpoints remain functional for backward compatibility
  • Alembic migration script included for database schema updates
  • Clear migration path from old Contact system to new Person Profiles

Benefits Over Previous System

  • Better Data Organization: Normalized structure prevents redundancy
  • Enhanced Privacy: Granular control over what information is shared
  • Richer Information Types: Support for belongings, life events, comprehensive tracking
  • Improved Relationships: Advanced relationship mapping with categories and strength
  • Extensible Architecture: Easy to add new information types in the future
  • Performance: Normalized queries are more efficient for specific data access

The system maintains full tenant isolation and user ownership while providing a much more flexible foundation for relationship management.

Fixes #228.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 3 commits August 17, 2025 16:51
Co-authored-by: credevator <2756303+credevator@users.noreply.github.com>
…management

Co-authored-by: credevator <2756303+credevator@users.noreply.github.com>
Co-authored-by: credevator <2756303+credevator@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor Contacts API Refactor Contacts API to Relationship Management System with Normalized Database Schema Aug 17, 2025
Copilot AI requested a review from credevator August 17, 2025 16:58
@credevator credevator marked this pull request as ready for review August 19, 2025 04:30
@credevator credevator merged commit 3add7dc into main Aug 19, 2025
0 of 2 checks passed
@credevator credevator deleted the copilot/fix-228 branch August 19, 2025 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor Contacts API

2 participants