Commit 2da127

2025-10-13 07:20:03 Kaushal Lamkhade: Updated Sequence DIargram
Projects/CommNet.md ..
@@ 82,90 82,11 @@
- **CI/CD**: GITLAB
## System Architecutre Diagram
- ```mermaid
- graph TD
- %% === CHANNELS ===
- subgraph CH["CHANNELS"]
- SMS["SMS Adapter"]
- Widget["Website Widget Adapter"]
- end
-
- %% === CALLING ADAPTERS ===
- subgraph CA["CALLING ADAPTER"]
- Transcribe["Transcription Service"]
- Telegram["Telegram Adapter"]
- WhatsApp["WhatsApp Adapter"]
- Email["Email Adapter"]
- end
-
- %% === INGESTION ROUTING ===
- subgraph IR["INGESTION ROUTING"]
- Kafka["Kafka / RabbitMQ"]
- Router["Channel Router"]
- Kafka --> Router
- end
-
- %% === CORE SERVICES ===
- subgraph CS["CORE SERVICES"]
- IM["Intelligent Model"]
- MCP["MCP Handler"]
- IM --> MCP
- end
-
- %% === AI PROCESSING ===
- subgraph AI["AI PROCESSING"]
- subgraph AIH["AI HANDLER"]
- OpenAI["OpenAI API"]
- Gemini["Gemini API"]
- end
-
- subgraph KB["KNOWLEDGE BASE"]
- VectorDB["Vector DB"]
- end
-
- Memory["Memory (Redis)"]
- end
-
- %% === DATA LAYER ===
- subgraph DL["DATA LAYER"]
- Postgres["Postgres"]
- PGVector["pgvector"]
- end
-
- %% === FLOWS ===
- %% Channel and adapters feed into ingestion
- SMS --> Kafka
- Widget --> Kafka
- Transcribe --> Kafka
- Telegram --> Kafka
- WhatsApp --> Kafka
- Email --> Kafka
-
- %% Routing to orchestration
- Router --> Orchestration["Orchestration"]
-
- %% Orchestration connects to AI Processing
- Orchestration --> OpenAI
- Orchestration --> Gemini
- Orchestration --> Memory
- Orchestration --> VectorDB
-
- %% Core services interaction
- Telegram --> IM
- WhatsApp --> IM
- Email --> IM
-
- %% Data layer connections
- VectorDB --> PGVector
- PGVector --> Postgres
- Postgres --> Orchestration
- Postgres --> VectorDB
- Memory --> Orchestration
- ```
+ ![](./System_Architecture.png)
## 1. Tech Stack
- **Backend (Node.js)**
- - **NestJS** (modular, scalable, and TypeScript-based backend framework optimized for maintainable server-side applications and APIs)
+ - **FastAPI** (async, lightweight, API-first approach) or Djangofeatures).
- **Database**
- **PostgreSQL** (perfectly suited for multi-tenant, relational data storage).
- **Frontend**
@@ 227,43 148,7 @@
- Analytics & logs.
## Dataflow Diagram
- ```mermaid
- graph TD
- A["Customer Queries"] --> B_Email["Email"]
- A --> B_Telegram["Telegram"]
- A --> B_Twilio["Twilio"]
- A --> B_Slack["Slack"]
- A --> B_Interface["Interface"]
-
- B_Email --> API["API Gateway"]
- B_Telegram --> API
- B_Twilio --> API
- B_Slack --> API
- B_Interface --> API
-
- API --> Auth["Auth and Client Service"]
- Auth --> Postgres["Postgres"]
- Auth --> Orch["Conversation Orchestrator"]
-
- Orch --> AIConnect["AI Connectors"]
- Orch --> AIResponse["AI Response - KB + AI"]
- AIResponse --> LogConv["Log Conversation"]
- LogConv --> Dashboard["Dashboard"]
-
- AIConnect --> ChatGPT["ChatGPT"]
- AIConnect --> Gemini["Gemini"]
- AIConnect --> Perplexity["Perplexity"]
-
- Postgres --> ClientA["Client A"]
- Postgres --> ClientB["Client B"]
- ClientA --> Departments["Departments"]
- ClientA --> KB["Knowledge Base - Vector DB Search"]
- ClientB --> KB
- KB --> ChannelConfig["Channel Configurations"]
-
- LogConv -->|"Response to Customer Query"| A
- ```
-
+ ![Dataflow Diagram](./Comm_1.png)
---
@@ 301,6 186,88 @@
---
+ # Sequence Diagram
+
+ ```mermaid
+ sequenceDiagram
+ %% Participants
+ participant ClientUser as Client (Registers on Comnet)
+ participant Comnet as Comnet System
+ participant Workspace as Workspace (Project)
+ participant WorkspaceOwner as Workspace Owner (ClientUser Role)
+ participant ChannelConfig as Channel Configuration
+ participant Channel as Communication Channel (Email/Telegram/SMS)
+ participant Agent as Channel Agent
+ participant Customer as Customer (Client's customer)
+ participant MCP as MCP Server (Message Coordination Processor)
+ participant AI as AI Model (ChatGPT/Gemini)
+ participant KB as Knowledge Base
+ participant Task as Task Management Module
+ participant Group as Group (Managers & Members)
+ participant Member as Group Member
+
+ %% Registration and Workspace Creation by Client (Workspace Owner)
+ ClientUser->>Comnet: Register account
+ Comnet-->>ClientUser: Account created
+ ClientUser->>Workspace: Create new workspace (project)
+ Workspace-->>ClientUser: Workspace created
+ ClientUser->>WorkspaceOwner: Become workspace owner
+
+ %% Workspace Setup & Channel Configuration (done by workspace owner)
+
+ WorkspaceOwner->>Workspace: Create groups and assign roles (Manager / Member)
+ WorkspaceOwner->>ChannelConfig: Add and configure channels (Email / Telegram / SMS)
+ ChannelConfig-->>Workspace: Channels registered and linked to workspace
+ ChannelConfig->>Agent: Provision Channel Agents for each channel
+ Agent-->>Workspace: Channel Agents ready and bound to workspace
+
+ %% Normal flow: Customer raises query on a configured channel
+ Customer->>Channel: Send message/query (via configured channel)
+ Channel->>Agent: Channel Agent receives and forwards message
+ Agent->>MCP: Forward message + workspace context (client id, channel id, conversation history)
+
+ %% AI processing using KB and workspace context
+ MCP->>AI: Send message + workspace context + KB pointers
+ AI->>KB: Request relevant KB entries and workspace-specific context
+ KB-->>AI: Return KB results and context
+ AI-->>MCP: Return generated response + intent detection (actionable? yes/no) + confidence
+
+ %% Conditional: If AI detects actionable intent -> create task in same workspace and assign to group
+ alt Actionable intent detected
+ MCP->>Task: Create Task in Workspace (details, priority, assignee group)
+ Task->>Group: Assign task to specific group or manager
+ Group-->>Task: Acknowledgement of task assignment
+ Task->>Workspace: Log task creation and link it to conversation
+ Workspace-->>WorkspaceOwner: Notify workspace members (or assigned group) of new task
+ end
+
+ %% Response delivery back to customer via same channel
+ MCP-->>Agent: Return AI-generated reply (and task info if created)
+ Agent-->>Channel: Send reply via originating channel
+ Channel-->>Customer: Deliver AI response to customer
+
+ %% Group resolves task (if created)
+ alt Task exists
+ Member->>Task: View task and start work
+ Member->>Group: Update task status / add comments / attach files
+ Group-->>Task: Mark task progress or resolution
+ Task-->>Workspace: Update task log and notify conversation thread
+ Workspace-->>Customer: Optionally send status update (via Channel) if configured
+ end
+
+ %% Logging, KB updates and analytics (always)
+ Agent->>Workspace: Log conversation and response metadata
+ AI->>Workspace: (optional) Suggest KB update based on conversation
+ Workspace->>KB: Update KB (optional manual review or auto-suggest)
+ Workspace-->>WorkspaceOwner: Update analytics / reports / conversation history
+
+ %% Ongoing conversation loop
+ Customer-->>Channel: Follow-up messages (loop continues)
+ Channel->>Agent: Forward follow-ups
+ Agent->>MCP: Repeat AI processing with updated context
+
+ ```
+
# Future Scope
The platform is designed with scalability in mind, allowing integration of new features and channels to enhance client communication and management. Planned future improvements include:
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9