A modern, AI-powered chat history storage and management system with semantic search capabilities. Store, organize, and intelligently retrieve conversational data across multiple sessions and users.
Memos is a full-stack application designed to revolutionize how we store and retrieve conversational data. By combining traditional keyword search with AI-powered semantic similarity, it provides an intelligent system for managing chat histories, conversations, and memory-based interactions.
- π Hybrid Search: Combines keyword matching (30%) with semantic similarity (70%) for intelligent retrieval
- π€ AI-Powered: Leverages Google Gemini AI for generating high-quality text embeddings
- π₯ Multi-User Support: Handle multiple users and conversation sessions
- π Vector Database: Supabase PostgreSQL with pgvector for efficient semantic search
- π MCP Integration: Model Context Protocol server for AI tool integration
- β‘ Real-time: Modern React frontend with real-time updates
- π³ Docker Ready: Full containerized development environment with hot reload
- π Hot Reload: All services support hot reload for rapid development
- Runtime: Node.js 18+
- Framework: Express.js with TypeScript
- Database: Supabase PostgreSQL with pgvector extension
- AI Service: Google Gemini AI (gemini-embedding-001)
- Vector Dimensions: 1536-dimensional embeddings
- Framework: Next.js 15+ with React 19
- UI Library: Radix UI + Tailwind CSS
- State Management: Redux Toolkit
- Styling: Tailwind CSS with custom animations
- Icons: Lucide React + React Icons
- SDK: @modelcontextprotocol/sdk
- Runtime: TypeScript with tsx
- Validation: Zod for schema validation
- Package Manager: pnpm
- Build Tool: TypeScript compiler
- Development: Hot-reload with ts-node-dev
- Containerization: Docker & Docker Compose
- Node.js 18 or higher
- pnpm (recommended) or npm
- Docker and Docker Compose
- Google Gemini AI API key
-
Clone the repository
git clone <repository-url> cd memos
-
Configure environment variables
# Create backend environment file echo "GEMINI_API_KEY=your_gemini_api_key_here" > apps/backend/.env
-
Start all services with Docker
# Start all services (database, backend, frontend, MCP server) ./start-dev.sh # Or manually docker-compose up -d
-
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:3001
- MCP Server: http://localhost:3002
- Database: localhost:5432
-
Verify services are running
./verify-ports.sh
-
Stop services
./stop-dev.sh # Or manually docker-compose down
-
Clone the repository
git clone <repository-url> cd memos
-
Install dependencies
pnpm install
-
Set up the database
# Start PostgreSQL with pgvector docker-compose up -d postgres # Or use the setup script ./setup-db.sh
-
Configure environment variables
# Create backend environment file cp apps/backend/.env.example apps/backend/.env # Edit the file with your configuration nano apps/backend/.env
Required environment variables:
PORT=3000 DB_HOST=localhost DB_PORT=5432 DB_USER=memos_user DB_PASSWORD=memos_password DB_NAME=memos GEMINI_API_KEY=your_gemini_api_key_here
-
Start the development servers
# Terminal 1: Start backend cd apps/backend pnpm dev # Terminal 2: Start frontend cd apps/frontend pnpm dev # Terminal 3: Start MCP server (optional) cd apps/mcp pnpm dev
-
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:3001/api
- Health Check: http://localhost:3001/health
memos/
βββ apps/
β βββ backend/ # Node.js REST API
β β βββ src/
β β β βββ controllers/ # Business logic
β β β βββ routes/ # API endpoints
β β β βββ services/ # External services (AI)
β β β βββ config/ # Database & AI configuration
β β β βββ types/ # TypeScript definitions
β β β βββ utils/ # Utility functions
β β β βββ app.ts # Express app setup
β β β βββ server.ts # Entry point
β β βββ database.sql # Database schema
β β βββ package.json
β β
β βββ frontend/ # Next.js React application
β β βββ app/ # Next.js 15 app directory
β β β βββ memories/ # Memory management pages
β β β βββ settings/ # Settings page
β β β βββ layout.tsx # Root layout
β β βββ components/ # Reusable UI components
β β β βββ ui/ # Radix UI components
β β β βββ shared/ # Shared components
β β β βββ dashboard/ # Dashboard components
β β βββ hooks/ # Custom React hooks
β β βββ store/ # Redux store
β β βββ lib/ # Utility libraries
β β βββ styles/ # Global styles
β β
β βββ mcp/ # Model Context Protocol server
β βββ src/
β β βββ index.ts # MCP server entry point
β βββ package.json
β
βββ packages/
β βββ shared/ # Shared utilities & types
β
βββ docker-compose.yml # All services setup
βββ setup-db.sh # Database setup script
βββ start-dev.sh # Start development environment
βββ stop-dev.sh # Stop development environment
βββ verify-ports.sh # Port verification script
βββ pnpm-workspace.yaml # Workspace configuration
βββ README.md # This file
# Start all services with hot reload
./start-dev.sh
# View logs
docker-compose logs -f
# Stop services
./stop-dev.sh
# Rebuild specific service
docker-compose build backend
docker-compose up -d backend# Start all services in development mode
pnpm dev
# Or start individual services
cd apps/backend && pnpm dev # Backend on port 3000
cd apps/frontend && pnpm dev # Frontend on port 3000
cd apps/mcp && pnpm dev # MCP server# Build all applications
pnpm build
# Or build individual apps
cd apps/backend && pnpm build
cd apps/frontend && pnpm build
cd apps/mcp && pnpm build# Health check
curl http://localhost:3001/health
# Create a new memo
curl -X POST http://localhost:3001/memo \
-H "Content-Type: application/json" \
-d '{
"sessionId": "session_123",
"userId": "user_456",
"content": "This is a test memo about machine learning",
"authorRole": "user",
"tags": ["test", "ml", "ai"]
}'
# Search memos
curl -X POST http://localhost:3001/search \
-H "Content-Type: application/json" \
-d '{
"query": "machine learning",
"limit": 10,
"sessionId": "session_123"
}'
# Get all memos
curl http://localhost:3001/memos
# Get specific memo
curl http://localhost:3001/memo/1# Start database
docker-compose up -d postgres
# Stop database
docker-compose down
# View database logs
docker-compose logs -f postgres
# Access database directly
docker-compose exec postgres psql -U memos_user -d memoshttp://localhost:3001
Currently, the API does not require authentication. This may change in future versions.
GET /healthResponse:
{
"status": "ok",
"timestamp": "2024-01-01T00:00:00.000Z"
}POST /memoRequest Body:
{
"sessionId": "string",
"userId": "string",
"content": "string",
"authorRole": "user" | "agent" | "system",
"summary": "string (optional)",
"importance": 1.0,
"tags": ["string"]
}Response:
{
"id": 1,
"sessionId": "session_123",
"userId": "user_456",
"content": "This is a test memo",
"authorRole": "user",
"importance": 1.0,
"accessCount": 0,
"tags": ["test"],
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
}GET /memos?sessionId=session_123&userId=user_456&limit=10&offset=0Query Parameters:
sessionId(optional): Filter by sessionuserId(optional): Filter by userlimit(optional): Number of results (default: 50)offset(optional): Pagination offset (default: 0)
GET /memo/:idResponse: Same as Create Memo response
PATCH /memo/:idRequest Body: Same as Create Memo (all fields optional)
DELETE /memo/:idResponse:
{
"message": "Memo deleted successfully"
}POST /searchRequest Body:
{
"query": "string",
"limit": 10,
"sessionId": "string (optional)",
"userId": "string (optional)"
}Response:
{
"results": [
{
"id": 1,
"content": "...",
"similarity": 0.95,
"relevanceScore": 0.87
}
],
"total": 1,
"processingTime": "0.123s"
}We welcome contributions to the Memos project! Please follow these guidelines:
-
Code Style
- Use TypeScript with strict type checking
- Follow ESLint and Prettier configurations
- Write descriptive commit messages using conventional commits
- Maintain consistent code formatting
-
Before Contributing
- Check existing issues and pull requests
- Fork the repository and create a feature branch
- Ensure all tests pass and linting is clean
- Update documentation for any API changes
-
Pull Request Process
- Create descriptive pull request titles
- Include detailed description of changes
- Reference related issues
- Ensure CI/CD pipelines pass
- Request review from maintainers
# Fork and clone the repository
git clone https://github.com/yourusername/memos.git
cd memos
# Install dependencies
pnpm install
# Create a new feature branch
git checkout -b feature/your-feature-name
# Make your changes and commit
git add .
git commit -m "feat: add new feature"
# Push to your fork
git push origin feature/your-feature-name- Testing: Write unit tests for new features
- Documentation: Update README and inline documentation
- Error Handling: Implement proper error handling and logging
- Performance: Consider performance implications of changes
- Security: Follow security best practices
When reporting bugs or requesting features:
- Check existing issues first
- Use the appropriate issue template
- Provide detailed reproduction steps
- Include system information and logs
- Tag issues appropriately
- Follow the established layered architecture
- Keep components focused and single-purpose
- Maintain clear separation between frontend and backend
- Use TypeScript interfaces for data contracts
- Follow REST API conventions
This project is licensed under the ISC License. See the LICENSE file for details.
- Frontend: http://localhost:3000
- Backend API: http://localhost:3001
- MCP Server: http://localhost:3002
- Database: localhost:5432
Run the verification script to check all services:
./verify-ports.sh- Google Gemini AI for embedding generation
- PostgreSQL and pgvector for vector database capabilities
- The React and Next.js communities for excellent tooling
- All contributors and maintainers
For more detailed information, see the PROJECT_OVERVIEW.md file.
Happy coding! π