How can I add AI chat functionality to my application using an LLM API? #209460
🏷️ Discussion TypeQuestion 💬 Feature/Topic AreaOther BodyHi, I’m building an AI application and I need some guidance. I want to build an AI chat application with:
I would like to understand the best way to structure this project using GitHub and what technologies/services I should use. What I expected: What I need help with: Thank you. |
Replies: 1 comment
Building a Full-Stack AI Chat Application — Architecture and Technology RecommendationsWhat I am trying to buildI am building a full-stack AI chat application similar in concept to an AI assistant platform. The application should allow users to:
I am looking for advice on the correct technical architecture and recommended technologies before I start building the application. 1. AI Chat InterfaceI want to create a modern web-based chat interface. Users should be able to:
I am considering:
Is this a good frontend stack for an AI application? 2. AI / LLM ModelI don't want to run a large language model locally initially. I want to use an API-based LLM provider. Possible providers include:
My requirements are:
I also want the architecture to allow me to change the AI provider later. For example: Would this be a good architecture? Should I create an abstraction layer so that changing the LLM provider does not require rewriting the entire application? 3. User AuthenticationEvery user should have a separate account. I need:
I am considering:
Which would you recommend for an AI startup MVP? Security is very important because users will have private conversations and private documents. I want to guarantee that: is never possible. 4. DatabaseI need to store: A possible database structure is: I am considering:
I am leaning toward PostgreSQL because the application has many relationships between users, conversations, messages, documents and memories. Would PostgreSQL be the better choice? 5. AI MemoryOne of the most important features I want is AI memory. I don't want to send the entire conversation history to the LLM every time because:
I am thinking about separating memory into different types. Short-term memoryRecent conversation messages. Long-term memoryImportant information about the user. For example: Semantic memoryI am considering storing embeddings for important memories. For example: Then when the user asks a question, the system performs semantic search and retrieves relevant memories. Possible technologies:
Would PostgreSQL + pgvector be enough for the initial version? 6. PDF / Document UploadI want users to upload:
The user should then be able to ask questions about the uploaded document. For example: I don't want to send the entire document to the LLM for every question. I am considering a RAG architecture. 7. RAG ArchitectureMy proposed RAG pipeline is: Then when the user asks a question: Is this the correct architecture? 8. Document CitationsI also want the AI to provide citations. For example: Therefore, I think every document chunk should contain metadata such as: Is this enough to implement reliable page-level citations? 9. File StorageI need secure storage for uploaded documents. Possible options:
Requirements:
What would you recommend for an MVP? 10. Backend ArchitectureI am unsure whether I should keep everything inside Next.js or create a separate backend. Option AOption BWhich architecture would you recommend? I eventually want to add:
I therefore want to avoid an architecture that will need to be completely rebuilt later. 11. Python vs TypeScriptI am also trying to decide whether I should use: for everything, or: I understand that Python has a very strong AI/ML ecosystem. Would using Python for the AI backend be beneficial if I eventually want to add:
Or would this be unnecessary complexity for the first version? 12. Background ProcessingLarge PDFs can take time to process. I don't want the user's HTTP request to remain open while the document is being processed. I am considering: Possible technologies:
What would you recommend for an MVP? 13. SecuritySecurity is extremely important because users will upload private information. I want to protect against:
I believe the architecture should be: and NOT: because the API key must never be exposed to the browser. Is this correct? What other security practices should I implement from the beginning? 14. Environment VariablesI plan to store secrets such as: in environment variables. For local development: For production: I will not commit secrets to GitHub. Is this the correct approach? 15. API ArchitectureI am thinking about having APIs similar to: For example: would receive: {
"conversationId": "123",
"message": "Explain this document"
}Then the backend would: Is this a reasonable API architecture? 16. Recommended Database StructureI am thinking about something like: Would this be a good starting schema? What important tables or fields am I missing? 17. Multi-Tenant Data IsolationBecause multiple users will use the application, I need strong data isolation. For example: User A should never be able to query: I am considering PostgreSQL Row Level Security if I use Supabase. Would RLS be the correct approach? 18. Cost ControlI also want to keep the initial cost low. The application may have:
I want to prevent one user from consuming unlimited AI resources. I am considering: Should I implement usage tracking from the beginning? 19. DeploymentFor the first production version I am considering: Would this be a reasonable production MVP architecture? 20. Possible Final ArchitectureThe architecture I currently have in mind is: For document processing: For a document question: 21. Project StructureI am considering the following project structure: Is this structure reasonable? 22. Development OrderI am thinking about developing the application in this order: Phase 1 — Basic ApplicationPhase 2 — ConversationsPhase 3 — DocumentsPhase 4 — MemoryPhase 5 — ProductionPhase 6 — Advanced AIDoes this development order make sense? 23. My Main QuestionsI would really appreciate feedback from people who have built production AI applications. Specifically:
24. What I Am Looking ForI am not only looking for a list of technologies. I want to understand:
I am relatively new to building a complete production AI application, so detailed architectural explanations would be very helpful. If you have built a similar AI application, I would especially appreciate advice about mistakes you made early that I should avoid. Thank you! |
Building a Full-Stack AI Chat Application — Architecture and Technology Recommendations
What I am trying to build
I am building a full-stack AI chat application similar in concept to an AI assistant platform.
The application should allow users to:
I am looking for advice on the correct technical architecture and recommended technologies before I start building the application.
1. …