← Back to home

Contekst

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

Problem Statement

Contekstis 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 FeaturesIntent-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.🏗️ ArchitectureRuntime: 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 FluenceEmbeddings: OpenAI'stext-embedding-3-largeDatabase: MySQL with connection pooling - hosted on FluenceAI Computation: OpenAI'sgpt-5-minifor intent extractionBlockchain: Ethereum/Sui integration with smart contractsCaching: Redis for high-performance caching - hosted on FluenceImage Storage: Walrus decentralized storage

Solution

How We Built Contekst: The Nitty-Gritty Technical DetailsContekstis 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 StackRuntime & PerformanceBun Runtime: Chose Bun over Node.js for significantly faster performance across the entire stackElysiaJS Backend: Lightning-fast TypeScript backend framework that outperforms ExpressNext.js 14 Frontend: React 18 with App Router for modern SSR/SSG capabilitiesMonorepo Structure: Bun workspaces for efficient dependency management across 4 main applicationsDatabase & Storage LayerQdrant Vector Database: High-performance vector search using 3072D embeddings for semantic memory retrievalRedis Caching: Sub-second response times with intelligent caching strategiesWalrus Decentralized Storage: For image, large file, and encrypted conversation context blob storage with blockchain verificationAI & EmbeddingsOpenAI GPT-5 Mini: For AI computation and memory processingOpenAI text-embedding-3-large: 3072-dimensional embeddings for superior semantic understandingCustom Retrieval Algorithm: Multi-stage semantic search with similarity thresholdsBlockchain IntegrationHedera Smart Contracts: For on-chain memory ownership, access-control, and audit trailsSIWE (Sign-In With Ethereum): For wallet-based authentication🔧 The Four Major Applications1. Backend API (apps/backend)Tech Stack: Bun + ElysiaJS + TypeScript + Drizzle ORMThe backend handles all core business logic:Memory Processing Pipeline: Intent + Facts + Summary + Tags extraction → Embedding generation → Vector storageSemantic Search Engine: Multi-stage retrieval with relevance scoringBlockchain Integration: Smart contract interactions for memory ownership, Access-Control, Audit TrailsAuthentication System: JWT + wallet signature verificationImage Processing: Base64 handling with Walrus storage integrationKey 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 + RainbowKitModern web interface with wallet connectivity:Wallet Authentication: RainbowKit + Wagmi for seamless Web3 integrationMemory Management UI: Browse, search, and manage stored memoriesReal-time Updates: Live memory processing statusResponsive Design: Mobile-first approach with Tailwind CSSKey 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 APIThe most technically challenging component:Content Scripts: Separate implementations for ChatGPT and ClaudeDOM Manipulation: Real-time injection of context buttonsCross-Origin Communication: Extension ↔ Web App ↔ BackendImage Capture: Automatic detection and processing of uploaded images4. Smart Contracts (apps/contracts)Tech Stack: Solidity 0.8.28 + Hardhat + TypeScriptDecentralized memory ownership and access control:DomainRegistry.sol: Maps domain names to official wallet addressesMemoryControl.sol: Manages memory ownership, permissions, and audit trailsHybrid Storage Model: On-chain metadata hashes, off-chain contentAdvanced Access Control: Time-based, granular, and domain-specific permissions🚧 Major Technical Challenges1. Browser Extension ComplexityChallenge: Building a browser extension is deceptively complex, especially for dynamic web apps.Specific Issues:DOM Element Instability: ChatGPT and Claude constantly change their DOM structureContent Script Injection: Timing issues with SPA navigationCross-Origin Restrictions: Extension security model limitations2. AI App DOM Manipulation NightmareChallenge: 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 structureSend button selectors change frequentlyReact state management interferes with direct DOM manipulationClaude Challenges:Different contenteditable implementationMore aggressive DOM restructuringComplex layout changes after message sending3. Wallet Authentication in ExtensionsChallenge:window.ethereumdoesn't work inside browser extensions, making wallet connection extremely complex.The Problem:Extensions run in isolated contextsNo direct access to injected wallet providersComplex user flow between extension popup and web app4. Smart Contract Lease Management ComplexityChallenge: 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 revocationGranular Permissions: Memory-level vs domain-level accessDomain Verification: Preventing domain spoofing attacksGas Optimization: Minimizing transaction costsHybrid Storage: On-chain hashes, off-chain content5. Sub-Second Performance on VM DeploymentChallenge: Ensuring sub-second computation and retrieval while deployed on a VM.Performance Optimizations:Redis Caching: Aggressive caching of embeddings and search resultsConnection Pooling: MySQL connection reuseVector Index Optimization: Qdrant HNSW parameters tuningBun Runtime: 3x faster than Node.js for our workload🔍 Deployment & InfrastructureBackend DeploymentFluence Platform: Decentralized compute for backend servicesDocker Containerization: Consistent deployment environmentEnvironment Variables: Secure configuration managementHealth Checks: Comprehensive monitoring endpointsDatabase HostingFluence-hosted MySQL: Managed database with automatic backupsFluence-hosted Qdrant: Managed vector database with high availabilityFluence-hosted Redis: Managed caching layer

Hackathon

ETHGlobal New Delhi

2025

Contributors