A comprehensive memory extraction and query system that analyzes chat conversations to extract and store meaningful memories using AI, with a modern web interface for searching and managing extracted memories.
- API: https://memory-api-faff.onrender.com
- Frontend: https://memory-frontend-faff.vercel.app
- Backend Repository: https://github.com/LogicalGuy77/memory-api-faff
The Memory Extraction System is designed to solve the problem of automatically capturing and organizing meaningful information from chat conversations. Instead of manually tracking user preferences, personal information, and important details scattered across multiple conversations, this system uses AI to intelligently extract, categorize, and store memories that can be easily searched and retrieved.
- Information Overload: Automatically processes large volumes of chat data
- Memory Organization: Categorizes memories into meaningful types
- Intelligent Search: Provides semantic and text-based search capabilities
- Data Persistence: Reliably stores and manages extracted memories
- User Experience: Offers an intuitive interface for memory management
The system follows a modern three-tier architecture:
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Frontend β β Backend API β β Database β
β (React) βββββΊβ (FastAPI) βββββΊβ (PostgreSQL) β
β β β β β β
β β’ Memory Query β β β’ Memory β β β’ Chat Messages β
β β’ Chat Upload β β Extraction β β β’ Memories β
β β’ Results View β β β’ AI Processing β β β’ Associations β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- Chat Upload: Users upload chat data via the frontend
- AI Processing: Gemini AI analyzes conversations and extracts memories
- Memory Storage: Extracted memories are categorized and stored in PostgreSQL
- Query & Search: Users can search and filter memories through the frontend
- Results Display: Relevant memories are highlighted and presented
- Memory Extraction: AI-powered extraction using Google Gemini
- RESTful API: Complete CRUD operations for chats and memories
- Advanced Search: Semantic search with filtering capabilities
- Data Validation: Robust input validation and error handling
- PostgreSQL Integration: Scalable database with proper indexing
- CORS Support: Cross-origin requests for frontend integration
- Chat Upload: File upload with real-time processing feedback
- Memory Query: Advanced search interface with multiple filters
- Result Highlighting: Search term highlighting in results
- Type Filtering: Filter memories by category
- Modern UI: Responsive design with Tailwind CSS
- Error Handling: Comprehensive error states and user feedback
- Food Preferences: Dietary restrictions, favorite cuisines, allergies
- Travel Preferences: Destinations, transportation, accommodation
- Personal Information: Names, relationships, important dates
- Delivery Instructions: Addresses, special instructions, preferences
- Hobbies & Interests: Activities, sports, entertainment preferences
- Routine & Timing: Schedules, availability, time preferences
- FastAPI: Modern, fast web framework for building APIs
- Google Gemini AI: Advanced language model for memory extraction
- PostgreSQL: Robust relational database for production
- Psycopg2: PostgreSQL adapter for Python
- Pydantic: Data validation and settings management
- Uvicorn: ASGI server for FastAPI
- React: Modern JavaScript library for building user interfaces
- Tailwind CSS: Utility-first CSS framework
- Axios: HTTP client for API communication
- Vite: Fast build tool and development server
- Render: Backend deployment with PostgreSQL
- Vercel: Frontend deployment with CDN
- Environment Variables: Secure configuration management
faff/
βββ memory-api/ # Backend API
β βββ main.py # FastAPI application
β βββ database.py # PostgreSQL connection
β βββ requirements.txt # Python dependencies
β βββ .env # Environment variables
βββ frontend-memory/ # React frontend
β βββ src/
β β βββ components/ # React components
β β β βββ ChatUpload.jsx # Chat upload interface
β β β βββ MemoryQuery.jsx# Memory search interface
β β β βββ ui/ # Reusable UI components
β β βββ services/ # API communication
β β βββ App.jsx # Main application
β βββ package.json # Node.js dependencies
β βββ tailwind.config.js # Tailwind configuration
βββ README.md # This file
- Python 3.8+
- Node.js 16+
- PostgreSQL (for local development)
-
Clone the repository
git clone <repository-url> cd faff/memory-api
-
Create virtual environment
python -m venv memory_env source memory_env/bin/activate # On Windows: memory_env\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Environment configuration
# Create .env file GEMINI_API_KEY=your_gemini_api_key DATABASE_URL=postgresql://username:password@localhost:5432/memory_db
-
Run the server
uvicorn main:app --reload
-
Navigate to frontend directory
cd ../frontend-memory
-
Install dependencies
npm install
-
Start development server
npm run dev
POST /upload-chat
- Upload and process chat dataGET /chats
- List all chatsGET /chats/{chat_id}
- Get specific chat details
GET /memories
- List all memories with optional filteringGET /memories/search
- Advanced memory searchGET /memories/types
- Get available memory typesDELETE /memories/{memory_id}
- Delete specific memory
GET /health
- API health status
Upload Chat:
POST /upload-chat
{
"chat_data": [
{
"message_id": "msg_1",
"timestamp": "2024-01-01T10:00:00",
"sender": "user",
"content": "I love Italian food, especially pasta",
"chat_id": "chat_1"
}
]
}
Search Memories:
GET /memories/search?query=food&types=food_preference&chat_id=chat_1
{
"memories": [
{
"memory_id": "mem_1",
"content": "User loves Italian food, especially pasta",
"memory_type": "food_preference",
"confidence": 0.95,
"created_at": "2024-01-01T10:00:00"
}
]
}
The system categorizes extracted information into six primary types:
-
Food Preferences (
food_preference
)- Favorite cuisines, dishes, restaurants
- Dietary restrictions and allergies
- Cooking preferences and habits
-
Travel Preferences (
travel_preference
)- Preferred destinations and activities
- Transportation preferences
- Accommodation requirements
-
Personal Information (
personal_info
)- Names, relationships, family details
- Important dates and events
- Contact information
-
Delivery Instructions (
delivery_instruction
)- Addresses and locations
- Special delivery requirements
- Access instructions
-
Hobbies & Interests (
hobby_interest
)- Sports and activities
- Entertainment preferences
- Skills and talents
-
Routine & Timing (
routine_timing
)- Daily schedules and habits
- Availability patterns
- Time preferences
Decision: Migrated from SQLite to PostgreSQL for production deployment.
Rationale:
- Scalability: PostgreSQL handles concurrent connections better
- Production Ready: Industry standard for web applications
- Advanced Features: Better text search, indexing, and query optimization
- Render Compatibility: Native PostgreSQL support on hosting platform
Trade-offs:
- β Better performance and reliability
- β Advanced search capabilities (ILIKE, full-text search)
- β Production-grade features
- β Increased complexity for local development
- β Additional hosting costs
Decision: Using Google Gemini for memory extraction.
Rationale:
- Advanced Understanding: Excellent context comprehension
- Structured Output: Reliable JSON response format
- Cost Effective: Competitive pricing for API usage
- Integration: Good Python SDK support
Trade-offs:
- β High-quality memory extraction
- β Reliable structured responses
- β Good performance
- β External dependency and API costs
- β Rate limiting considerations
- β Requires internet connectivity
Decision: React with functional components and hooks.
Rationale:
- Modern Development: Current best practices
- Component Reusability: Modular UI components
- State Management: Built-in hooks for state handling
- Ecosystem: Rich library ecosystem
Trade-offs:
- β Fast development and good DX
- β Reusable components
- β Large community support
- β Bundle size considerations
- β Learning curve for new developers
Decision: Utility-first CSS framework.
Rationale:
- Rapid Prototyping: Quick UI development
- Consistency: Predefined design tokens
- Performance: Optimized production builds
- Flexibility: Easy customization
Trade-offs:
- β Fast development
- β Consistent design
- β Small production bundle
- β Learning curve
- β HTML verbosity
Decision: Separate deployments for frontend and backend.
Rationale:
- Scalability: Independent scaling of services
- Technology Freedom: Use best tools for each service
- Deployment Flexibility: Different update schedules
- Reliability: Isolated failure domains
Trade-offs:
- β Better scalability and flexibility
- β Independent deployments
- β Technology diversity
- β Increased operational complexity
- β Network latency between services
- β CORS configuration requirements
Decision: Process entire conversations rather than individual messages.
Rationale:
- Context Preservation: Better understanding of conversation flow
- Relationship Detection: Connections between related information
- Efficiency: Fewer API calls to AI service
- Quality: More accurate memory extraction
Trade-offs:
- β Higher quality extraction
- β Better context understanding
- β More efficient API usage
- β Longer processing time for large chats
- β Memory usage for large conversations
- β All-or-nothing processing
-
Database Setup
- PostgreSQL database automatically provisioned
- Environment variables configured via Render dashboard
-
Service Configuration
# render.yaml services: - type: web name: memory-api env: python buildCommand: pip install -r requirements.txt startCommand: uvicorn main:app --host 0.0.0.0 --port $PORT
-
Environment Variables
GEMINI_API_KEY=<your-api-key> DATABASE_URL=<auto-generated-by-render>
-
Build Configuration
{ "builds": [ { "src": "package.json", "use": "@vercel/static-build" } ] }
-
Environment Variables
VITE_API_BASE_URL=https://memory-api-faff.onrender.com
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- Follow existing code style and conventions
- Add tests for new features
- Update documentation for API changes
- Ensure all tests pass before submitting PR
This project is licensed under the MIT License - see the LICENSE file for details.
- Google Gemini AI for advanced language processing
- FastAPI team for the excellent web framework
- React community for the robust frontend ecosystem
- Render and Vercel for reliable deployment platforms
Project Status: β Production Ready
For questions, issues, or contributions, please reach out or create an issue in the repository.