I'm Samuel FajreldinesI am a specialist in the entire JavaScript and TypeScript ecosystem (including Node.js, React, Angular and Vue.js) I am expert in AI and in creating AI integrated solutions I am expert in DevOps and Serverless Architecture (AWS, Google Cloud and Azure) I am expert in PHP and its frameworks (such as Codeigniter and Laravel). |
Samuel FajreldinesI am a specialist in the entire JavaScript and TypeScript ecosystem. I am expert in AI and in creating AI integrated solutions. I am expert in DevOps and Serverless Architecture I am expert in PHP and its frameworks.
|
Graphiti transforms ever-changing data into a bi-temporal knowledge graph that your AI agents can query in milliseconds.
In this guide you'll learn why it exists, how it works, and how to build a Personal Financial AI Coach that learns from your daily spending habits and provides personalized advice to help you make better money decisions.
Graphiti is an open-source Python framework for building real-time, bi-temporal knowledge graphs tailored to retrieval-augmented generation (RAG) and autonomous agents. It continuously ingests structured, semi-structured, and unstructured events—conversations, documents, transactions—and attaches temporal metadata so you always know when something happened and when the system learned about it.
Key capabilities
Capability | Why it matters |
---|---|
Bi-temporal model | Track both event_time and record_time ; perfect for audits & back-tests |
Incremental ingestion | Process new events in milliseconds—no full-rebuild downtime |
Hybrid search | Fuse vector, keyword, and contextual search for high-precision retrieval |
AI-powered insights | Works with OpenAI, Anthropic, local LLMs—just pass your API key |
Temporal knowledge | AI agents understand when events happened and how they relate |
Python & TypeScript SDKs | Build workers, ETL pipelines, and agent toolkits in your language of choice |
Quick fact: The MCP Server image packages Graphiti as a container with REST and WebSocket interfaces. Point it at Neo4j ≥ 5.26, export
OPENAI_API_KEY
, and you’re live in minutes.
Follow these steps on any laptop with Docker:
Spin up Graphiti MCP Server
docker run -d --name graphiti \
-p 8000:8000 \
-e OPENAI_API_KEY=$OPENAI_API_KEY \
zepai/graphiti:latest
POST your first event
curl -X POST http://localhost:8000/v1/episodes \
-H "Content-Type: application/json" \
-d '{
"actor":"user:123",
"content":"Paid $45 at Starbucks",
"timestamp":"2025-07-14T15:04:22Z"
}'
You just created a temporally-tagged Episode
that the AI can now understand and query 🎉.
graph LR A["Sarah's Daily Life<br/>(transactions, bills, income)"] -->|"Graphiti Learns"| B["Smart Memory System"] B --> C["Organized Knowledge<br/>About Sarah"] C --> D["AI Understanding<br/>Her Patterns"] C --> E["AI Recognizes<br/>Her Habits"] D --> F["ChatGPT Gives<br/>Personal Advice"] E --> F
Think of it like this: Graphiti is Sarah's personal financial memory assistant that never forgets anything:
Domain | Example |
---|---|
Fintech | Dynamic credit scoring & AML monitoring |
Customer 360 | Real-time, multi-channel profiles for CX agents |
Healthcare | Longitudinal patient records with event provenance |
Supply Chain | Live dependency graphs & risk propagation |
Security | Attack-path analysis with timestamped IoCs |
We'll create a system that ingests daily transactions, learns spending patterns, and provides personalized financial coaching to help individuals make better money decisions.
Let's follow Sarah through her financial journey and see how Graphiti transforms her daily activities into actionable insights.
Here's how Sarah's real-world financial behavior gets captured throughout her daily life:
// Morning coffee routine - Episode 1
{
"actor": "user:sarah_jones",
"content": "Sarah spent $45 at Starbucks on Main Street for a venti caramel macchiato and pastry",
"timestamp": "2025-07-14T08:15:00Z",
"metadata": {
"amount": 45.00,
"merchant": "Starbucks",
"category": "coffee",
"location": "Main Street",
"items": ["venti caramel macchiato", "blueberry muffin"],
"frequency": "daily"
}
}
// Grocery shopping - Episode 2
{
"actor": "user:sarah_jones",
"content": "Sarah spent $127.50 at Whole Foods for weekly groceries",
"timestamp": "2025-07-14T10:30:00Z",
"metadata": {
"amount": 127.50,
"merchant": "Whole Foods",
"category": "groceries",
"frequency": "weekly",
"items": ["organic vegetables", "premium meat", "specialty cheese"]
}
}
// Gas station visit - Episode 3
{
"actor": "user:sarah_jones",
"content": "Sarah spent $52.00 on gas at Shell station",
"timestamp": "2025-07-14T12:45:00Z",
"metadata": {
"amount": 52.00,
"merchant": "Shell",
"category": "transportation",
"frequency": "bi-weekly",
"gallons": 12.5
}
}
// Lunch with colleague - Episode 4
{
"actor": "user:sarah_jones",
"content": "Sarah spent $38.50 at Olive Garden for lunch meeting",
"timestamp": "2025-07-14T13:20:00Z",
"metadata": {
"amount": 38.50,
"merchant": "Olive Garden",
"category": "dining",
"occasion": "business lunch",
"frequency": "occasional"
}
}
// Impulse purchase - Episode 5
{
"actor": "user:sarah_jones",
"content": "Sarah spent $85.00 at Target for household items and unplanned clothing",
"timestamp": "2025-07-14T16:00:00Z",
"metadata": {
"amount": 85.00,
"merchant": "Target",
"category": "retail",
"planned_amount": 25.00,
"impulse_amount": 60.00,
"items": ["laundry detergent", "sweater", "decorative pillows"]
}
}
// Evening entertainment - Episode 6
{
"actor": "user:sarah_jones",
"content": "Sarah spent $67.00 at AMC Theater for movie and snacks",
"timestamp": "2025-07-14T19:30:00Z",
"metadata": {
"amount": 67.00,
"merchant": "AMC Theater",
"category": "entertainment",
"frequency": "weekly",
"companions": 2
}
}
// Online shopping - Episode 7
{
"actor": "user:sarah_jones",
"content": "Sarah spent $142.00 on Amazon for books and electronics",
"timestamp": "2025-07-14T21:15:00Z",
"metadata": {
"amount": 142.00,
"merchant": "Amazon",
"category": "online_shopping",
"items": ["wireless headphones", "self-help books", "phone charger"],
"delivery": "next_day"
}
}
// Late night food delivery - Episode 8
{
"actor": "user:sarah_jones",
"content": "Sarah spent $28.50 on DoorDash for Thai food delivery",
"timestamp": "2025-07-14T22:45:00Z",
"metadata": {
"amount": 28.50,
"merchant": "DoorDash",
"category": "food_delivery",
"restaurant": "Thai Garden",
"frequency": "3x_weekly"
}
}
// Bill payment delay - Episode 9
{
"actor": "user:sarah_jones",
"content": "Sarah's credit card payment of $1,200 is 5 days overdue",
"timestamp": "2025-07-14T23:59:00Z",
"metadata": {
"amount": 1200.00,
"payment_type": "credit_card",
"days_overdue": 5,
"severity": "moderate",
"min_payment": 35.00
}
}
// Morning workout - Episode 10
{
"actor": "user:sarah_jones",
"content": "Sarah paid $89.00 for monthly gym membership at Planet Fitness",
"timestamp": "2025-07-15T07:00:00Z",
"metadata": {
"amount": 89.00,
"merchant": "Planet Fitness",
"category": "fitness",
"frequency": "monthly",
"auto_pay": true
}
}
// Utility bill - Episode 11
{
"actor": "user:sarah_jones",
"content": "Sarah paid $156.00 for electricity bill to ConEd",
"timestamp": "2025-07-15T09:30:00Z",
"metadata": {
"amount": 156.00,
"merchant": "ConEd",
"category": "utilities",
"frequency": "monthly",
"kwh_used": 890,
"season": "summer"
}
}
// Subscription service - Episode 12
{
"actor": "user:sarah_jones",
"content": "Sarah paid $15.99 for Netflix subscription",
"timestamp": "2025-07-15T10:45:00Z",
"metadata": {
"amount": 15.99,
"merchant": "Netflix",
"category": "entertainment",
"frequency": "monthly",
"auto_pay": true
}
}
// Healthcare expense - Episode 13
{
"actor": "user:sarah_jones",
"content": "Sarah paid $35.00 copay for doctor visit",
"timestamp": "2025-07-15T11:15:00Z",
"metadata": {
"amount": 35.00,
"merchant": "Dr. Smith Medical",
"category": "healthcare",
"frequency": "quarterly",
"insurance_covered": 85.00
}
}
// Pharmacy visit - Episode 14
{
"actor": "user:sarah_jones",
"content": "Sarah spent $42.50 at CVS for prescription and vitamins",
"timestamp": "2025-07-15T12:00:00Z",
"metadata": {
"amount": 42.50,
"merchant": "CVS",
"category": "healthcare",
"items": ["prescription", "multivitamins", "face wash"],
"insurance_covered": 15.00
}
}
// Car maintenance - Episode 15
{
"actor": "user:sarah_jones",
"content": "Sarah paid $1,200 for car repair at AutoFix",
"timestamp": "2025-07-15T14:45:00Z",
"metadata": {
"amount": 1200.00,
"merchant": "AutoFix",
"category": "emergency",
"payment_method": "credit_card",
"urgency": "high",
"repair_type": "transmission"
}
}
// Side income - Episode 16
{
"actor": "user:sarah_jones",
"content": "Sarah received $350 from freelance graphic design work",
"timestamp": "2025-07-15T16:20:00Z",
"metadata": {
"amount": 350.00,
"source": "freelance",
"category": "additional_income",
"frequency": "irregular",
"client": "Small Business Co",
"hours_worked": 8
}
}
// Insurance payment - Episode 17
{
"actor": "user:sarah_jones",
"content": "Sarah paid $245.00 for auto insurance to State Farm",
"timestamp": "2025-07-15T17:00:00Z",
"metadata": {
"amount": 245.00,
"merchant": "State Farm",
"category": "insurance",
"frequency": "monthly",
"coverage": "full",
"auto_pay": true
}
}
// Weekend shopping - Episode 18
{
"actor": "user:sarah_jones",
"content": "Sarah spent $180.00 at Zara for new work clothes",
"timestamp": "2025-07-15T18:30:00Z",
"metadata": {
"amount": 180.00,
"merchant": "Zara",
"category": "clothing",
"frequency": "monthly",
"items": ["blazer", "blouse", "dress pants"],
"occasion": "work_wardrobe"
}
}
// Pet expenses - Episode 19
{
"actor": "user:sarah_jones",
"content": "Sarah spent $95.00 at PetSmart for dog food and toys",
"timestamp": "2025-07-15T19:15:00Z",
"metadata": {
"amount": 95.00,
"merchant": "PetSmart",
"category": "pet_care",
"frequency": "monthly",
"items": ["premium dog food", "chew toys", "treats"],
"pet": "golden_retriever"
}
}
// Investment contribution - Episode 20
{
"actor": "user:sarah_jones",
"content": "Sarah invested $500 in index funds through her 401k",
"timestamp": "2025-07-15T20:00:00Z",
"metadata": {
"amount": 500.00,
"investment_type": "401k",
"asset_class": "index_funds",
"frequency": "monthly",
"employer_match": 250.00
}
}
// Rent payment - Episode 21
{
"actor": "user:sarah_jones",
"content": "Sarah paid $1,800 rent to Sunset Apartments",
"timestamp": "2025-07-16T08:00:00Z",
"metadata": {
"amount": 1800.00,
"merchant": "Sunset Apartments",
"category": "housing",
"frequency": "monthly",
"payment_method": "auto_pay",
"apartment": "2BR_downtown"
}
}
// Phone bill - Episode 22
{
"actor": "user:sarah_jones",
"content": "Sarah paid $78.00 for Verizon phone service",
"timestamp": "2025-07-16T09:30:00Z",
"metadata": {
"amount": 78.00,
"merchant": "Verizon",
"category": "utilities",
"frequency": "monthly",
"plan": "unlimited",
"auto_pay": true
}
}
// Loan application - Episode 23
{
"actor": "user:sarah_jones",
"content": "Sarah applied for a $15,000 personal loan for debt consolidation",
"timestamp": "2025-07-16T14:30:00Z",
"metadata": {
"amount": 15000.00,
"loan_type": "personal",
"purpose": "debt_consolidation",
"interest_rate": 8.5,
"term_months": 36
}
}
// Subscription cancellation - Episode 24
{
"actor": "user:sarah_jones",
"content": "Sarah canceled her $19.99 Spotify Premium subscription",
"timestamp": "2025-07-16T15:45:00Z",
"metadata": {
"amount": 19.99,
"merchant": "Spotify",
"category": "entertainment",
"action": "cancel",
"reason": "cost_cutting"
}
}
// Weekend dining - Episode 25
{
"actor": "user:sarah_jones",
"content": "Sarah spent $125.00 at The Cheesecake Factory for dinner with friends",
"timestamp": "2025-07-16T19:00:00Z",
"metadata": {
"amount": 125.00,
"merchant": "The Cheesecake Factory",
"category": "dining",
"frequency": "weekly",
"companions": 3,
"occasion": "social"
}
}
// Online course - Episode 26
{
"actor": "user:sarah_jones",
"content": "Sarah spent $299.00 on Udemy for Python programming course",
"timestamp": "2025-07-17T10:00:00Z",
"metadata": {
"amount": 299.00,
"merchant": "Udemy",
"category": "education",
"course": "Python programming",
"duration": "40_hours",
"career_development": true
}
}
// Emergency fund withdrawal - Episode 27
{
"actor": "user:sarah_jones",
"content": "Sarah withdrew $800 from savings account for emergency fund",
"timestamp": "2025-07-17T11:30:00Z",
"metadata": {
"amount": 800.00,
"account_type": "savings",
"purpose": "emergency_fund",
"remaining_balance": 2400.00,
"reason": "car_repair_payment"
}
}
// Birthday gift - Episode 28
{
"actor": "user:sarah_jones",
"content": "Sarah spent $75.00 at Bath & Body Works for friend's birthday gift",
"timestamp": "2025-07-17T13:15:00Z",
"metadata": {
"amount": 75.00,
"merchant": "Bath & Body Works",
"category": "gifts",
"frequency": "occasional",
"occasion": "birthday",
"recipient": "friend"
}
}
// Meal prep ingredients - Episode 29
{
"actor": "user:sarah_jones",
"content": "Sarah spent $85.00 at Costco for meal prep ingredients",
"timestamp": "2025-07-17T15:00:00Z",
"metadata": {
"amount": 85.00,
"merchant": "Costco",
"category": "groceries",
"purpose": "meal_prep",
"frequency": "bi-weekly",
"bulk_purchase": true
}
}
// Internet bill - Episode 30
{
"actor": "user:sarah_jones",
"content": "Sarah paid $89.99 for Comcast internet service",
"timestamp": "2025-07-17T16:30:00Z",
"metadata": {
"amount": 89.99,
"merchant": "Comcast",
"category": "utilities",
"frequency": "monthly",
"speed": "100mbps",
"auto_pay": true
}
}
When Sarah's daily activities are recorded in Graphiti, the AI becomes like a smart financial friend who remembers everything:
Recognizes people, places, and things: AI automatically identifies Sarah, Starbucks, Target, her credit card, her emergency fund, and her freelance work
Connects the dots:
Understands Sarah's money personality:
Tracks timing and changes: AI notices Sarah's spending went up 15% after her car repair, payment delays started 3 months ago, and she began cutting costs 2 weeks ago
The Problem with SQL for Financial Behavior Analysis:
-- Traditional SQL struggles with temporal relationships
SELECT u.name, t.amount, t.category, t.timestamp
FROM users u JOIN transactions t ON u.id = t.user_id
WHERE u.id = 'sarah_jones' AND t.timestamp > '2025-07-01'
ORDER BY t.timestamp;
This SQL query gives you raw data but misses crucial insights:
How Graphiti Solves This:
# Graphiti transforms raw events into AI-queryable knowledge
coffee_habits = await graphiti.search(
"Sarah coffee spending habits frequency daily Starbucks",
limit=20
)
# AI can now understand:
# - Sarah visits Starbucks every morning at 8:15 AM
# - She spends $45 per visit (above average for coffee)
# - This habit represents 12% of her monthly income
# - It started 6 months ago when she moved downtown
# - It correlates with her increased stress levels
Key Advantages of Graphiti for Personal Finance:
Capability | Traditional SQL | Graphiti + AI |
---|---|---|
Pattern Recognition | Requires complex joins & aggregations | AI automatically identifies spending patterns |
Temporal Understanding | Manual date filtering | Bi-temporal model tracks when habits changed |
Behavioral Context | No relationship understanding | AI understands why Sarah spends more after stress events |
Personalized Insights | Generic reports | AI generates specific advice: "Sarah, try brewing coffee at home" |
Predictive Analysis | Requires separate ML models | AI predicts: "Sarah might miss next payment based on current patterns" |
Real-time Adaptation | Batch processing | Incremental updates as new events arrive |
Real Example - Coffee Spending Analysis:
SQL Approach:
SELECT AVG(amount) as avg_coffee_spend, COUNT(*) as frequency
FROM transactions
WHERE user_id = 'sarah_jones'
AND merchant LIKE '%Starbucks%'
AND timestamp >= DATE_SUB(NOW(), INTERVAL 30 DAY);
-- Result: $45 average, 22 visits
-- But what does this mean for Sarah?
Graphiti + AI Approach:
# Search for coffee patterns
coffee_data = await graphiti.search(
"Sarah coffee spending habits daily routine financial impact",
limit=15
)
# AI analyzes and provides personalized insight
insight = await chatgpt.analyze(f"""
Sarah's coffee data: {coffee_data}
Provide personalized financial advice for Sarah about her coffee spending.
""")
# Result: "Sarah, your daily $45 Starbucks visits cost $990/month -
# that's 12% of your income! Try brewing premium coffee at home
# for $8/month. You could save $982 monthly for your emergency fund."
The Power of Temporal Context:
Where Sarah's data comes from
– Her credit card and bank transactions
– Financial app activity and budgeting behavior
– Payment patterns and financial goals
Data collector
Takes each thing Sarah does with money and turns it into a story Graphiti can understand.
Smart memory storage
Graphiti saves everything about Sarah's financial life in a way that AI can easily search and understand.
AI financial coach
ChatGPT looks at Sarah's patterns and creates a financial health score from 0-100.
Personal insight generator
AI looks at Sarah's last 90 days and creates helpful advice specifically for her.
Sarah's dashboard
A simple app that shows Sarah her AI-generated financial insights and recommendations.
What AI Notices | How It Helps Sarah |
---|---|
Monthly spending vs income | AI tracks if Sarah spends more than she earns and warns her early |
Spending habit changes | AI notices if Sarah suddenly starts spending more on coffee or less on groceries |
Payment trouble patterns | AI spots when Sarah might be heading toward financial stress before it gets bad |
All insights are generated by first using Graphiti's search functionality to retrieve relevant information, then feeding those results to ChatGPT for personalized advice directly to Sarah.
Step 1: Search for Coffee Spending Data
# Search for coffee-related spending patterns
coffee_search_results = await graphiti.search(
"Sarah coffee spending Starbucks habits frequency amount daily routine",
limit=15
)
# Search for income and budget context
income_search_results = await graphiti.search(
"Sarah monthly income salary freelance total earnings",
limit=10
)
Step 2: Personalized AI Advice for Sarah
# Extract facts from search results
coffee_facts = [result.fact for result in coffee_search_results]
income_facts = [result.fact for result in income_search_results]
# Create personalized advice prompt
ai_prompt = f"""
You are Sarah's personal financial AI assistant. Based on her coffee spending data, provide friendly, actionable advice.
Sarah's Coffee Spending:
{coffee_facts}
Sarah's Income Context:
{income_facts}
Provide personalized advice to Sarah:
1. Friendly observation about her coffee habits
2. Financial impact in terms she can understand
3. Specific, actionable alternatives
4. Monthly savings potential
5. Motivation and encouragement
"""
personal_insight = await client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": ai_prompt}]
)
Generated Personal Insight:
"Hi Sarah! I noticed you're spending $45 daily at Starbucks - that's $990 per month, which is 12% of your income. I totally get it - good coffee makes the day better! But here's an idea: What if you invested in a premium espresso machine for $300? You could make cafe-quality drinks at home for about $8/month. That's $982 monthly savings, which could fully fund your emergency fund in just 3 months! Plus, you'd have more time in the morning. Want me to find some highly-rated espresso machines in your price range?"
Step 1: Search for Payment Patterns
# Search for payment history and upcoming bills
payment_search_results = await graphiti.search(
"Sarah payment history missed late overdue bills upcoming",
limit=20
)
# Search for cash flow patterns
cashflow_search_results = await graphiti.search(
"Sarah income expenses monthly flow timing emergency fund",
limit=15
)
Step 2: Proactive Payment Assistance
payment_facts = [result.fact for result in payment_search_results]
cashflow_facts = [result.fact for result in cashflow_search_results]
ai_prompt = f"""
You are Sarah's helpful financial assistant. Based on her payment history, provide supportive guidance.
Payment History:
{payment_facts}
Cash Flow Data:
{cashflow_facts}
Provide caring, non-judgmental advice to Sarah:
1. Acknowledge her recent payment challenges
2. Identify payment timing patterns
3. Suggest practical solutions
4. Offer encouragement about positive behaviors
5. Provide specific next steps
"""
payment_insight = await client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": ai_prompt}]
)
Generated Personal Insight:
"Sarah, I noticed you've had a few late payments recently - totally understandable with that unexpected $1,200 car repair! The good news is you're only averaging 4.5 days late, which shows you're managing despite the challenge. I see your income usually hits on the 1st and 15th, but your credit card is due on the 12th. Here's what I suggest: Set up automatic payments for the minimum amount on the 2nd of each month when you have cash flow, then make additional payments when your freelance income comes in. Also, you've got $2,400 in emergency savings - that's actually really good! You're doing better than you think."
Step 1: Multiple Targeted Searches
# Search for all spending categories
spending_categories = await graphiti.search(
"Sarah spending categories coffee groceries entertainment shopping utilities",
limit=30
)
# Search for income and positive behaviors
positive_behaviors = await graphiti.search(
"Sarah income 401k savings subscription cancellation meal prep positive",
limit=20
)
# Search for stress indicators and challenges
challenges = await graphiti.search(
"Sarah emergency expense late payment debt loan application stress",
limit=15
)
Step 2: Comprehensive Personal Financial Review
all_financial_data = {
"spending": [r.fact for r in spending_categories],
"positive": [r.fact for r in positive_behaviors],
"challenges": [r.fact for r in challenges]
}
comprehensive_prompt = f"""
You are Sarah's personal financial AI coach. Provide an encouraging, comprehensive review of her financial situation.
Sarah's Spending Patterns:
{all_financial_data['spending']}
Sarah's Positive Behaviors:
{all_financial_data['positive']}
Sarah's Current Challenges:
{all_financial_data['challenges']}
Provide a supportive financial review for Sarah:
1. Celebrate her positive financial behaviors
2. Provide honest but encouraging assessment
3. Top 3 areas where she can improve
4. Specific action steps for next 30 days
5. Long-term financial goals alignment
6. Motivation and confidence building
"""
comprehensive_insight = await client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": comprehensive_prompt}]
)
Generated Personal Insight:
"Sarah, let me start with what you're doing RIGHT! You're contributing $500 monthly to your 401k (that's $6,000 annually!), you proactively canceled subscriptions to save money, and you're even meal prepping - these are expert-level financial moves! Your challenge right now is that your discretionary spending ($1,440/month on coffee + food delivery) is competing with your emergency fund recovery after that car repair. Here's your 30-day action plan: 1) Try home-brewing coffee 3 days a week (save $400/month), 2) Set up automatic $50 weekly transfers to rebuild your emergency fund, 3) Use your freelance income ($350/month) specifically for fun expenses. You're actually in better shape than 70% of Americans - you just need to optimize your daily habits. Want me to create a personalized savings challenge?"
Step 1: Search for Recent Spending Patterns
# Search for today's and recent spending
recent_spending = await graphiti.search(
"Sarah spending today recent unusual large amount impulse",
limit=10
)
# Search for budget and goals context
budget_context = await graphiti.search(
"Sarah monthly budget goals savings target spending limits",
limit=15
)
Step 2: Real-time Spending Guidance
recent_facts = [result.fact for result in recent_spending]
budget_facts = [result.fact for result in budget_context]
ai_prompt = f"""
You are Sarah's real-time financial assistant. Based on her recent spending, provide immediate, helpful guidance.
Recent Spending Activity:
{recent_facts}
Budget Context:
{budget_facts}
Provide immediate, supportive guidance:
1. Acknowledge her recent purchase
2. Put it in context of her monthly spending
3. Offer practical alternatives if concerning
4. Provide encouragement about good choices
5. Suggest next steps if needed
"""
realtime_insight = await client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": ai_prompt}]
)
Generated Personal Insight:
"Hey Sarah! I saw you just spent $142 on Amazon for headphones and books. The headphones are a great investment for your work setup, and I love that you're reading self-help books! Just a friendly heads up - you're at $380 in online shopping this month, which is about 60% of your discretionary budget. No stress though! Maybe hold off on non-essential purchases for the next week? Your freelance payment should come in soon, and that could cover any remaining shopping desires. Keep up the great work on personal development!"
Sarah's AI assistant generates personalized insights by first performing targeted searches in Graphiti, then analyzing the results with AI to provide helpful, actionable advice:
from graphiti_core import Graphiti
from openai import OpenAI
client = OpenAI()
graphiti = Graphiti()
async def get_personal_financial_health_check(user_id: str):
# Search for payment patterns to help Sarah stay on track
payment_search = await graphiti.search(
f"{user_id} payment history bills upcoming due dates",
limit=20
)
# Search for spending patterns to identify optimization opportunities
spending_search = await graphiti.search(
f"{user_id} spending habits categories monthly trends",
limit=25
)
# Search for positive behaviors to celebrate
positive_search = await graphiti.search(
f"{user_id} savings 401k emergency fund positive financial behaviors",
limit=15
)
# Extract facts from search results
payment_facts = [result.fact for result in payment_search]
spending_facts = [result.fact for result in spending_search]
positive_facts = [result.fact for result in positive_search]
# Generate personalized financial health insight
insight_prompt = f"""
You are Sarah's personal financial AI assistant. Based on her financial data, provide encouraging, actionable advice.
Payment History:
{payment_facts}
Spending Patterns:
{spending_facts}
Positive Behaviors:
{positive_facts}
Provide friendly, supportive advice:
1. Celebrate her positive financial behaviors
2. Identify her biggest opportunity for improvement
3. Suggest one specific action for this week
4. Provide motivation and encouragement
5. Ask if she wants help with any specific area
"""
response = await client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": insight_prompt}]
)
return {
"user_id": user_id,
"insight_type": "personal_financial_health",
"search_results_count": len(payment_search) + len(spending_search) + len(positive_search),
"ai_advice": response.choices[0].message.content
}
from graphiti_core.search.search_config_recipes import EDGE_HYBRID_SEARCH_RRF
from graphiti_core.search.search_config import SearchConfig
async def get_category_spending_advice(user_id: str, category: str):
# Custom search configuration for edges (relationships) to find spending patterns
search_config = EDGE_HYBRID_SEARCH_RRF.model_copy(deep=True)
search_config.limit = 30
search_config.mmr_lambda = 0.7 # Adjust diversity vs relevance
# Search for spending relationships in this category
spending_search = await graphiti._search(
query=f"{user_id} spent spending {category} amount frequency habit pattern",
config=search_config
)
# Search for income context to provide relative advice
income_search = await graphiti.search(
f"{user_id} income salary revenue earnings monthly",
limit=10
)
# Search for similar category optimizations Sarah has done
optimization_search = await graphiti.search(
f"{user_id} saved money optimization budget reduction {category}",
limit=10
)
# Extract relationship facts
spending_facts = [edge.fact for edge in spending_search.edges]
income_facts = [result.fact for result in income_search]
optimization_facts = [result.fact for result in optimization_search]
# Generate personalized spending advice
advice_prompt = f"""
You are Sarah's personal financial coach. Help her optimize her {category} spending.
Sarah's {category} Spending Patterns:
{spending_facts}
Sarah's Income Context:
{income_facts}
Previous Optimization Efforts:
{optimization_facts}
Provide supportive, actionable advice:
1. Acknowledge her current spending in this category
2. Calculate percentage of income spent on {category}
3. Identify trends (increasing/stable/decreasing)
4. Suggest specific, realistic optimization strategies
5. Provide motivation and celebrate any positive changes
6. Ask if she wants help creating a plan for this category
"""
response = await client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": advice_prompt}]
)
return {
"user_id": user_id,
"category": category,
"spending_patterns_found": len(spending_search.edges),
"context_facts": len(income_search),
"optimization_history": len(optimization_search),
"personal_advice": response.choices[0].message.content
}
async def comprehensive_financial_goals_planning(user_id: str):
# Multiple parallel searches for different aspects of Sarah's financial life
searches = await asyncio.gather(
# Current financial habits
graphiti.search(f"{user_id} spending habits daily weekly monthly routine", limit=20),
# Savings and investment behaviors
graphiti.search(f"{user_id} savings 401k investment emergency fund", limit=15),
# Debt and payment patterns
graphiti.search(f"{user_id} debt payment credit card loan balance", limit=15),
# Income sources and stability
graphiti.search(f"{user_id} income salary freelance job employment", limit=12),
# Financial goals and aspirations
graphiti.search(f"{user_id} goals plans future financial dreams", limit=10),
# Positive financial behaviors
graphiti.search(f"{user_id} budget optimization savings achievements", limit=15)
)
habits_results, savings_results, debt_results, income_results, goals_results, positive_results = searches
# Organize search results by financial areas
financial_data = {
"spending_habits": [r.fact for r in habits_results],
"savings_behaviors": [r.fact for r in savings_results],
"debt_situation": [r.fact for r in debt_results],
"income_sources": [r.fact for r in income_results],
"financial_goals": [r.fact for r in goals_results],
"positive_behaviors": [r.fact for r in positive_results]
}
# Generate comprehensive financial planning advice
planning_prompt = f"""
You are Sarah's personal financial planning assistant. Help her create a comprehensive financial plan based on her current situation.
Current Spending Habits: {financial_data['spending_habits']}
Savings & Investment Behaviors: {financial_data['savings_behaviors']}
Debt Situation: {financial_data['debt_situation']}
Income Sources: {financial_data['income_sources']}
Financial Goals: {financial_data['financial_goals']}
Positive Behaviors: {financial_data['positive_behaviors']}
Provide comprehensive, encouraging financial planning advice:
1. Celebrate her current positive financial behaviors
2. Assess her progress toward financial stability (0-100)
3. Identify her top 3 financial opportunities
4. Create a prioritized action plan for next 90 days
5. Suggest specific strategies for her biggest challenges
6. Provide motivation and confidence-building insights
7. Ask what specific goals she wants to focus on first
"""
response = await client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": planning_prompt}]
)
return {
"user_id": user_id,
"total_search_results": sum(len(results) for results in searches),
"financial_areas": list(financial_data.keys()),
"comprehensive_plan": response.choices[0].message.content
}
async def provide_realtime_financial_coaching(user_id: str):
# Monitor for opportunities to help Sarah with her financial decisions
coaching_searches = {
"spending_decision": f"{user_id} spending today recent purchase decision",
"saving_opportunity": f"{user_id} saved money optimization achievement",
"bill_reminder": f"{user_id} bills due upcoming payment reminder",
"financial_goal": f"{user_id} goal progress achievement milestone"
}
for coaching_type, search_query in coaching_searches.items():
recent_results = await graphiti.search(search_query, limit=8)
if recent_results:
# Generate immediate coaching insight
coaching_facts = [result.fact for result in recent_results]
coaching_prompt = f"""
You are Sarah's supportive financial coach. Based on her recent activity, provide helpful guidance.
Recent Activity Type: {coaching_type}
Recent Facts:
{coaching_facts}
Provide encouraging, actionable coaching:
1. Acknowledge her recent activity positively
2. Provide context about her overall financial journey
3. Suggest immediate helpful actions (if any)
4. Offer encouragement and motivation
5. Ask if she wants help with anything specific
"""
response = await client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": coaching_prompt}]
)
# Send personalized coaching message to Sarah
send_coaching_message({
"user_id": user_id,
"coaching_type": coaching_type,
"search_results": len(recent_results),
"personal_coaching": response.choices[0].message.content,
"timestamp": datetime.now().isoformat()
})
import requests
import json
from datetime import datetime
def send_financial_event(user_id: str, description: str, amount: float, category: str):
"""
Send a financial event to Graphiti for AI analysis
"""
payload = {
"actor": f"user:{user_id}",
"content": description,
"timestamp": datetime.now().isoformat(),
"metadata": {
"amount": amount,
"category": category
}
}
response = requests.post(
"http://localhost:8000/v1/episodes",
headers={"Content-Type": "application/json"},
data=json.dumps(payload)
)
return response.json()
# Example usage
send_financial_event("sarah_jones", "Sarah spent $45 at Starbucks", 45.0, "coffee")
send_financial_event("sarah_jones", "Sarah missed credit card payment", 1200.0, "missed_payment")
send_financial_event("sarah_jones", "Sarah applied for personal loan", 15000.0, "loan_application")
Here's a complete workflow showing how to use Graphiti's search functionality to generate insights:
from graphiti_core import Graphiti
from graphiti_core.search.search_config_recipes import EDGE_HYBRID_SEARCH_RRF, NODE_HYBRID_SEARCH_RRF
from openai import OpenAI
import asyncio
async def generate_personal_financial_insights(user_id: str):
"""
Complete workflow for generating personal financial insights using Graphiti search
"""
graphiti = Graphiti()
client = OpenAI()
# Step 1: Search for different types of financial behavior
print(f"Searching for financial patterns for {user_id}...")
# Basic search for spending patterns
spending_results = await graphiti.search(
f"{user_id} spending amount money paid",
limit=25
)
# Advanced search for relationships using custom config
relationship_config = EDGE_HYBRID_SEARCH_RRF.model_copy(deep=True)
relationship_config.limit = 20
payment_relationships = await graphiti._search(
query=f"{user_id} payment relationship missed late",
config=relationship_config
)
# Search for entities (nodes) related to the user
entity_config = NODE_HYBRID_SEARCH_RRF.model_copy(deep=True)
entity_config.limit = 15
user_entities = await graphiti._search(
query=f"{user_id} person customer account",
config=entity_config
)
# Step 2: Extract and organize search results
spending_facts = [result.fact for result in spending_results]
payment_facts = [edge.fact for edge in payment_relationships.edges]
entity_summaries = [node.summary for node in user_entities.nodes]
# Step 3: Generate AI insight from search results
insight_prompt = f"""
Generate personalized financial coaching insights for {user_id} based on these search results:
SPENDING PATTERNS:
{spending_facts}
PAYMENT RELATIONSHIPS:
{payment_facts}
USER ENTITIES:
{entity_summaries}
Please provide:
1. Personal financial health summary
2. Top 3 areas for improvement
3. Top 2 positive behaviors to celebrate
4. Specific actionable recommendations for better financial habits
5. Motivational insights based on their progress
"""
response = await client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": insight_prompt}]
)
# Step 4: Return structured insight
return {
"user_id": user_id,
"search_results": {
"spending_patterns": len(spending_results),
"payment_relationships": len(payment_relationships.edges),
"user_entities": len(user_entities.nodes)
},
"ai_generated_insight": response.choices[0].message.content,
"data_sources": "Graphiti search results",
"generation_method": "search_then_analyze"
}
# Example usage
async def run_insight_generation():
insights = await generate_personal_financial_insights("sarah_jones")
print(f"Generated insights based on {sum(insights['search_results'].values())} search results")
print(insights['ai_generated_insight'])
# Run the workflow
asyncio.run(run_insight_generation())
Sample Output:
Generated insights based on 47 search results
PERSONAL FINANCIAL HEALTH SUMMARY:
Sarah shows a mix of positive and challenging financial behaviors. She demonstrates excellent retirement planning with consistent 401k contributions and income diversification through freelance work, but her daily spending habits (especially coffee purchases) represent a significant opportunity for optimization.
TOP 3 AREAS FOR IMPROVEMENT:
1. Daily coffee spending ($45/day = $990/month, 12% of income)
2. Payment timing optimization (averaging 4.5 days late, manageable but improvable)
3. Emergency fund rebuilding after recent car repair expense
TOP 2 POSITIVE BEHAVIORS TO CELEBRATE:
1. Consistent retirement savings - $500/month 401k contributions show excellent long-term planning
2. Proactive cost-cutting through subscription cancellations, saving $47/month
SPECIFIC ACTIONABLE RECOMMENDATIONS:
- Try home brewing coffee 3 days per week to save $400/month
- Set up automatic bill payments to avoid late fees
- Use freelance income specifically for emergency fund rebuilding
- Create a "fun money" budget for guilt-free discretionary spending
MOTIVATIONAL INSIGHTS:
Sarah is actually doing better than 70% of Americans with her retirement savings rate. Her main challenge is optimizing daily habits - small changes to her coffee routine could free up nearly $1,000/month for emergency savings and debt reduction. She's already shown she can cut costs (subscription cancellations) and earn extra income (freelance work).
from graphiti_core import Graphiti
from openai import OpenAI
client = OpenAI()
graph = Graphiti()
def fetch_personal_financial_context(user_id: str) -> str:
"""
Retrieve Sarah's comprehensive financial context from Graphiti
"""
return graph.get_user_context(user_id, days=90)
def generate_personal_financial_coaching(financial_context: str, user_id: str) -> str:
"""
Generate personalized financial coaching and advice for Sarah
"""
prompt = f"""
You are Sarah's personal financial AI coach. Analyze her financial behavior and provide supportive, actionable guidance.
User: {user_id}
Financial Context (Last 90 Days):
{financial_context}
Provide encouraging, personalized coaching:
1. Warm greeting and positive acknowledgment
2. Top 3 financial strengths Sarah is demonstrating
3. Her biggest opportunity for financial improvement
4. Specific, actionable steps she can take this week
5. Long-term financial goal suggestions based on her patterns
6. Motivation and encouragement about her financial journey
7. Ask what specific area she'd like help with most
Format as a supportive conversation with Sarah, not a formal report.
"""
response = client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "system", "content": "You are Sarah's supportive personal financial coach. Provide encouraging, actionable advice in a friendly tone."},
{"role": "user", "content": prompt}
]
)
return response.choices[0].message.content
def generate_weekly_financial_check_in(user_id: str) -> str:
"""
Generate a weekly financial check-in for Sarah
"""
# Get recent financial activity
recent_context = graph.get_user_context(user_id, days=7)
prompt = f"""
You are Sarah's weekly financial check-in assistant. Review her past week and provide supportive guidance.
Sarah's Activity This Week:
{recent_context}
Provide a friendly weekly financial check-in:
1. Celebrate any positive financial decisions from this week
2. Identify any spending patterns worth noting
3. Suggest one small improvement for next week
4. Provide encouragement about her overall progress
5. Ask about her financial goals for the coming week
Keep it encouraging and actionable!
"""
response = client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "system", "content": "You are Sarah's supportive weekly financial check-in coach."},
{"role": "user", "content": prompt}
]
)
return response.choices[0].message.content
# Generate personalized coaching for Sarah
financial_context = fetch_personal_financial_context("sarah_jones")
coaching = generate_personal_financial_coaching(financial_context, "sarah_jones")
print(coaching)
# Generate weekly check-in
weekly_checkin = generate_weekly_financial_check_in("sarah_jones")
print(weekly_checkin)
Sample AI-Generated Personal Financial Coaching:
Hi Sarah! 👋
I've been looking at your financial journey over the past 90 days, and I'm really impressed with some of the positive steps you're taking!
YOUR TOP 3 FINANCIAL STRENGTHS:
1. 🎯 Consistent 401k contributions ($500/month) - You're building a solid retirement foundation!
2. ✂️ Proactive cost-cutting - You canceled subscriptions saving $47/month. That's smart budgeting!
3. 💪 Income diversification - Your freelance work brings in extra $350/month. Great hustle!
YOUR BIGGEST OPPORTUNITY:
Your daily coffee habit ($45/day = $990/month) is 12% of your income. I know good coffee is important, but this could be your fast track to financial freedom!
THIS WEEK'S ACTION STEPS:
1. Try brewing coffee at home 3 days this week (save ~$135)
2. Set up automatic $50 weekly transfer to emergency fund
3. Track your "impulse purchases" - you had $60 unplanned at Target
LONG-TERM GOAL SUGGESTIONS:
• Build emergency fund to $5,000 (you're at $2,400 - so close!)
• Create a "fun money" budget for guilt-free spending
• Consider a side hustle goal: grow freelance to $500/month
YOU'RE DOING GREAT! Despite the car repair setback, you're managing your finances responsibly. Your payment delays are minimal (4.5 days avg), and you're actively working on solutions.
What would you like to focus on most right now? Your coffee optimization, emergency fund building, or maybe creating a monthly budget that includes fun money? I'm here to help! 💪
Sample Weekly Check-in:
Hey Sarah! Time for our weekly financial check-in! 🌟
THIS WEEK'S WINS:
• You meal prepped at Costco ($85) - smart move for both health and budget!
• Invested in yourself with that Python course ($299) - career development is always a good investment!
• Only one impulse purchase this week (much better than last week!)
SPENDING PATTERNS TO NOTE:
Your coffee spending was $315 this week (7 days × $45). That's consistent with your habit, but remember our goal to try home brewing 3 days?
NEXT WEEK'S SMALL IMPROVEMENT:
Try the "24-hour rule" before any purchase over $50. This week you bought headphones ($142) - were they planned or impulse?
YOU'RE MAKING PROGRESS! 📈
Your emergency fund is slowly rebuilding, and I love seeing your focus on career development. Keep up the great work!
What's your financial goal for next week? Want to try that coffee experiment? 😊
Here are additional examples of how Sarah's daily financial activities help AI understand her better:
{
"actor": "user:sarah_jones",
"content": "Sarah canceled her Netflix subscription of $15.99",
"timestamp": "2025-07-16T10:30:00Z",
"metadata": {
"action": "cancel",
"service": "Netflix",
"monthly_amount": 15.99,
"reason": "cost_cutting"
}
}
What AI tells Sarah:
"Great job canceling Netflix! You've now saved $47/month by canceling 3 subscriptions. This shows you're serious about your budget - keep it up! This cost-cutting will help you reach your emergency fund goal faster."
{
"actor": "user:sarah_jones",
"content": "Sarah invested $500 in index funds through her 401k",
"timestamp": "2025-07-17T09:15:00Z",
"metadata": {
"amount": 500.00,
"investment_type": "401k",
"asset_class": "index_funds",
"frequency": "monthly"
}
}
What AI tells Sarah:
"You're doing amazing with your 401k! Even with your recent car repair expense, you're still investing $500/month for retirement. This consistency shows strong financial discipline. You're building a solid future!"
{
"actor": "user:sarah_jones",
"content": "Sarah paid $1,200 for car repair at AutoFix",
"timestamp": "2025-07-18T14:45:00Z",
"metadata": {
"amount": 1200.00,
"category": "emergency",
"merchant": "AutoFix",
"payment_method": "credit_card",
"urgency": "high"
}
}
What AI tells Sarah:
"I know that $1,200 car repair was unexpected and stressful. Since you used your credit card, let's make a plan to pay it off quickly. Want to temporarily reduce your coffee budget to put that money toward this repair? I can help you create a payoff plan."
{
"actor": "user:sarah_jones",
"content": "Sarah received $350 from freelance work",
"timestamp": "2025-07-19T16:20:00Z",
"metadata": {
"amount": 350.00,
"source": "freelance",
"category": "additional_income",
"frequency": "irregular"
}
}
What AI tells Sarah:
"Your freelance work is bringing in an extra $350/month on average - that's fantastic! This extra income is really helping your overall financial picture. Have you considered using some of this for your emergency fund or to pay down that car repair faster?"
Graphiti gives AI a perfect memory that never forgets anything important. Through Sarah's financial journey, we've seen how simple daily activities like "Sarah bought coffee for $45" or "Sarah paid her bill 5 days late" become smart insights that ChatGPT can use to help her make better financial decisions:
Our example shows how to build a system that remembers, understands, and advises Sarah through AI—creating a personal financial coach that learns from her daily life and helps her achieve her money goals.
The magic isn't in the technology itself, but in how Graphiti's memory + ChatGPT's intelligence = a personal financial advisor that actually understands Sarah's unique situation and helps her improve over time.
What makes this work for Sarah:
Ready to build your own AI financial coach?
→ git clone https://github.com/getzep/graphiti
and start creating personalized AI assistants that actually remember and learn today!
About Me
Since I was a child, I've always wanted to be an inventor. As I grew up, I specialized in information systems, an area which I fell in love with and live around it. I am a full-stack developer and work a lot with devops, i.e., I'm a kind of "jack-of-all-trades" in IT. Wherever there is something cool or new, you'll find me exploring and learning... I am passionate about life, family, and sports. I believe that true happiness can only be achieved by balancing these pillars. I am always looking for new challenges and learning opportunities, and would love to connect with other technology professionals to explore possibilities for collaboration. If you are looking for a dedicated and committed full-stack developer with a passion for excellence, please feel free to contact me. It would be a pleasure to talk with you! |
SecurityScoreCard
Nov. 2023 - Present
New York, United States
Senior Software Engineer
I joined SecurityScorecard, a leading organization with over 400 employees, as a Senior Full Stack Software Engineer. My role spans across developing new systems, maintaining and refactoring legacy solutions, and ensuring they meet the company's high standards of performance, scalability, and reliability.
I work across the entire stack, contributing to both frontend and backend development while also collaborating directly on infrastructure-related tasks, leveraging cloud computing technologies to optimize and scale our systems. This broad scope of responsibilities allows me to ensure seamless integration between user-facing applications and underlying systems architecture.
Additionally, I collaborate closely with diverse teams across the organization, aligning technical implementation with strategic business objectives. Through my work, I aim to deliver innovative and robust solutions that enhance SecurityScorecard's offerings and support its mission to provide world-class cybersecurity insights.
Technologies Used:
Node.js Terraform React Typescript AWS Playwright and Cypress