do you have an example chat-bot system with message history, conversations, and internal documents? in every example what I saw is just 2 lines of code that everybody copy-pasted from each other. I want to understand how a smart people design a database for persisting conversations, users, how they combine a chat history to ask a question on top of a document.