https://github.com/codestackr/ai-sdk-mongodb-memory-persistence
https://github.com/codestackr/ai-sdk-mongodb-memory-persistence
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/codestackr/ai-sdk-mongodb-memory-persistence
- Owner: codeSTACKr
- Created: 2025-05-16T14:59:29.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-05-16T14:59:31.000Z (11 months ago)
- Last Synced: 2025-06-18T03:11:45.493Z (9 months ago)
- Language: TypeScript
- Size: 87.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
- [Next.js](https://nextjs.org) - React framework
- [MongoDB](https://www.mongodb.com/cloud/atlas/register/?utm_campaign=devrel&utm_source=third-party-content&utm_medium=cta&utm_content=building-chat-application-mongodb-memory-provider-vercel-ai-sdk&utm_term=jesse.hall) - Database for chat persistence
- [Vercel AI SDK](https://sdk.vercel.ai/docs) - AI integration
- [shadcn/ui](https://ui.shadcn.com) - UI components
- [Tailwind CSS](https://tailwindcss.com) - Styling
- [TypeScript](https://typescriptlang.org) - Type safety
## 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:
```bash
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:
```bash
npm install
```
3. Set up your environment variables
4. Run the development server:
```bash
npm run dev
```
5. Open [http://localhost:3000](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
- [Next.js Documentation](https://nextjs.org/docs)
- [MongoDB Documentation](https://mongodb.com/docs/?utm_campaign=devrel&utm_source=third-party-content&utm_medium=cta&utm_content=building-chat-application-mongodb-memory-provider-vercel-ai-sdk&utm_term=jesse.hall)
- [Vercel AI SDK Documentation](https://sdk.vercel.ai/docs)