Skip to content

Conversation

sagnik-create
Copy link
Contributor

πŸš€ Pull Request: Implement Persistent Chat Storage with SQLAlchemy

πŸ”— Related Issue

Closes #41 β€” Volatile Local Storage for Chat Data


πŸ“‹ Summary

This PR replaces the existing cache-based chat data storage mechanism with a persistent solution using SQLAlchemy and SQLite. The goal is to retain user chat history across sessions and enhance personalization.


🧠 What’s Implemented

  • πŸ“¦ Integrated SQLAlchemy ORM for structured database interaction
  • πŸ› οΈ Created a SQLite-based database schema for managing user sessions and chat messages
  • 🧾 Implemented logic to:
    • Automatically create a new user entry upon first visit
    • Store and retrieve chat messages for each user
    • Persist chat context for a personalized experience
  • πŸ”„ Hooked up the backend to interact with the chatbot engine seamlessly
  • πŸ§ͺ Included basic test coverage for DB connection and data operations

πŸ“Έ Demo (Optional)

image

Table creation code in db.py

image

Testing of the Database through DB Browser

image

Messages are stored in separate Database and new database is created for each user that can be retrieved using proper module functions


βœ… Checklist

  • Database connection established via SQLAlchemy
  • User chat sessions persist across page reloads
  • Schema scales well for multiple users
  • No breaking changes introduced
  • Tested thoroughly in local development environment

πŸ’¬ Additional Notes

  • Currently using SQLite for local persistence. Can be upgraded to PostgreSQL or another RDBMS for production.
  • Currently the chat just gets stored in the db database, Can upgrade the frontend modules to show chat history in the sidebar as well

πŸ™‹β€β™‚οΈ Request

Please review the changes and provide feedback. I’d be happy to iterate further based on suggestions!

@eccentriccoder01
Copy link
Owner

Great work @sagnik-create, level 3 worthy, keep it up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding database capabilities to the chat-interface.py to make it more personalized
2 participants