8000
Skip to content

STiFLeR7/dex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Dex - Personal AI Assistant

Dex Logo

MCP-Powered β€’ Memory-Aware β€’ Multi-Channel

Python FastAPI React Vite Gemini


🎯 Overview

Dex is a production-grade personal AI assistant built on the Model Context Protocol (MCP) architecture. Unlike generic chatbots, Dex is designed to be a persistent, memory-aware assistant that:

  • 🧠 Remembers your conversations, notes, and preferences
  • ⏰ Tracks reminders and sends alerts via WhatsApp/Telegram
  • πŸ”„ Syncs seamlessly across Web, WhatsApp, and Telegram
  • πŸ“Ž Handles file uploads and context-aware responses
  • πŸ” Traces all interactions via Opik for observability

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         Dex Architecture                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”‚
β”‚  β”‚   Web UI    β”‚    β”‚  WhatsApp   β”‚    β”‚  Telegram   β”‚         β”‚
β”‚  β”‚  (Vite)     β”‚    β”‚    Bot      β”‚    β”‚    Bot      β”‚         β”‚
β”‚  β”‚  :5173      β”‚    β”‚   Baileys   β”‚    β”‚   grammY    β”‚         β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜         β”‚
β”‚         β”‚                  β”‚                  β”‚                 β”‚
β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β”‚
β”‚                            β–Ό                                    β”‚
β”‚                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                          β”‚
β”‚                   β”‚   MCP Runtime   β”‚                          β”‚
β”‚                   β”‚   (FastAPI)     β”‚                          β”‚
β”‚                   β”‚     :8000       β”‚                          β”‚
β”‚                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                          β”‚
β”‚                            β”‚                                    β”‚
β”‚         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                β”‚
β”‚         β–Ό                  β–Ό                  β–Ό                β”‚
β”‚  β”Œβ”€β”€β”€β”€β”
8000
€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚
β”‚  β”‚ Orchestratorβ”‚   β”‚   Prompt    β”‚   β”‚    Tools    β”‚          β”‚
β”‚  β”‚  + Session  β”‚   β”‚  Registry   β”‚   β”‚  (Echo,Calc)β”‚          β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚
β”‚         β”‚                                                       β”‚
β”‚         β–Ό                                                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                             β”‚
β”‚  β”‚ Gemini 2.0  β”‚   β”‚   Opik      β”‚                             β”‚
β”‚  β”‚   Flash     β”‚   β”‚  Tracing    β”‚                             β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                             β”‚
β”‚                                                                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“‚ Project Structure

dex/
β”œβ”€β”€ ui/                          # Frontend (Vite + React + TypeScript)
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ InputArea.tsx        # Message input with file upload
β”‚   β”‚   β”œβ”€β”€ LeftSidebar.tsx      # Conversation history
β”‚   β”‚   β”œβ”€β”€ RightSidebar.tsx     # Quick Access panel
β”‚   β”‚   β”œβ”€β”€ MessageBubble.tsx    # Chat messages
β”‚   β”‚   └── WelcomeScreen.tsx    # Landing screen
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   └── api.ts               # Backend API integration
β”‚   β”œβ”€β”€ App.tsx                  # Main application
β”‚   └── types.ts                 # TypeScript interfaces
β”‚
β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ mcp_runtime/             # Core MCP Runtime
β”‚   β”‚   β”œβ”€β”€ main.py              # FastAPI app + endpoints
β”‚   β”‚   β”œβ”€β”€ orchestrator.py      # Message orchestration
β”‚   β”‚   β”œβ”€β”€ llm.py               # Gemini client
β”‚   β”‚   β”œβ”€β”€ session.py           # Session management
β”‚   β”‚   β”œβ”€β”€ gateway.py           # WebSocket gateway
β”‚   β”‚   └── schemas.py           # Pydantic models
β”‚   β”‚
β”‚   β”œβ”€β”€ prompt_registry/         # Prompt Management
β”‚   β”‚   β”œβ”€β”€ registry.py          # Prompt loader
β”‚   β”‚   └── prompts/
β”‚   β”‚       └── dex_core.yaml    # Dex persona definition
β”‚   β”‚
β”‚   β”œβ”€β”€ tools/                   # Tool Definitions
β”‚   β”‚   └── definitions.py       # Echo, Calculator tools
β”‚   β”‚
β”‚   └── channels/                # Multi-Channel Adapters
β”‚       β”œβ”€β”€ discord/             # Discord bot
β”‚       β”œβ”€β”€ telegram/            # Telegram bot (grammY)
β”‚       └── whatsapp/            # WhatsApp bot (Baileys)
β”‚
β”œβ”€β”€ web/                         # Legacy Next.js UI (deprecated)
β”œβ”€β”€ k8s/                         # Kubernetes manifests
β”œβ”€β”€ scripts/                     # Utility scripts
└── .env                         # Environment variables

πŸš€ Quick Start

Prerequisites

1. Clone & Setup Environment

# Clone the repository
git clone https://github.com/STiFLeR7/dex.git
cd dex

# Create Python virtual environment
python -m venv venv
.\venv\Scripts\Activate.ps1

# Install Python dependencies
pip install fastapi uvicorn httpx python-dotenv pyyaml opik pytz python-multipart

2. Configure Environment

Create a .env file in the project root:

# Gemini API (Get from https://aistudio.google.com/apikey)
GEMINI_API_KEY=your_gemini_api_key_here

# Opik Tracing (Optional - for observability)
OPIK_API_KEY=your_opik_api_key
OPIK_WORKSPACE=your_workspace

# Channel Tokens (Optional - for multi-channel)
DISCORD_BOT_TOKEN=your_discord_token
TELEGRAM_BOT_TOKEN=your_telegram_token

3. Start the Backend

# From project root with venv activated
uvicorn services.mcp_runtime.main:app --reload --port 8000

4. Start the Frontend

# In a new terminal
cd ui
npm install
npm run dev

5. Access Dex

Open http://localhost:5173 in your browser.


πŸ“‘ API Endpoints

Endpoint Method Description
/ GET Health check
/v1/process POST Process message (main endpoint)
/v1/whatsapp/status GET Check WhatsApp connection
/v1/whatsapp/connect POST Mark WhatsApp connected
/v1/notes GET/POST Manage saved notes
/v1/reminders GET/POST Manage reminders
/v1/upload POST Upload files
/ws/{conversation_id} WebSocket Real-time messaging

Example: Send Message

curl -X POST http://localhost:8000/v1/process \
  -H "Content-Type: application/json" \
  -d '{
    "context_id": "123",
    "assistant": {"name": "Dex", "persona_version": "2.0.0"},
    "session": {"type": "web", "conversation_id": "conv-1"},
    "user_input": {"message": "Hello Dex!"},
    "prompt": {"id": "dex-core", "version": "2.0.0"},
    "tools_available": ["echo", "calculator"]
  }'

🎨 UI Features

Feature Description
Dark Theme Professional grey (#1a1a1a) with green accents (#22c55e)
File Upload Attach images, PDFs, docs via paperclip button
Conversation History Persisted in localStorage, grouped by date
Quick Access Panel Real-time date/time, notes, reminders
Channel Connect Connect WhatsApp/Telegram from UI
Responsive Works on desktop, tablet, mobile

πŸ”Œ Multi-Channel Setup

WhatsApp (Baileys)

cd services/channels/whatsapp
npm install
npm start
# Scan QR code when prompted

Telegram (grammY)

# Set TELEGRAM_BOT_TOKEN in .env first
cd services/channels/telegram
npm install
npm start

Discord

# Set DISCORD_BOT_TOKEN in .env first
cd services/channels/discord
npm install
npm start

🧠 Dex Persona

Dex is configured via services/prompt_registry/prompts/dex_core.yaml:

id: dex-core
version: "2.0.0"

system_prompt: |
  You are **Dex**, a personal AI assistant.
  
  ## IDENTITY
  - Your name is **Dex** - always introduce yourself by name
  - You are friendly, helpful, and precise
  - You remember context from conversations
  
  ## CURRENT CONTEXT
  - Current Date: {current_date}
  - Current Time: {current_time}
  - Timezone: {timezone}
  - Day of Week: {day_of_week}

The orchestrator automatically injects the current date/time into every response.


πŸ“Š Observability

Dex uses Opik for tracing and observability:

  • All interactions are logged with trace IDs
  • View traces at Comet Opik Dashboard
  • Traces include: messages, LLM calls, tool executions

πŸ› οΈ Development Status

Component Status
MCP Runtime βœ… Complete
Gemini Integration βœ… Complete
Web UI (Vite) βœ… Complete
File Upload βœ… Complete
Session Management βœ… Complete
Opik Tracing βœ… Complete
WhatsApp Bot πŸ”§ Ready (needs testing)
Telegram Bot πŸ”§ Ready (needs testing)
Discord Bot πŸ”§ Ready (needs testing)
Kubernetes Deployment πŸ“‹ Prepared

πŸ”œ Coming Soon

  • Persistent database for notes/reminders
  • User authentication system
  • Voice input/output
  • Advanced tool integrations
  • Mobile app (React Native)

πŸ“ License

MIT License - See LICENSE for details.


Built with ❀️ by STIFLER

About

Dex is a production-grade personal AI assistant built on the Model Context Protocol (MCP) architecture. Unlike generic chatbots, Dex is designed to be a persistent, memory-aware assistant.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

0