Inspiration
Current AI assistants are stateless. They forget everything the moment a conversation ends. Users are forced to repeatedly explain their goals, projects, priorities, and preferences, leading to generic, context-free, and repetitive responses.
We wanted to build an AI assistant that actually remembers and learns. Memoria AI was inspired by the idea of giving agents a persistent, structured, and self-improving memory architecture. Instead of a temporary chatbot, Memoria AI acts as a personal Chief of Staff that understands your long-term roadmap, tracks your task checklist, and proactively guides your decisions based on past interactions.
What it does
Memoria AI is a cognitive personal Chief of Staff agent that organizes your life and projects through four distinct memory dimensions:
- Secure Onboarding & Bring Your Own Database (BYODB): Users sign up and log in using a secure custom credentials portal where they can paste and connect their own MongoDB Atlas clusters. Connection strings are encrypted and managed dynamically, ensuring complete user privacy.
- Episodic & Semantic Memory: Captures important life events, milestones, and factual user preferences (e.g., your tech stack, business strategy, or design inspiration).
- Goal Memory: Tracks long-term, multi-month objectives (e.g., launching an MVP or acquiring beta customers).
- Task Memory: Automatically extracts actionable to-do items from your conversations and compiles them into checkable checklists.
- Reflection Engine: Periodically audits your memory logs using Gemini to deduce behavioral patterns and write high-level cognitive insights (e.g., realizing you are postponing marketing tasks in favor of coding), feeding them back into your memory vector store.
- Intelligent Retrieval: Uses semantic search to pull relevant memories, goals, and reflections to ground Gemini's reasoning before responding.
- Interactive Console Dashboard: Visualizes your MongoDB collections, entity nodes, relationship links, and raw embeddings, and features an MCP Hub to query the database using natural language.
How we built it
- Frontend: Built with Next.js 15, utilizing Framer Motion for premium micro-animations, Lucide React for modern iconography, and customized dark-mode Vanilla CSS (HSL-tailored glassmorphism).
- Authentication & Encryption: Custom credentials-based authentication using Node’s native
cryptomodule (PBKDF2 password hashing and HMAC session signatures). User database connection strings are encrypted with AES-256-CBC and stored securely in signed, HTTP-only session cookies. - Agent Framework: Orchestrated using the new Google ADK (Agent Development Kit). We defined our Chief of Staff agent using
LlmAgent, managed execution streams viaInMemoryRunner, and registered domain-specificFunctionToolsfor memory search, goal queries, and reflection. - Model: Powered by Gemini 2.5 Flash (via
@google/genai) for conversational intelligence, memory extraction, and cognitive reflections. - Memory & Search Layer: MongoDB Atlas serves as the persistent memory store, holding collections for
users,conversations,messages,memories,goals,tasks,reflections,entities,relationships, andembeddings. - Vector Search: MongoDB Atlas Vector Search performs semantic retrieval on the memory embeddings, with a fast local cosine similarity calculation fallback in the repository layer to guarantee reliability.
- Tool Integration: The MongoDB MCP (Model Context Protocol) Server is integrated via ADK's
MCPToolsetusingStdioConnectionParamsto auto-discover and execute database actions (finding documents, listing collections, running aggregations) directly through natural language.
Challenges we ran into
- DNS Resolution on ISP/Campus Networks: We encountered connection timeout errors when trying to resolve MongoDB Atlas SRV connection strings (
mongodb+srv://) or Google API domains on restricted networks. We solved this by creating a dynamic Next.jsinstrumentationhook that overrides Node's default DNS resolver to Google DNS (8.8.8.8/8.8.4.4) and prioritizes IPv4 first. - Gemini Multi-Turn Function-Calling sequence: In multi-turn tool calling, the Gemini API enforces strict alternating roles. When
@google/adkinternally stripped unique IDs from function calls and responses (viaremoveClientFunctionCallId), the Gemini API returned a 400 sequence error because it couldn't correlate the tool results. We solved this by patch-routing@google/adk's core module files to preserve these IDs and disabling thinking mode budget for the agent call, ensuring perfect API alignment. - MCP Subprocess Management: Running standard
npx mongodb-mcp-servercould hang if initial handshakes timed out. We resolved this by configuring a strict 30-second timeout connection and setting a startup delay to allow the server process to settle before executing the JSON-RPC handshake. - Next.js Client/Server Boundary Webpack Errors: Standard client components threw webpack resolution errors (
Cannot find module './996.js') when server-only modules (likenext/headers) were transitively imported by the database repositories. We resolved this by refactoring theUserRepositoryto remove dynamic imports and passing the verified session user ID directly from server-side Route Handlers.
Accomplishments that we're proud of
- Successfully integrating the brand new Google ADK framework and MongoDB MCP Server to run a fully local, tool-discovered database agent loop.
- Designing a highly secure, private, decentralized Bring Your Own Database (BYODB) workspace architecture that puts memory ownership entirely in the user's hands.
- Creating a complete cognitive loop that runs entirely in the background (message -> vector search -> Gemini streaming -> extraction of memories/entities/relationships -> reflection -> database save) in seconds.
- Building a gorgeous, responsive, HSL dark-mode console dashboard visualizing real-time MongoDB collections stats, vector search weights, and graph entity nodes.
- Securing the app by eliminating exposed credentials and enforcing strict
.gitignorepatterns.
What we learned
- The simplicity and elegance of using Google ADK's declarative
LlmAgentandInMemoryRunnerfor managing agentic sessions. - How to implement robust database fallbacks (like locally computed cosine similarity) to keep applications responsive while remote vector indexes are propagating.
- How to securely manage and route database connections dynamically using symmetric encryption and signed HTTP-only cookies in Next.js.
- The details of the Model Context Protocol (MCP) and how it makes databases natively discoverable to LLMs.
What's next for Memoria-Ai
- GraphRAG Integration: Combining Atlas Vector Search with our entity-relationship graph to support complex multi-hop queries (e.g., retrieving facts linked to a person who is linked to a specific project).
- Automated Background Auditing: Running the reflection engine on a daily cron job using Google Cloud Scheduler to continuously deliver fresh progress reviews.
- Enhanced Federated Auth: Incorporating OAuth providers (like Google Login) alongside the custom Bring Your Own Database connection configurations.
Log in or sign up for Devpost to join the conversation.