Skip to content

codeSTACKr/ai-sdk-mongodb-memory-persistence

Repository files navigation

AI Chat with MongoDB Memory Persistence

A Next.js chat application that uses MongoDB to store chat history, built with the Vercel AI SDK. This application provides persistent memory for AI conversations, allowing users to maintain chat history across sessions.

Features

  • Persistent chat history using MongoDB
  • Real-time AI responses with streaming
  • Modern UI with dark/light mode using shadcn/ui
  • Chat history navigation sidebar
  • Chat deletion functionality
  • Responsive design

Tech Stack

Prerequisites

  • Node.js 18.18 or later
  • MongoDB Atlas account (free tier works)
  • OpenAI API key

Environment Variables

Create a .env.local file in the root directory with the following variables:

MONGODB_URI=your_mongodb_uri
MONGODB_DB=your_database_name
OPENAI_API_KEY=your_openai_api_key

Getting Started

  1. Clone the repository
  2. Install dependencies:
    npm install
  3. Set up your environment variables
  4. Run the development server:
    npm run dev
  5. Open http://localhost:3000 in your browser

Development

The application uses the Next.js App Router and is structured as follows:

  • app/ - Next.js application routes and API endpoints
  • components/ - React components including chat interface
  • lib/ - Utility functions and database connection
  • public/ - Static assets

Learn More

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published