How afffroz1/customer-and-employee-support-ai works
This repository is the backend for a customer/employee support system with a knowledge-grounded AI assistant. Users authenticate and interact with ticketing, attachments, and CSAI through REST APIs; the AI chat path maintains conversation context, retrieves and ranks approved knowledge, builds a prompt, and returns a generated answer. The graph includes the documented account, ticket, and attachment capabilities as well as the sampled CSAI internals. Some CSAI persistence and AI-provider details are documented but their implementations were not sampled, so those links are marked unverified.
Main entry points: index.js API route registry · support.service.js Conversation orchestration · auth.middleware.js JWT authentication · auth.routes.js Authentication routes
Components 33
API and Access
- Express API
src/app.js - API route registry
src/routes/index.js
Identity
- Authentication routes
src/routes/auth.routes.js - Account management
src/controllers/auth.controller.js - JWT authentication
src/middlewares/auth.middleware.js - User records
src/models/user.model.js
Support Operations
- Ticket routes
src/routes/ticket.routes.js - Ticket handling
src/controllers/ticket.controller.js - Ticket records
src/models/ticket.model.js - Ticket message routes
src/routes/ticketMessage.routes.js - Ticket messages
src/controllers/ticketMessage.controller.js - Activity routes
src/routes/activity.routes.js - Activity logging
src/controllers/activity.controller.js - Attachment routes
src/routes/binFile.routes.js - Attachment handling
src/controllers/binFile.controller.js - Attachment records
src/models/BinFile.model.js
AI Support
- AI support routes
src/csai/Routes/support.routes.js - Chat controller
src/csai/Controller/support.controller.js - Conversation orchestration
src/csai/Services/support.service.js - Conversation storage
src/csai/Repository/Chat.repository.js - Chat message storage
src/csai/Repository/Message.repository.js - Conversation memory
src/csai/Services/memory.service.js - Prompt construction
src/csai/Services/prompt.service.js - Response validation
src/csai/Services/responseValidator.js - Gemini integration
src/csai/Services/ai.service.js
Knowledge Retrieval
- Knowledge routes
src/csai/Routes/knowledge.routes.js - Knowledge management
src/csai/Controller/knowledge.controller.js - Search and ranking
src/csai/Services/knowledge.service.js - Knowledge repository
src/csai/Repository/knowledge.repository.js - Approved knowledge
src/csai/Model/Knowledge.model.js
Other components
- Client or employee
- Google Gemini
- MongoDB
Connections 39
- Client or employee → Express API: sends requests
src/app.js - Express API → API route registry: mounts routes
src/app.js - API route registry → Authentication routes: registers
src/routes/index.js - API route registry → Ticket routes: registers
src/routes/index.js - API route registry → Ticket message routes: registers
src/routes/index.js - API route registry → Activity routes: registers
src/routes/index.js - API route registry → Attachment routes: registers
src/routes/index.js - API route registry → AI support routes: registers
src/routes/index.js - API route registry → Knowledge routes: registers
- Authentication routes → Account management: routes requests
src/routes/auth.routes.js - Authentication routes → JWT authentication: protects routes
src/routes/auth.routes.js - Account management → User records: reads and updates
src/controllers/auth.controller.js - JWT authentication → User records: loads user
src/middlewares/auth.middleware.js - Ticket routes → JWT authentication: protects routes
src/routes/ticket.routes.js - Ticket routes → Ticket handling: routes requests
src/routes/ticket.routes.js - Ticket handling → Ticket records: reads and updates
src/controllers/ticket.controller.js - Ticket message routes → Ticket messages: routes requests
src/routes/ticketMessage.routes.js - Ticket messages → MongoDB: persists messages
- Activity routes → Activity logging: routes requests
src/routes/activity.routes.js - Activity logging → MongoDB: persists activity
- Attachment routes → Attachment handling: routes requests
src/routes/binFile.routes.js - Attachment handling → Attachment records: reads and writes
src/controllers/binFile.controller.js - AI support routes → JWT authentication: protects routes
src/csai/Routes/support.routes.js - AI support routes → Chat controller: routes requests
src/csai/Routes/support.routes.js - Chat controller → Conversation orchestration: delegates chat
src/csai/Controller/support.controller.js - Conversation orchestration → Conversation storage: uses conversation storage
src/csai/Services/support.service.js - Conversation orchestration → Chat message storage: uses message storage
src/csai/Services/support.service.js - Conversation orchestration → Conversation memory: loads context
src/csai/Services/support.service.js - Conversation orchestration → Search and ranking: searches knowledge
src/csai/Services/support.service.js - Conversation orchestration → Prompt construction: builds prompt
src/csai/Services/support.service.js - Conversation orchestration → Gemini integration: requests generation
src/csai/Services/support.service.js - Conversation orchestration → Response validation: validates answer
src/csai/Services/support.service.js - Gemini integration → Google Gemini: calls model
- Knowledge routes → Knowledge management: routes requests
src/csai/Routes/knowledge.routes.js - Knowledge routes → JWT authentication: protects routes
src/csai/Routes/knowledge.routes.js - Knowledge management → Search and ranking: delegates CRUD
src/csai/Controller/knowledge.controller.js - Search and ranking → Knowledge repository: loads records
src/csai/Services/knowledge.service.js - Knowledge repository → Approved knowledge: reads and writes
src/csai/Repository/knowledge.repository.js - Approved knowledge → MongoDB: stored in