How shahzaibkaramat67-coder/chat_app works
This is a Next.js AI chat application with account management, chat creation, streamed assistant replies, and persisted conversation history. The main workflow runs from the home screen through message input to the chat API, which checks authentication, records the user message, invokes the AI helper, and returns a reply; the client then saves the assistant message. Separate routes support signup, login, token refresh, and password recovery. The README is only the Next.js starter README, so it does not document product capabilities; edges below are limited to relationships visible in excerpts or SOURCE INDEX references.
Main entry points: page.tsx Home screen · Chat/route.js Chat API · db.js DB connector · saveAi/route.js Save assistant reply
Components 26
Chat interface
- Home screen
app/page.tsx - Sidebar
components/sidbar.jsx - History view
components/history.jsx - New chat
components/newChat.jsx - Search
components/search.jsx - Projects
components/project.jsx - Share popup
components/popup.jsx - Profile
components/profile.jsx - More menu
components/threedot.jsx - Message display
app/chat/message/page.jsx - Message input
app/chat/UserInput/page.jsx
Chat runtime
- Chat API
app/Api/Chat/route.js - AI helper
app/lib/Ai.js - Save assistant reply
app/Api/saveAi/route.js - History API
app/Api/history/route.js
Identity and accounts
- Token verification
app/lib/verify.js - Login API
app/login/loginRoute/route.js - Signup API
app/Signup/signupRoute/route.js - Token refresh API
app/Api/refresh-token/route.js - Token generator
app/lib/auth.js - Mail helper
app/lib/mail.js
Persistence
- DB connector
app/lib/db.js - User records
model/User.js - Chat records
model/Chat.js - Message records
model/massage.js
Other components
- User
Connections 32
- User → Home screen: uses
- Home screen → Sidebar: renders
app/page.tsx - Home screen → New chat: renders
app/page.tsx - Home screen → Search: renders
app/page.tsx - Home screen → Projects: renders
app/page.tsx - Home screen → Share popup: renders
app/page.tsx - Home screen → Profile: renders
app/page.tsx - Home screen → More menu: renders
app/page.tsx - Home screen → Message display: renders
app/page.tsx - Home screen → Message input: renders
app/page.tsx - Sidebar → History view: renders
components/sidbar.jsx - Home screen → Chat API: loads messages
app/page.tsx - Message input → Chat API: sends prompt
app/chat/UserInput/page.jsx - Chat API → DB connector: connects
app/Api/Chat/route.js - Chat API → Token verification: verifies user
app/Api/Chat/route.js - Chat API → Chat records: reads or creates chat
app/Api/Chat/route.js - Chat API → Message records: stores user message
app/Api/Chat/route.js - Chat API → AI helper: requests reply
app/Api/Chat/route.js - Message input → Save assistant reply: submits reply
app/chat/UserInput/page.jsx - Save assistant reply → DB connector: connects
app/Api/saveAi/route.js - Save assistant reply → Chat records: checks chat
app/Api/saveAi/route.js - Save assistant reply → Message records: stores reply
app/Api/saveAi/route.js - History API → Chat records: queries history
app/Api/history/route.js - Login API → DB connector: connects
app/login/loginRoute/route.js - Login API → User records: checks and updates user
app/login/loginRoute/route.js - Login API → Token generator: generates tokens
app/login/loginRoute/route.js - Signup API → DB connector: connects
app/Signup/signupRoute/route.js - Signup API → User records: creates user
app/Signup/signupRoute/route.js - Signup API → Mail helper: sends signup mail
app/Signup/signupRoute/route.js - Token refresh API → User records: loads user
app/Api/refresh-token/route.js - Token refresh API → Token generator: generates token
app/Api/refresh-token/route.js - DB connector → User records: persists