architecture.md

January 30, 2026 · View on GitHub

Architecture

Multi-Provider LLM Architecture

┌─────────────────────────────────────────────────────────────┐
│                    Nylas AI Assistant CLI                   │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  User Input: "Schedule 30-min call with John next Tuesday" │
│       ↓                                                     │
│  ┌─────────────────────────────────────────────────────┐   │
│  │  Unified LLM Interface (Provider-Agnostic)          │   │
│  │  - Input validation                                 │   │
│  │  - Prompt templating                                │   │
│  │  - Function calling setup                           │   │
│  │  - Response parsing                                 │   │
│  └─────────────────────────────────────────────────────┘   │
│       ↓                                                     │
│  ┌─────────────────────────────────────────────────────┐   │
│  │  Provider Router (selects based on config)          │   │
│  └─────────────────────────────────────────────────────┘   │
│       ↓         ↓           ↓          ↓                   │
│  ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐              │
│  │ Ollama │ │ Claude │ │OpenAI  │ │ Groq   │              │
│  │ (Local)│ │ (Cloud)│ │(Cloud) │ │(Cloud) │              │
│  │ FREE   │ │  $$    │ │  $$    │ │  $     │              │
│  └────────┘ └────────┘ └────────┘ └────────┘              │
│       ↓                                                     │
│  ┌─────────────────────────────────────────────────────┐   │
│  │  Function Calling Tools                             │   │
│  │  - findMeetingTime(participants, duration, ...)     │   │
│  │  - checkDST(time, timezone)                         │   │
│  │  - validateWorkingHours(time, timezone)             │   │
│  │  - createEvent(title, time, participants, ...)      │   │
│  │  - analyzePatterns(userId, lookbackDays)            │   │
│  │  - suggestFocusTime(userId, weekStart)              │   │
│  └─────────────────────────────────────────────────────┘   │
│       ↓                                                     │
│  ┌─────────────────────────────────────────────────────┐   │
│  │  Calendar & Timezone Services                       │   │
│  │  - Nylas API (events, availability, calendars)      │   │
│  │  - Timezone Service (conversions, DST, scoring)     │   │
│  └─────────────────────────────────────────────────────┘   │
│                                                             │
└─────────────────────────────────────────────────────────────┘

Function Calling Tools

AI agents have access to specialized tools:

ToolDescriptionParameters
findMeetingTimeFind optimal meeting times across timezonesparticipants, duration, dateRange, workingHours
checkDSTCheck if time falls during DST transitiontime, timezone
validateWorkingHoursCheck if time is within working hourstime, timezone, workStart, workEnd
createEventCreate calendar eventtitle, startTime, endTime, participants, timezone
getAvailabilityGet participant availabilityparticipants, startTime, endTime
analyzePatternsAnalyze historical calendar patternsuserId, lookbackDays
suggestFocusTimeSuggest focus time blocksuserId, weekStart