Contextual AI Assistant: System Design Documentation

Executive Summary

The Contextual AI Assistant is an advanced system designed to understand user activities across applications by continuously ingesting screen data and responding to complex contextual queries. This document provides comprehensive technical documentation, implementation guidelines, and system design details for the solution based on Mem0's hybrid memory architecture with Neo4j as the graph store.


Technical Documentation

1. Database Schema and Relationships

1.1 Neo4j Graph Database Schema

The knowledge graph in Neo4j consists of the following node types and relationships:

Core Entity Nodes:

Node Label Description Key Properties
Person Individuals (users, contacts, team members) id, name, role, email
Message Communication content across platforms id, content, timestamp, status
PullRequest Code review requests id, number, title, description, status, repo
Comment Remarks on various entities id, content, timestamp
Team Groups of people working together id, name, description
Project Work initiatives containing tasks id, name, description, status
Application Software applications being used id, name, type

Key Relationships:

Relationship Type Source → Target Description
AUTHORED PersonMessage / Comment Person created content
RECEIVED_BY MessagePerson Message was received by person
REPLIED_TO MessageMessage Message is a reply to another
MEMBER_OF PersonTeam Person belongs to team
WORKS_ON PersonProject Person works on project
CREATED PersonPullRequest Person created PR
REVIEWED PersonPullRequest Person reviewed PR
COMMENTED_ON PersonPullRequest Person commented on PR
CAPTURED_IN {Any Entity}Application Entity was observed in app

Neo4j Schema Definition:

// Core entity constraints
CREATE CONSTRAINT person_id IF NOT EXISTS FOR (p:Person) REQUIRE p.id IS UNIQUE;
CREATE CONSTRAINT message_id IF NOT EXISTS FOR (m:Message) REQUIRE m.id IS UNIQUE;
CREATE CONSTRAINT pr_id IF NOT EXISTS FOR (pr:PullRequest) REQUIRE pr.id IS UNIQUE;
CREATE CONSTRAINT comment_id IF NOT EXISTS FOR (c:Comment) REQUIRE c.id IS UNIQUE;
CREATE CONSTRAINT team_id IF NOT EXISTS FOR (t:Team) REQUIRE t.id IS UNIQUE;
CREATE CONSTRAINT project_id IF NOT EXISTS FOR (p:Project) REQUIRE p.id IS UNIQUE;
CREATE CONSTRAINT app_id IF NOT EXISTS FOR (a:Application) REQUIRE a.id IS UNIQUE;

// Indexes for efficient lookups
CREATE INDEX person_name IF NOT EXISTS FOR (p:Person) ON (p.name);
CREATE INDEX message_status IF NOT EXISTS FOR (m:Message) ON (m.status);
CREATE INDEX pr_status IF NOT EXISTS FOR (pr:PullRequest) ON (pr.status);

1.2 Mem0 Memory Architecture

The Mem0 memory system integrates three types of storage:

Vector Store: