Commit 1fd46b

2025-10-16 06:22:18 Kaushal Lamkhade: Updated Sequence Diagram
Projects/CommNet.md ..
@@ 84,6 84,80 @@
## System Architecutre Diagram
![](./System_Architecture.png)
+ ```mermaid
+ flowchart TB
+
+ %% SECTION: External
+ subgraph EXT[External Environment]
+ Customer[Customer (End User)]
+ end
+
+ %% SECTION: Comnet Platform
+ subgraph COM[Comnet Platform]
+ Reg[User Registration & Auth Service]
+ TenantMgr[Workspace / Tenant Manager]
+ end
+
+ %% SECTION: Workspace Layer
+ subgraph WS[Workspace Layer (per Client)]
+ subgraph WM[Workspace Modules]
+ Users[User & Group Management]
+ Clients[Client Records]
+ Tasks[Task Management Module]
+ KB[Knowledge Base]
+ Analytics[Reports & Analytics]
+ end
+ Channels[Channel Integrations (Email, Telegram, SMS)]
+ Agents[Channel Agents]
+ end
+
+ %% SECTION: Core System
+ subgraph CORE[Core Processing Layer]
+ MCP[MCP Server (Message Coordination Processor)]
+ AIHub[AI Model Router]
+ subgraph AI[AI Services]
+ ChatGPT[(ChatGPT Model)]
+ Gemini[(Gemini Model)]
+ end
+ end
+
+ %% Data Stores
+ DB[(Database Storage)]
+ Logs[(Conversation Logs)]
+
+ %% External Connections
+ Customer <--> Channels
+ Channels --> Agents
+ Agents --> MCP
+ MCP --> AIHub
+ AIHub --> ChatGPT
+ AIHub --> Gemini
+ AIHub --> KB
+ KB --> MCP
+ MCP --> Tasks
+ MCP --> Agents
+ Tasks --> Users
+ Users --> Analytics
+ Agents --> Logs
+ WS --> DB
+
+ %% Comnet relationships
+ Reg --> TenantMgr
+ TenantMgr --> WS
+
+ %% Labels
+ classDef external fill:#f5f5f5,stroke:#999,stroke-width:1px;
+ classDef service fill:#e0f7fa,stroke:#0288d1,stroke-width:1px;
+ classDef ai fill:#fff3e0,stroke:#fb8c00,stroke-width:1px;
+ classDef storage fill:#f1f8e9,stroke:#7cb342,stroke-width:1px;
+ classDef core fill:#fce4ec,stroke:#ad1457,stroke-width:1px;
+ class COM,WS,CORE service;
+ class AI,AIHub ai;
+ class DB,Logs,KB storage;
+ class Customer external;
+ ```
+
+
## 1. Tech Stack
- **Backend (Node.js)**
- **FastAPI** (async, lightweight, API-first approach) or Djangofeatures).
@@ 186,86 260,96 @@
---
- # Sequence Diagram - [Click to View](https://getu.at/hWuEId)
+ # Sequence Diagram - [Click to View](https://getu.at/kDgGCA)
```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
+ autonumber
+
+ %% ===== PARTICIPANTS =====
+ participant Client as πŸ§‘ Client (Workspace Owner)
+ participant Comnet as 🌐 Comnet Portal
+ participant WS as 🏒 Workspace Service
+ participant Channel as πŸ’¬ Communication Channel (Email/Telegram)
+ participant Agent as πŸ€– Channel Agent
+ participant MCP as 🧠 MCP Server
+ participant AI as 🧩 AI Model Router (ChatGPT/Gemini)
+ participant KB as πŸ“š Knowledge Base Service
+ participant Task as πŸ“‹ Task Service
+ participant DB as πŸ—„οΈ PostgreSQL Database
+
+ %% ===== REGISTRATION & WORKSPACE CREATION =====
+ Client->>Comnet: Register on Comnet
+ Comnet->>DB: INSERT client credentials and org record
+ Comnet-->>Client: Return registration success + auth token
+
+ Client->>WS: Create Workspace
+ WS->>DB: INSERT workspace details linked to client
+ WS-->>Client: Workspace created successfully
+
+ %% ===== WORKSPACE CONFIGURATION =====
+ Client->>WS: Add Users, Groups, Clients
+ WS->>DB: INSERT user/group/client records
+ Client->>KB: Upload KB documents / FAQs / SOPs
+ KB->>DB: INSERT KB entries + embeddings
+ KB-->>Client: KB indexed successfully
+ Client->>WS: Configure Communication Channels (Email, Telegram, SMS)
+ WS->>DB: UPDATE workspace with channel settings
+ WS-->>Client: Channel configuration saved
+
+ %% ===== AI & MCP CONFIGURATION =====
+ Client->>AI: Configure AI Models (ChatGPT, Gemini)
+ AI->>DB: INSERT model config (API keys, version, workspace linkage)
+ AI-->>Client: Model configuration confirmed
+
+ Client->>MCP: Configure MCP routing rules (channel–AI mapping)
+ MCP->>DB: INSERT routing and message handling configuration
+ MCP-->>Client: MCP configured successfully
+
+ Note over Client,DB: Workspace setup completed (Users, Channels, AI, MCP, KB)
+
+ %% ===== CUSTOMER COMMUNICATION FLOW =====
+ Note over Channel,Agent: Customer sends query via selected channel
+ Channel->>Agent: Receive inbound message
+ Agent->>MCP: Forward message + workspace/channel context
+ MCP->>DB: SELECT workspace configuration + routing rules
+ MCP->>AI: Route message to appropriate AI model
+
+ %% ===== AI PROCESSING & KB INTERACTION =====
+ AI->>KB: Request contextual KB data
+ KB->>DB: SELECT related knowledge entries
+ DB-->>KB: Return matching KB results
+ KB-->>AI: Provide relevant context
+ AI-->>MCP: Return AI-generated response + detected intent
+
+ %% ===== TASK MANAGEMENT =====
+ alt Actionable Intent Detected
+ MCP->>Task: Create new task (assigned to group)
+ Task->>DB: INSERT new task entry
+ Task-->>MCP: Task creation success
+ else Informational Only
+ MCP-->>Agent: Return AI response for delivery
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
+ %% ===== RESPONSE DELIVERY =====
+ MCP->>Agent: Send AI response payload
+ Agent->>Channel: Deliver reply back to customer
+ Channel-->>Customer: Message displayed
- %% 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
+ %% ===== KNOWLEDGE UPDATE (Learning Loop) =====
+ alt New Insight Identified
+ AI->>KB: Suggest KB entry addition/update
+ KB->>DB: INSERT or UPDATE KB record
+ KB-->>AI: Update acknowledged
+ end
- %% Ongoing conversation loop
- Customer-->>Channel: Follow-up messages (loop continues)
- Channel->>Agent: Forward follow-ups
- Agent->>MCP: Repeat AI processing with updated context
+ %% ===== LOGGING & ANALYTICS =====
+ MCP->>DB: INSERT message, AI response, metadata
+ Task->>DB: UPDATE task progress or completion
+ WS->>DB: UPDATE analytics data (response time, task count, sentiment)
+ DB-->>WS: Return metrics for dashboard display
+ Note over DB: PostgreSQL stores all entities (clients, workspaces, channels, AI configs, KB, tasks, analytics)
```
# Future Scope
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