{"id":43194262,"url":"https://github.com/amotivv-inc/snowflake-memory-box","last_synced_at":"2026-02-01T05:14:11.270Z","repository":{"id":318542877,"uuid":"1010913402","full_name":"amotivv-inc/snowflake-memory-box","owner":"amotivv-inc","description":"Snowflake Memory Box: AI analytics with persistent memory using Cortex, Claude AI and Memory Box","archived":false,"fork":false,"pushed_at":"2025-10-21T15:10:41.000Z","size":267,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-21T17:24:57.657Z","etag":null,"topics":["ai","analytics","data-visualization","memory","snowflake"],"latest_commit_sha":null,"homepage":"https://memorybox.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amotivv-inc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-30T03:06:14.000Z","updated_at":"2025-10-21T15:10:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"dd8fd763-ddcb-45dd-8179-ebee18e269c7","html_url":"https://github.com/amotivv-inc/snowflake-memory-box","commit_stats":null,"previous_names":["amotivv-inc/snowflake-memory-box"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/amotivv-inc/snowflake-memory-box","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amotivv-inc%2Fsnowflake-memory-box","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amotivv-inc%2Fsnowflake-memory-box/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amotivv-inc%2Fsnowflake-memory-box/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amotivv-inc%2Fsnowflake-memory-box/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amotivv-inc","download_url":"https://codeload.github.com/amotivv-inc/snowflake-memory-box/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amotivv-inc%2Fsnowflake-memory-box/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28969082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T04:44:20.970Z","status":"ssl_error","status_checked_at":"2026-02-01T04:44:19.994Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","analytics","data-visualization","memory","snowflake"],"created_at":"2026-02-01T05:14:10.623Z","updated_at":"2026-02-01T05:14:11.262Z","avatar_url":"https://github.com/amotivv-inc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🧠 Snowflake Memory Box\n\n[![Next.js](https://img.shields.io/badge/Next.js-15-black?logo=next.js)](https://nextjs.org/)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5-blue?logo=typescript)](https://www.typescriptlang.org/)\n[![Snowflake](https://img.shields.io/badge/Snowflake-Cortex-29B5E8?logo=snowflake)](https://www.snowflake.com/)\n[![Claude](https://img.shields.io/badge/Claude-AI-FF6B35?logo=anthropic)](https://www.anthropic.com/)\n[![License: BSL 1.1](https://img.shields.io/badge/License-BSL%201.1-blue.svg)](https://mariadb.com/bsl11/)\n\nA comprehensive demonstration of **AI-powered analytics with persistent memory**, built on Snowflake's data platform. This application showcases the seamless integration of Snowflake's Cortex AI capabilities with Memory Box for context-aware data analysis.\n\n![Memory Box Logo](./assets/logo.svg)\n\n## 🏢 Memory Box: Enterprise-Ready AI Memory\n\n**Memory Box** is a proven AI memory solution that has been successfully deployed in production environments to enhance the value and effectiveness of AI interactions. Originally developed as a standalone platform, Memory Box has now been **architected specifically for enterprise use on Snowflake**, bringing enterprise-grade security, scalability, and performance to AI-powered analytics.\n\n🎧 **[Listen: Memory Box on Snowflake Podcast](https://static.amotivv.io/cdn/memory-box-on-snowflake.mp3)** - Deep dive into the philosophy and technical architecture\n\n### Why Memory Box on Snowflake?\n\n- **🔒 Enterprise Security**: Memory data never leaves your Snowflake environment, ensuring maximum data security and compliance\n- **📈 Proven Value**: Field-tested solution that demonstrably improves AI interaction quality and business outcomes  \n- **🏗️ Native Architecture**: Purpose-built for Snowflake using Cortex AI functions for optimal performance\n- **💰 Cost Efficiency**: Eliminates external API costs and data transfer fees while leveraging existing Snowflake infrastructure\n- **⚡ Production Ready**: Enterprise-grade scalability and reliability with Snowflake's proven platform\n- **🔧 Operational Simplicity**: No additional infrastructure to manage - Memory Box runs entirely within your Snowflake environment\n\nThis demo showcases how Memory Box transforms traditional data analytics into **intelligent, context-aware conversations** that remember insights, build upon previous analyses, and provide increasingly valuable recommendations over time.\n\n## 🎯 What This Demo Shows\n\nThis project demonstrates how to build a **production-ready AI analytics application** that:\n\n- 🗄️ **Explores Data Naturally**: Browse Snowflake databases using natural language\n- 🤖 **Analyzes with AI**: Leverage Claude AI for intelligent data insights\n- 🧠 **Remembers Everything**: Store and retrieve analysis results using Memory Box natively on Snowflake\n- 💬 **Maintains Context**: Memory Box enables AI that remembers previous interactions and builds upon them\n- 🔧 **Integrates Seamlessly**: Native Snowflake Cortex integration with Memory Box and modern web technologies\n\n## ✨ Key Features\n\n### 🚀 Core Capabilities\n- **Database Explorer**: Interactive browsing of databases, schemas, and tables\n- **AI Chat Interface**: Natural language conversations with Claude AI\n- **Memory System**: Vector-based storage and retrieval of insights using Snowflake Cortex\n- **Cortex Analyst**: Direct integration with Snowflake's native AI capabilities\n- **Tool Integration**: Seamless tool calling within conversations\n\n### 🛠️ Technical Highlights\n- **Modern Stack**: Next.js 15, React 18, TypeScript, Tailwind CSS\n- **Professional UI**: Assistant-UI for chat interface with tool support\n- **Secure Authentication**: JWT-based Snowflake integration with RSA key pairs\n- **Native Vector Search**: Snowflake Cortex embedding functions for similarity search\n- **Production Ready**: Comprehensive error handling and responsive design\n\n## 🏗️ Architecture Overview\n\n```mermaid\ngraph TB\n    subgraph \"Frontend Layer\"\n        UI[Next.js App]\n        Chat[Assistant-UI Chat]\n        Tools[Tool Components]\n    end\n    \n    subgraph \"API Layer\"\n        API[Next.js API Routes]\n        Auth[JWT Authentication]\n        Data[Data Operations]\n        Memory[Memory Operations]\n    end\n    \n    subgraph \"Services Layer\"\n        SF[Snowflake Service]\n        Claude[Claude Runtime]\n        Vector[Vector Search]\n    end\n    \n    subgraph \"External Services\"\n        Snowflake[Snowflake Platform]\n        Anthropic[Claude API]\n        MemoryDB[Memory Box]\n    end\n    \n    UI --\u003e API\n    Chat --\u003e API\n    Tools --\u003e API\n    \n    API --\u003e SF\n    API --\u003e Claude\n    API --\u003e Vector\n    \n    SF --\u003e Snowflake\n    Claude --\u003e Anthropic\n    Vector --\u003e MemoryDB\n```\n\n## 🚀 Deployment Options\n\n### Snowpark Container Services (SPCS) Deployment ✅\n\nThis application is **fully deployed and running on Snowpark Container Services**. For production deployments, SPCS provides:\n\n- 🔒 **Complete Data Security**: All processing happens within your Snowflake environment\n- 🚀 **Native Performance**: Direct integration with Snowflake services\n- 📈 **Enterprise Scale**: Automatic scaling and high availability\n- 🛡️ **Built-in Security**: Snowflake's enterprise security features\n- 🔐 **Native Authentication**: Uses Snowflake OAuth tokens - no external auth required\n\n**Current SPCS Deployment:**\n- Backend Service: `memory-box-backend:v20` (RUNNING)\n- Frontend Service: `memory-box-frontend:v5` (RUNNING)\n- URL: https://your-url.snowflakecomputing.app\n\n### 🔐 Enterprise Authentication Models\n\nMemory Box supports **three authentication models** for different deployment scenarios:\n\n#### Model A: Customer Self-Deploy (Enterprise)\n- 🏢 **Target**: Large enterprises with existing Snowflake governance\n- 🔑 **Auth**: Snowflake OAuth with corporate SSO integration\n- ✅ **Status**: Fully implemented and demo-ready\n\n#### Model B: Managed Service (Mid-Market)\n- 🏢 **Target**: Organizations wanting simplified deployment\n- 🔑 **Auth**: Service account with user validation layer\n- ✅ **Status**: Fully implemented and demo-ready\n\n#### Model C: Native App (Marketplace)\n- 🏢 **Target**: All Snowflake customers via Marketplace\n- 🔑 **Auth**: Native app permissions model\n- 📋 **Status**: On roadmap\n\n\n### Local Development Quick Start\n\n#### Prerequisites\n\nBefore you begin, ensure you have:\n\n- **Snowflake Account** with Cortex AI and Claude Sonneet 3.5 enabled\n- **Node.js 18+** and npm/yarn\n- **RSA Key Pair** for Snowflake authentication\n\n### 1. Clone \u0026 Install\n\n```bash\ngit clone https://github.com/amotivv-inc/snowflake-memory-box.git\ncd snowflake-memory-box\nnpm install\n```\n\n### 2. Environment Setup\n\n```bash\n# Copy the environment template\ncp .env.example .env.local\n\n# Edit .env.local with your credentials\nnano .env.local\n```\n\nRequired environment variables:\n```env\nSNOWFLAKE_ACCOUNT=your-account-identifier\nSNOWFLAKE_USERNAME=your-username\nSNOWFLAKE_PRIVATE_KEY_PATH=/path/to/your/rsa_key.p8\nSNOWFLAKE_PUBLIC_KEY_FP=your-public-key-fingerprint\n```\n\n### 3. Snowflake Setup\n\nRun the setup script to create the necessary database and memory system:\n\n```sql\n-- Enable cross-region inference (if needed)\nALTER ACCOUNT SET CORTEX_ENABLED_CROSS_REGION = 'AWS_US';\n\n-- Create memory database\nCREATE DATABASE IF NOT EXISTS NATIVE_MEMORY_POC;\nUSE DATABASE NATIVE_MEMORY_POC;\nCREATE SCHEMA IF NOT EXISTS CORE;\n\n-- Create memories table with vector support\nCREATE OR REPLACE TABLE CORE.MEMORIES (\n    memory_id STRING PRIMARY KEY,\n    content STRING NOT NULL,\n    content_type STRING NOT NULL,\n    embedding VECTOR(FLOAT, 768) NOT NULL,\n    owner_user STRING NOT NULL DEFAULT CURRENT_USER(),\n    access_level STRING NOT NULL DEFAULT 'PRIVATE',\n    created_at TIMESTAMP_NTZ DEFAULT CURRENT_TIMESTAMP(),\n    -- ... additional fields\n);\n```\n\n### 4. Local Authentication Setup\n\nGenerate RSA key pair for Snowflake authentication:\n\n```bash\n# Create keys directory\nmkdir -p ~/.snowflake/keys\n\n# Generate private key\nopenssl genrsa -out ~/.snowflake/keys/rsa_key.pem 2048\n\n# Convert to PKCS#8 format\nopenssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt \\\n  -in ~/.snowflake/keys/rsa_key.pem -out ~/.snowflake/keys/rsa_key.p8\n\n# Generate public key\nopenssl rsa -in ~/.snowflake/keys/rsa_key.pem -pubout \\\n  -out ~/.snowflake/keys/rsa_key.pub\n\n# Get fingerprint\nopenssl rsa -pubin -in ~/.snowflake/keys/rsa_key.pub -outform DER | \\\n  openssl dgst -sha256 -binary | openssl enc -base64\n```\n\nConfigure the public key in Snowflake:\n```sql\nALTER USER your_username SET RSA_PUBLIC_KEY='\u003cyour_public_key_content\u003e';\n```\n\n### 5. Run the Application\n\n```bash\n# Start development server\nnpm run dev\n\n# Open in browser\nopen http://localhost:3000\n```\n\n## 🎮 Usage Examples\n\n### Data Exploration\n```\n👤 User: \"Show me the available databases\"\n🤖 AI: [Uses selectDataSource tool to list databases]\n\n👤 User: \"What tables are in the NONPROFIT_POC database?\"\n🤖 AI: [Explores database structure and shows tables with details]\n```\n\n### AI-Powered Analysis\n```\n👤 User: \"Analyze donation patterns in the last quarter\"\n🤖 AI: [Uses Cortex Analyst to generate SQL, executes query, provides insights]\n\n👤 User: \"Store this analysis for future reference\"\n🤖 AI: [Uses storeMemory tool to save insights with vector embeddings]\n```\n\n### Memory-Enhanced Conversations\n```\n👤 User: \"What did we discover about donor behavior last time?\"\n🤖 AI: [Uses Memory Box to find relevant previous insights]\n```\n\n## 🔍 API Reference\n\n### Data Operations\n| Endpoint | Method | Description |\n|----------|--------|-------------|\n| `/api/data/databases` | GET | List available databases |\n| `/api/data/schemas` | GET | List schemas in a database |\n| `/api/data/tables` | GET | List tables in a schema |\n| `/api/data/preview` | GET | Preview table data |\n| `/api/data/query` | POST | Execute custom SQL queries |\n\n### Memory Operations\n| Endpoint | Method | Description |\n|----------|--------|-------------|\n| `/api/memory/store` | POST | Store insights with vector embeddings |\n| `/api/memory/search` | POST | Search memories by similarity |\n\n### AI Integration\n| Endpoint | Method | Description |\n|----------|--------|-------------|\n| `/api/chat` | POST | Claude AI conversation handling |\n| `/api/suggestions` | GET | Dynamic suggestion generation |\n\n## 🧪 Testing\n\n```bash\n# Test API endpoints\ncurl -X GET http://localhost:3000/api/data/databases\n\n# Test memory operations\ncurl -X POST http://localhost:3000/api/memory/search \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"query\": \"donation analysis\", \"limit\": 5}'\n```\n\n## 🚀 Deployment\n\n### Development\n```bash\nnpm run dev\n```\n\n### Production Build\n```bash\nnpm run build\nnpm start\n```\n\n\n## 🔧 Technology Stack\n\n| Category | Technology | Purpose |\n|----------|------------|---------|\n| **Frontend** | Next.js 15, React 18, TypeScript | Modern web application framework |\n| **Styling** | Tailwind CSS | Utility-first CSS framework |\n| **AI/Chat** | Assistant-UI, Claude (Anthropic) | Professional chat interface and AI |\n| **Database** | Snowflake | Data platform and memory storage |\n| **Vector Search** | Snowflake Cortex | Native embedding and similarity search |\n| **Authentication** | JWT with RSA keys | Secure Snowflake integration |\n\n## 🔒 Security Features\n\n- 🔐 **JWT Authentication**: Secure token-based authentication with Snowflake\n- 🔑 **RSA Key Pairs**: Industry-standard public/private key authentication\n- 🛡️ **Input Sanitization**: SQL injection prevention and input validation\n- 🔒 **Environment Variables**: Secure credential management\n- 🚫 **Error Handling**: Secure error messages without data leakage\n\n## 🤝 Contributing\n\nWe welcome contributions! Please see our contributing guidelines:\n\n1. **Fork** the repository\n2. **Create** a feature branch (`git checkout -b feature/amazing-feature`)\n3. **Commit** your changes (`git commit -m 'Add amazing feature'`)\n4. **Push** to the branch (`git push origin feature/amazing-feature`)\n5. **Open** a Pull Request\n\n### Development Setup\n```bash\n# Clone your fork\ngit clone https://github.com/yourusername/snowflake-memory-box.git\n\n# Install dependencies\nnpm install\n\n# Start development server\nnpm run dev\n```\n\n## 🆘 Troubleshooting\n\n### Common Issues\n\n**Authentication Errors**\n```\nError: JWT token validation failed\n```\n- Verify public key is set in Snowflake\n- Check private key path and permissions\n- Ensure public key fingerprint matches\n\n**Cross-Region Model Errors**\n```\nError: Unknown model 'claude-3-sonnet'\n```\n- Enable cross-region inference: `ALTER ACCOUNT SET CORTEX_ENABLED_CROSS_REGION = 'AWS_US';`\n\n**Memory Database Not Found**\n```\nError: Database 'NATIVE_MEMORY_POC' does not exist\n```\n- Run the complete Snowflake setup script\n\n\n## 📄 License\n\nThis project is licensed under the Business Source License 1.1 - see the [LICENSE](LICENSE) file for details.\n\n**Key Points:**\n- ✅ **Product use**: Production use allowed for entities with total finances under $2M USD annually\n- ✅ **Open source future**: Automatically becomes AGPL-3.0 after 3 years\n- ✅ **No restrictions for development**: Full access for development, testing, and evaluation\n- 💼 **Enterprise licensing**: Commercial licenses available for larger organizations\n\nFor more information about BSL, visit [mariadb.com/bsl11](https://mariadb.com/bsl11/).\n\n## 🏆 Achievements\n\nThis project successfully demonstrates:\n\n- ✅ **Seamless Integration**: Direct Snowflake REST API v2 integration with modern web stack\n- ✅ **AI-Powered Analytics**: Natural language data analysis with Claude AI\n- ✅ **Vector Memory System**: Persistent context using Snowflake's native vector capabilities\n- ✅ **Production Architecture**: Scalable, maintainable, and secure codebase\n- ✅ **Comprehensive Documentation**: Complete setup guides and learning resources\n\n## 🔮 Future Roadmap\n\n- 🏢 **Multi-tenancy**: Support for multiple users and organizations\n- 📊 **Advanced Visualizations**: Interactive charts and graphs\n- 🤝 **Real-time Collaboration**: Shared analysis sessions\n- 🏷️ **Enhanced Memory**: Tags, folders, and advanced organization\n- 📈 **Analytics Dashboard**: Usage metrics and performance monitoring\n\n## 🌟 Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=amotivv-inc/snowflake-memory-box\u0026type=Date)](https://star-history.com/#amotivv-inc/snowflake-memory-box\u0026Date)\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**Built with ❤️ using [Memory Box](https://memorybox.dev), Snowflake, Claude AI, Next.js, and [Assistant-UI](https://github.com/assistant-ui/assistant-ui)**\n\n[🌟 Star this repo](https://github.com/amotivv-inc/snowflake-memory-box) • [🐛 Report Bug](https://github.com/amotivv-inc/snowflake-memory-box/issues) • [💡 Request Feature](https://github.com/amotivv-inc/snowflake-memory-box/issues)\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famotivv-inc%2Fsnowflake-memory-box","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famotivv-inc%2Fsnowflake-memory-box","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famotivv-inc%2Fsnowflake-memory-box/lists"}