| Feature / Topic | Video Walkthrough | Presentation Slides (PDF) |
|---|---|---|
| Product Walkthrough & Live Demo | Watch Demo on YouTube | View Slides (PDF) |
| System Architecture Deep Dive | Watch Deep Dive on YouTube | View Architecture Deck (PDF) |
Cortex retrieves historically relevant context to maintain more natural and context-aware conversations. It can recall past interactions, user preferences, and emotional cues to provide personalized responses. Task Retrieval allows the user to know about the previously asked tasks and their status.
Unlike traditional AI talking systems, where the user asks, then waits for the response, Cortex is designed to handle heavy computational loads of AI reasoning without blocking real-time user interactions. You can ask "Search for the best places to visit in Goa" and while the system is processing, you can ask "What was the weather like in Goa last week?" without waiting for the first response. Cortex will seamlessly handle both queries, providing responses as they become available.
Cortex is designed with user experience in mind. For queries, which require more in-depth reasoning, instead of leaving the user wondering if the system is still processing, Cortex provides fallback responses like "Let me think about that..." or "I'm looking into it for you..." to keep the user informed and engaged while the system works on generating a more comprehensive answer.
Cortex can analyze the user's emotional state based on their interactions and adjust its responses accordingly. For example,
- If a user doesn't prefer long responses in the evening, Cortex can automatically provide concise answers during that time, while offering more detailed responses at other times.
- If a user shows some specific behavior or preference for a given time of day, say Night, Cortex will try to consider them in future conversations for the same time and mood.
Cortex actively builds and updates a memory profile for the user, which includes preferences, past interactions, and emotional cues. This allows it to provide more personalized and relevant responses over time, creating a more engaging experience.
The project adopts a highly decoupled, microservice-like architecture to handle the heavy computational loads of AI reasoning without blocking real-time user interactions.
graph TD
User((User)) <-->|Audio / UI| App[Electron + NextJS App]
subgraph Frontend
App
end
App <-->|WebSockets & REST| Server[cortex_server]
subgraph Backend Services
Server -->|POST /add_task| Queue[cortex_queue]
Queue -.->|Listen via BRPOP| Core[cortex_core]
Core -->|POST /submit_task| Queue
Queue -.->|Pub/Sub Result| Server
EventWorker[cortex_event_tool] -->|POST /add_task| Queue
Core -.->|Create Event| EventWorker
end
subgraph Storage & Shared Models
CM[cortex_cm] -->|Provides| PG[(PostgreSQL + pgvector)]
CM -->|Provides| Redis[(Redis DB0-DB3)]
Server -.-> CM
Queue -.-> CM
Core -.-> CM
EventWorker -.-> CM
end
The repository is divided into distinct, purpose-built modules. For detailed technical specifications, architecture diagrams, and API endpoints, please refer to the specific module's README:
- app/ - The user-facing Electron and NextJS application. Handles audio recording, WebSocket streaming, and UI for tasks, history, and settings.
- cortex_server/ - The FastAPI server. Manages real-time WebSocket communication, audio transcription (STT), text-to-speech (TTS) streaming via an Audio Bridge, and standard REST APIs.
- cortex_queue/ - The task ingestion and result distribution hub. Safely offloads heavy LLM processing from the WebSocket server and ensures state persistence in PostgreSQL before caching.
- cortex_core/ - The "brain" of the assistant. Runs the LangGraph workflows, implements Maximal Marginal Relevance (MMR) for context retrieval, handles memory retrieval and building, and dynamically adjusts response tones based on time and user mood.
- cortex_event_tool/ - The precise, cron-driven background worker. Monitors Redis for scheduled reminders and injects them into the queue at the perfect time.
- cortex_cm/ - The Common Module. Centralizes database schemas (SQLModel), Redis client configurations, and global AI model loaders.
- presentation/ - Presentation decks (PDFs), recording scripts, and system storyboard guides.
The user interface is available as a standalone desktop application.
- Download: Visit the releases section of this repository to download the executable for your operating system (Windows, macOS, or Linux).
- Connectivity: The application requires the Backend Infrastructure (Step 2) to be running. You can point the application to your backend by configuring environment variables if building from source.
For detailed UI instructions, refer to the app/README.md.
Cortex AI requires a set of microservices to handle AI reasoning, task queuing, and data persistence. These services are containerized and orchestrated using Docker Compose.
Prerequisites:
- Docker & Docker Compose
- Hugging Face Token (for gated model access)
- A
.envfile populated based on.env.example(See ENV Guide) - Google Authentication credentials
Running the Backend: To spin up the PostgreSQL database, Redis instance, and all Python-based microservices:
docker-compose up --buildServices Started:
cortex-pg-db: PostgreSQL 17 withpgvectoron port5460.cortex-redis-db: Redis on port6379.cortex-queue: The central task routing API on port8001.cortex-server: The client-facing WebSocket and REST API on port8000.cortex-core: The background LLM reasoning worker.cortex-event-worker: The background scheduling worker.
Once the backend is healthy, ensure your Application (Step 1) is configured to connect to http://localhost:8000 (or your server's IP).
The application requires several environment variables to function correctly. Copy .env.example to .env and configure the following:
- POSTGRES_USER: The username for the PostgreSQL database (default:
postgres). - POSTGRES_DB: The name of the database to be created and used.
- POSTGRES_PASSWORD: The password for the database user.
- POSTGRES_PORT: The port mapping for the PostgreSQL container (default:
5460).
- REDIS_HOST: The hostname for the Redis service (use
redisfor Docker Compose). - REDIS_PORT: The port for Redis communication (default:
6379).
- CORTEX_QUEUE_PORT: The port assigned to the cortex_queue service (default:
8001). - CORTEX_SERVER_PORT: The port assigned to the cortex_server service (default:
8000).
- TZ: The system timezone used for accurate logging and event scheduling (e.g., Asia/Kolkata).
- HF_TOKEN: Your Hugging Face token required to download gated models or access private repositories.
- HF_CACHE_DIR: The internal container path where models are cached (default: /root/.cache/huggingface).
- TRANSFORMERS_CHECK_LOCAL_CACHE: Set to 1 to force the system to use locally cached models only, or 0 to allow automatic downloads of missing weights.
- GOOGLE_CLIENT_ID: Your Google Cloud project OAuth 2.0 Client ID.
- GOOGLE_CLIENT_SECRET: Your Google Cloud project OAuth 2.0 Client Secret.
- GOOGLE_REDIRECT_URI: The authorized redirect URI for OAuth callbacks (e.g., http://localhost:3000/api/auth/callback/google).
- GOOGLE_AUTH_URI: The Google OAuth 2.0 authorization endpoint.
- GOOGLE_TOKEN_URI: The Google OAuth 2.0 token exchange endpoint.
One thing a fellow developer might be confused about is why LangGraph workflows are used instead of an autonomous agent workflow. The reason is simple:
- Control and Predictability: I wanted to have more control over the flow of the conversation and the reasoning process. With a LangGraph workflow, I can define specific steps and logic for handling user queries, managing memory, and generating responses.
- Consistency: Agent workflows decide their path on their own based on the query provided, which can lead to unpredictable behavior and less control over the user experience.
- Objective: My objective was to create a more structured and consistent conversational experience, which is better achieved with a custom workflow rather than pure autonomous AI agents.
Cortex utilizes centralized model loading via the cortex_cm module, assigning specific models to the tasks they are best suited for:
- Planning and Routing: Qwen models (
Qwen/Qwen2.5-7B-Instruct) are utilized for localized planning as they demonstrate strong structural reasoning and are trained heavily on coding/logic tasks. - Orchestration & Heavy Planning: GPT models (
openai/gpt-oss-20b) are utilized for the main orchestrator and complex planning tasks that require deep, structured reasoning over large contexts. - Conversations: Meta's Llama models (
meta-llama/Llama-3.1-8B-Instructandmeta-llama/Llama-3.3-70B-Instruct) are used for normal, fluid conversations and heavy response generation as they are trained extensively on general, human-like dialogue. - Vector Search & Memory: Sentence Transformer models (
sentence-transformers/all-MiniLM-L6-v2) are employed specifically for Maximal Marginal Relevance (MMR) and vector similarity search. - Sensory Processing: OpenAI Whisper (
openai/whisper-small) is used for highly accurate local Speech-to-Text (STT) transcription, and the Kokoro pipeline (hexgrad/Kokoro-82M) is used for low-latency Text-to-Speech (TTS) synthesis. Emotion detection relies on BERT (boltuix/bert-emotion).
- More Exciting Tools Integration: Currently, the Cortex Core has three specialized tools (Web Search, Task Retrieval, and Event Creation). My next plan is to bring more tools to the system to further enhance capabilities, such as calendar management, music player control, and email management.
- Agentic Workflow (+ HITL): I am planning to integrate an Agentic workflow to allow the system to autonomously plan out complex scenarios. For example, if a user asks "Plan a trip to Goa for me", the system could autonomously plan the itinerary, book hotels, and suggest activities based on preferences. I also want to integrate Human-in-the-Loop (HITL) for critical tasks where human oversight is necessary to ensure accuracy and safety.
- More Language Support: Currently, the system primarily supports English, but I plan to expand its capabilities to support multiple languages, making it accessible to a wider audience.
- Enhanced Emotional Profiling: I want to further enhance the emotional profiling capabilities of the system, allowing it to better understand and respond to user emotions, creating an even more empathetic and personalized experience.
This project relies on several open-source models hosted on Hugging Face:
- Qwen/Qwen2.5-7B-Instruct
- meta-llama/Llama-3.1-8B-Instruct
- meta-llama/Llama-3.3-70B-Instruct
- sentence-transformers/all-MiniLM-L6-v2
- openai/whisper-small
- hexgrad/Kokoro-82M
- boltuix/bert-emotion
- openai/gpt-oss-20b
For any query or suggestion, email me on [email protected]
