Contekst

Contekst is a unified memory layer for seamless context continuity across AI application.

Contekst

Created At

ETHGlobal New Delhi

Project Description

Contekst is a high-performance unified memory layer that gives AI applications true context continuity—so users never have to “start over” when switching tools or platforms.

🚀 Key Features

  • Intent-based Memory Storage: Instead of just summarizing text, it focuses on categorically capturing the user's intents, facts and summaries.
  • Fast Semantic Search: Advanced sub-second retrieval algorithm using multiple retrieval techniques.
  • Cross-LLM Compatibility: You can switch between different LLM platforms and still maintain the context of the conversation.
  • Decentralized Storage: It uses a scalable cloud database hosted on a decentralized computing platform like Fluence.
  • Blockchain Integration: Smart contracts for memory management and decentralized storage verification.
  • Browser Extension: Seamless integration with ChatGPT and Claude for enhanced context awareness.

🏗️ Architecture

  • Runtime: Bun (which is faster than Node.js)
  • Backend Framework: ElysiaJS with TypeScript (hosted on Fluence)
  • Frontend: Next.js 14 with React 18 and Tailwind CSS (deployed on Vercel)
  • Vector Database: Qdrant (using 3072D embeddings for better intent understanding) - hosted on Fluence
  • Embeddings: OpenAI's text-embedding-3-large
  • Database: MySQL with connection pooling - hosted on Fluence
  • AI Computation: OpenAI's gpt-5-mini for intent extraction
  • Blockchain: Ethereum/Sui integration with smart contracts
  • Caching: Redis for high-performance caching - hosted on Fluence
  • Image Storage: Walrus decentralized storage

How it's Made

How We Built Contekst: The Nitty-Gritty Technical Details

Contekst is a high-performance unified memory layer that provides seamless context continuity across AI applications. Here's the deep dive into how we built this complex system and the major challenges we overcame.

Guilty Confession: This doc is AI generated (couldn't help it... we were racing against the clock) but trut me the challenges we faces were even more real than Donald Trump's cameo in Epstein Files :)

🏗️ Core Architecture & Technology Stack

Runtime & Performance

  • Bun Runtime: Chose Bun over Node.js for significantly faster performance across the entire stack
  • ElysiaJS Backend: Lightning-fast TypeScript backend framework that outperforms Express
  • Next.js 14 Frontend: React 18 with App Router for modern SSR/SSG capabilities
  • Monorepo Structure: Bun workspaces for efficient dependency management across 4 main applications

Database & Storage Layer

  • Qdrant Vector Database: High-performance vector search using 3072D embeddings for semantic memory retrieval
  • Redis Caching: Sub-second response times with intelligent caching strategies
  • Walrus Decentralized Storage: For image, large file, and encrypted conversation context blob storage with blockchain verification

AI & Embeddings

  • OpenAI GPT-5 Mini: For AI computation and memory processing
  • OpenAI text-embedding-3-large: 3072-dimensional embeddings for superior semantic understanding
  • Custom Retrieval Algorithm: Multi-stage semantic search with similarity thresholds

Blockchain Integration

  • Hedera Smart Contracts: For on-chain memory ownership, access-control, and audit trails
  • SIWE (Sign-In With Ethereum): For wallet-based authentication

🔧 The Four Major Applications

1. Backend API (apps/backend)

Tech Stack: Bun + ElysiaJS + TypeScript + Drizzle ORM

The backend handles all core business logic:

  • Memory Processing Pipeline: Intent + Facts + Summary + Tags extraction → Embedding generation → Vector storage
  • Semantic Search Engine: Multi-stage retrieval with relevance scoring
  • Blockchain Integration: Smart contract interactions for memory ownership, Access-Control, Audit Trails
  • Authentication System: JWT + wallet signature verification
  • Image Processing: Base64 handling with Walrus storage integration

Key Libraries:

{
  "@elysiajs/cors": "^1.4.0",
  "@mysten/sui": "^1.38.0", 
  "@mysten/walrus": "^0.7.0",
  "@qdrant/js-client-rest": "^1.15.1",
  "ethers": "5",
  "openai": "^5.23.1",
  "redis": "^5.8.2",
  "siwe": "^3.0.0"
}

2. Frontend Web App (apps/frontend)

Tech Stack: Next.js 14 + React 18 + Tailwind CSS + RainbowKit

Modern web interface with wallet connectivity:

  • Wallet Authentication: RainbowKit + Wagmi for seamless Web3 integration
  • Memory Management UI: Browse, search, and manage stored memories
  • Real-time Updates: Live memory processing status
  • Responsive Design: Mobile-first approach with Tailwind CSS

Key Libraries:

{
  "@rainbow-me/rainbowkit": "^2.2.8",
  "@tanstack/react-query": "^5.89.0",
  "next": "14.2.5",
  "siwe": "^3.0.0",
  "viem": "^2.37.6",
  "wagmi": "^2.17.0"
}

3. Browser Extension (apps/extension)

Tech Stack: TypeScript + React + Webpack + Chrome Extension API

The most technically challenging component:

  • Content Scripts: Separate implementations for ChatGPT and Claude
  • DOM Manipulation: Real-time injection of context buttons
  • Cross-Origin Communication: Extension ↔ Web App ↔ Backend
  • Image Capture: Automatic detection and processing of uploaded images

4. Smart Contracts (apps/contracts)

Tech Stack: Solidity 0.8.28 + Hardhat + TypeScript

Decentralized memory ownership and access control:

  • DomainRegistry.sol: Maps domain names to official wallet addresses
  • MemoryControl.sol: Manages memory ownership, permissions, and audit trails
  • Hybrid Storage Model: On-chain metadata hashes, off-chain content
  • Advanced Access Control: Time-based, granular, and domain-specific permissions

🚧 Major Technical Challenges

1. Browser Extension Complexity

Challenge: Building a browser extension is deceptively complex, especially for dynamic web apps.

Specific Issues:

  • DOM Element Instability: ChatGPT and Claude constantly change their DOM structure
  • Content Script Injection: Timing issues with SPA navigation
  • Cross-Origin Restrictions: Extension security model limitations

2. AI App DOM Manipulation Nightmare

Challenge: Capturing and inserting content from/to ChatGPT and Claude is extremely difficult due to constantly changing DOM elements.

ChatGPT Challenges:

  • Uses ProseMirror editor with complex paragraph structure
  • Send button selectors change frequently
  • React state management interferes with direct DOM manipulation

Claude Challenges:

  • Different contenteditable implementation
  • More aggressive DOM restructuring
  • Complex layout changes after message sending

3. Wallet Authentication in Extensions

Challenge: window.ethereum doesn't work inside browser extensions, making wallet connection extremely complex.

The Problem:

  • Extensions run in isolated contexts
  • No direct access to injected wallet providers
  • Complex user flow between extension popup and web app

4. Smart Contract Lease Management Complexity

Challenge: Managing memory leases on-chain is far more complex than expected due to numerous edge cases.

Edge Cases We Had to Handle:

  • Time-based Access Expiration: Automatic permission revocation
  • Granular Permissions: Memory-level vs domain-level access
  • Domain Verification: Preventing domain spoofing attacks
  • Gas Optimization: Minimizing transaction costs
  • Hybrid Storage: On-chain hashes, off-chain content

5. Sub-Second Performance on VM Deployment

Challenge: Ensuring sub-second computation and retrieval while deployed on a VM.

Performance Optimizations:

  • Redis Caching: Aggressive caching of embeddings and search results
  • Connection Pooling: MySQL connection reuse
  • Vector Index Optimization: Qdrant HNSW parameters tuning
  • Bun Runtime: 3x faster than Node.js for our workload

🔍 Deployment & Infrastructure

Backend Deployment

  • Fluence Platform: Decentralized compute for backend services
  • Docker Containerization: Consistent deployment environment
  • Environment Variables: Secure configuration management
  • Health Checks: Comprehensive monitoring endpoints

Database Hosting

  • Fluence-hosted MySQL: Managed database with automatic backups
  • Fluence-hosted Qdrant: Managed vector database with high availability
  • Fluence-hosted Redis: Managed caching layer
background image mobile

Join the mailing list

Get the latest news and updates