Skip to content

Commit 2130fc8

Browse files
committed
Demo Ivan
1 parent 7a3dcf3 commit 2130fc8

31 files changed

Lines changed: 4590 additions & 0 deletions

demo/ARCHITECTURE.md

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
# M365 Knowledge Assistant - Architecture
2+
3+
## Overview
4+
5+
An AI-powered knowledge assistant that helps employees find information across Microsoft 365 services (SharePoint, Teams, OneDrive, Outlook) using the GitHub Copilot SDK.
6+
7+
## System Architecture
8+
9+
```
10+
┌─────────────────────────────────────────────────────────────────────────────┐
11+
│ CLIENT LAYER │
12+
├─────────────────────────────────────────────────────────────────────────────┤
13+
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
14+
│ │ Teams Bot │ │ Web UI │ │ CLI Tool │ │
15+
│ │ (Future) │ │ (React) │ │ (Current) │ │
16+
│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
17+
│ │ │ │ │
18+
│ └─────────────────┼─────────────────┘ │
19+
│ ▼ │
20+
├─────────────────────────────────────────────────────────────────────────────┤
21+
│ API LAYER │
22+
├─────────────────────────────────────────────────────────────────────────────┤
23+
│ ┌─────────────────────────────────────────────────────────────────────┐ │
24+
│ │ Express.js REST API │ │
25+
│ │ /api/chat - Send messages, stream responses │ │
26+
│ │ /api/sessions - Manage conversation sessions │ │
27+
│ │ /api/health - Health checks and monitoring │ │
28+
│ └─────────────────────────────────────────────────────────────────────┘ │
29+
│ │ │
30+
├───────────────────────────┼─────────────────────────────────────────────────┤
31+
│ CORE LAYER │
32+
├───────────────────────────┼─────────────────────────────────────────────────┤
33+
│ ▼ │
34+
│ ┌─────────────────────────────────────────────────────────────────────┐ │
35+
│ │ Copilot SDK Client │ │
36+
│ │ • Session Management │ │
37+
│ │ • Tool Registration │ │
38+
│ │ • Event Streaming │ │
39+
│ │ • Custom Agents │ │
40+
│ └─────────────────────────────────────────────────────────────────────┘ │
41+
│ │ │
42+
│ ┌─────────────────┼─────────────────┐ │
43+
│ ▼ ▼ ▼ │
44+
│ ┌────────────┐ ┌────────────┐ ┌────────────┐ │
45+
│ │ M365 │ │ GitHub │ │ Custom │ │
46+
│ │ Tools │ │ MCP │ │ Skills │ │
47+
│ └────────────┘ └────────────┘ └────────────┘ │
48+
│ │
49+
├─────────────────────────────────────────────────────────────────────────────┤
50+
│ INTEGRATION LAYER │
51+
├─────────────────────────────────────────────────────────────────────────────┤
52+
│ ┌────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐ │
53+
│ │ SharePoint │ │ Teams │ │ OneDrive │ │ Outlook │ │
54+
│ │ Service │ │ Service │ │ Service │ │ Service │ │
55+
│ └─────┬──────┘ └─────┬──────┘ └─────┬──────┘ └─────┬──────┘ │
56+
│ │ │ │ │ │
57+
│ └────────────────┴────────────────┴────────────────┘ │
58+
│ │ │
59+
│ ▼ │
60+
│ ┌─────────────────────────────────────────────────────────────────────┐ │
61+
│ │ Microsoft Graph Client │ │
62+
│ │ • Authentication (MSAL) │ │
63+
│ │ • Token Management │ │
64+
│ │ • API Abstraction │ │
65+
│ └─────────────────────────────────────────────────────────────────────┘ │
66+
│ │
67+
└─────────────────────────────────────────────────────────────────────────────┘
68+
```
69+
70+
## Directory Structure
71+
72+
```
73+
demo/
74+
├── ARCHITECTURE.md # This file
75+
├── TECH_STACK.md # Technology decisions
76+
├── PROJECT.md # Current tasks and roadmap
77+
├── STANDARDS.md # Coding standards
78+
79+
├── backend/
80+
│ ├── src/
81+
│ │ ├── api/ # Express routes and controllers
82+
│ │ │ ├── routes/
83+
│ │ │ │ ├── chat.routes.ts
84+
│ │ │ │ ├── session.routes.ts
85+
│ │ │ │ └── health.routes.ts
86+
│ │ │ ├── controllers/
87+
│ │ │ │ ├── chat.controller.ts
88+
│ │ │ │ ├── session.controller.ts
89+
│ │ │ │ └── health.controller.ts
90+
│ │ │ └── middleware/
91+
│ │ │ ├── auth.middleware.ts
92+
│ │ │ ├── error.middleware.ts
93+
│ │ │ └── validation.middleware.ts
94+
│ │ │
95+
│ │ ├── core/ # Copilot SDK integration
96+
│ │ │ ├── copilot-client.ts # SDK client wrapper
97+
│ │ │ ├── session-manager.ts # Session lifecycle
98+
│ │ │ ├── tool-registry.ts # Tool registration
99+
│ │ │ └── agent-config.ts # Custom agent definitions
100+
│ │ │
101+
│ │ ├── tools/ # Custom Copilot tools
102+
│ │ │ ├── index.ts # Tool exports
103+
│ │ │ ├── sharepoint.tool.ts
104+
│ │ │ ├── teams.tool.ts
105+
│ │ │ ├── onedrive.tool.ts
106+
│ │ │ └── outlook.tool.ts
107+
│ │ │
108+
│ │ ├── services/ # Business logic & integrations
109+
│ │ │ ├── graph/
110+
│ │ │ │ ├── graph-client.ts
111+
│ │ │ │ ├── sharepoint.service.ts
112+
│ │ │ │ ├── teams.service.ts
113+
│ │ │ │ ├── onedrive.service.ts
114+
│ │ │ │ └── outlook.service.ts
115+
│ │ │ └── auth/
116+
│ │ │ ├── msal-client.ts
117+
│ │ │ └── token-cache.ts
118+
│ │ │
119+
│ │ ├── config/ # Configuration
120+
│ │ │ ├── index.ts
121+
│ │ │ ├── copilot.config.ts
122+
│ │ │ └── graph.config.ts
123+
│ │ │
124+
│ │ ├── utils/ # Shared utilities
125+
│ │ │ ├── logger.ts
126+
│ │ │ ├── errors.ts
127+
│ │ │ └── validators.ts
128+
│ │ │
129+
│ │ └── index.ts # Application entry point
130+
│ │
131+
│ ├── tests/
132+
│ │ ├── unit/
133+
│ │ ├── integration/
134+
│ │ └── e2e/
135+
│ │
136+
│ ├── package.json
137+
│ ├── tsconfig.json
138+
│ └── Dockerfile
139+
140+
├── common/ # Shared types and constants
141+
│ ├── types/
142+
│ │ ├── api.types.ts
143+
│ │ ├── session.types.ts
144+
│ │ ├── tool.types.ts
145+
│ │ └── m365.types.ts
146+
│ └── constants/
147+
│ └── index.ts
148+
149+
├── skills/ # Copilot SDK skills
150+
│ └── enterprise-knowledge/
151+
│ └── SKILL.md
152+
153+
├── scripts/ # Build and deployment scripts
154+
│ ├── setup.sh
155+
│ └── deploy.sh
156+
157+
├── .github/
158+
│ └── workflows/
159+
│ └── ci.yml
160+
161+
├── .env.example
162+
├── docker-compose.yml
163+
└── README.md
164+
```
165+
166+
## Data Flow
167+
168+
### 1. User Query Flow
169+
```
170+
User Input → API Layer → Core Layer → Tool Execution → Graph API → Response
171+
```
172+
173+
### 2. Session Management
174+
```
175+
Create Session → Register Tools → Configure Agent → Process Messages → Persist State
176+
```
177+
178+
### 3. Tool Invocation
179+
```
180+
Copilot Decision → Tool Registry → Service Layer → Graph Client → External API
181+
```
182+
183+
## Key Components
184+
185+
### 1. Copilot Client Wrapper (`/backend/src/core/copilot-client.ts`)
186+
- Manages SDK lifecycle (start/stop)
187+
- Handles connection to Copilot CLI
188+
- Provides singleton access
189+
190+
### 2. Session Manager (`/backend/src/core/session-manager.ts`)
191+
- Creates and resumes sessions
192+
- Manages session persistence
193+
- Handles multi-user scenarios
194+
195+
### 3. Tool Registry (`/backend/src/core/tool-registry.ts`)
196+
- Registers M365 tools with Copilot
197+
- Manages tool handlers
198+
- Provides type-safe tool definitions
199+
200+
### 4. M365 Services (`/backend/src/services/graph/`)
201+
- Abstracts Microsoft Graph API
202+
- Handles authentication via MSAL
203+
- Provides typed responses
204+
205+
## Security Boundaries
206+
207+
1. **Authentication**: MSAL for M365, JWT for API
208+
2. **Authorization**: Graph permissions, role-based access
209+
3. **Data Flow**: All M365 data through Graph API only
210+
4. **Secrets**: Environment variables, never hardcoded
211+
212+
## Extension Points
213+
214+
1. Add new tools in `/backend/src/tools/`
215+
2. Add new services in `/backend/src/services/`
216+
3. Add new skills in `/skills/`
217+
4. Add new agents in `/backend/src/core/agent-config.ts`

demo/PROJECT.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# M365 Knowledge Assistant - Project Tracker
2+
3+
## Project Overview
4+
5+
**Goal**: Build an AI-powered assistant that helps employees find information across Microsoft 365 using the GitHub Copilot SDK.
6+
7+
**Status**: 🚧 In Development
8+
9+
---
10+
11+
## Current Sprint: Foundation Setup
12+
13+
### ✅ Completed Tasks
14+
15+
- [x] Create architecture documentation (ARCHITECTURE.md)
16+
- [x] Define technology stack (TECH_STACK.md)
17+
- [x] Create project tracker (PROJECT.md)
18+
- [x] Define coding standards (STANDARDS.md)
19+
- [x] **Phase 1: Core Infrastructure**
20+
- [x] Setup backend project structure (package.json, tsconfig.json)
21+
- [x] Configure TypeScript
22+
- [x] Implement Copilot client wrapper (`copilot-client.ts`)
23+
- [x] Implement session manager (`session-manager.ts`)
24+
- [x] Create tool registry pattern (`tool-registry.ts`)
25+
- [x] Define custom agents (`agent-config.ts`)
26+
- [x] **Phase 2: M365 Integration**
27+
- [x] Setup Microsoft Graph client (`graph-client.ts`)
28+
- [x] Implement MSAL authentication
29+
- [x] Create SharePoint service (`sharepoint.service.ts`)
30+
- [x] Create Teams service (`teams.service.ts`)
31+
- [x] **Phase 3: Copilot Tools**
32+
- [x] Implement SharePoint search tool (`sharepoint.tool.ts`)
33+
- [x] Implement Teams tools (`teams.tool.ts`)
34+
- [x] **Phase 6: CLI Interface**
35+
- [x] Interactive CLI for testing (`cli.ts`)
36+
- [x] Streaming response support
37+
- [x] Command system (/new, /help, /agents, etc.)
38+
39+
### 🔄 In Progress
40+
41+
- [ ] **Phase 4: API Layer**
42+
- [ ] Create Express server
43+
- [ ] Implement chat routes
44+
- [ ] Implement session routes
45+
- [ ] Add middleware (auth, error, validation)
46+
47+
### 📋 Up Next
48+
49+
- [ ] **Phase 5: Extended M365 Tools**
50+
- [ ] Implement OneDrive file tool
51+
- [ ] Implement Outlook mail tool
52+
53+
- [ ] **Phase 7: Testing & Polish**
54+
- [ ] Unit tests for services
55+
- [ ] Integration tests for tools
56+
- [ ] E2E tests for API
57+
- [ ] Documentation
58+
59+
---
60+
61+
## Feature Roadmap
62+
63+
### MVP (v0.1.0)
64+
- [x] Architecture documentation
65+
- [ ] Basic Copilot SDK integration
66+
- [ ] SharePoint search tool
67+
- [ ] CLI-based interaction
68+
- [ ] Session persistence
69+
70+
### v0.2.0
71+
- [ ] Teams message retrieval
72+
- [ ] OneDrive file search
73+
- [ ] REST API endpoints
74+
- [ ] Streaming responses
75+
76+
### v0.3.0
77+
- [ ] Outlook integration
78+
- [ ] Custom agents (HR, IT, etc.)
79+
- [ ] Skills system
80+
- [ ] Multi-user sessions
81+
82+
### Future
83+
- [ ] Teams Bot integration
84+
- [ ] Web UI (React)
85+
- [ ] Power Platform connector
86+
- [ ] Analytics dashboard
87+
88+
---
89+
90+
## Technical Debt
91+
92+
| Item | Priority | Description |
93+
|------|----------|-------------|
94+
| - | - | No technical debt yet |
95+
96+
---
97+
98+
## Decisions Log
99+
100+
| Date | Decision | Rationale |
101+
|------|----------|-----------|
102+
| 2026-01-25 | Use GitHub Copilot SDK | Production-tested agent runtime with tool orchestration |
103+
| 2026-01-25 | TypeScript + Express | Team familiarity, mature ecosystem |
104+
| 2026-01-25 | Zod for validation | Runtime type safety, JSON Schema support |
105+
106+
---
107+
108+
## Dependencies & Blockers
109+
110+
### External Dependencies
111+
- [ ] GitHub Copilot CLI must be installed
112+
- [ ] Azure AD App Registration required
113+
- [ ] M365 tenant with appropriate licenses
114+
115+
### Blockers
116+
- None currently
117+
118+
---
119+
120+
## Team Notes
121+
122+
### Getting Started
123+
1. Clone repository
124+
2. Copy `.env.example` to `.env`
125+
3. Configure Azure AD credentials
126+
4. Install Copilot CLI
127+
5. Run `npm install`
128+
6. Run `npm run dev`
129+
130+
### Useful Commands
131+
```bash
132+
# Development
133+
npm run dev # Start with hot reload
134+
npm run build # Build for production
135+
npm run test # Run tests
136+
npm run lint # Run linter
137+
138+
# Copilot CLI
139+
copilot --version # Check CLI version
140+
copilot --server # Run in server mode
141+
```
142+
143+
---
144+
145+
## Metrics & Goals
146+
147+
| Metric | Target | Current |
148+
|--------|--------|---------|
149+
| Test Coverage | >80% | 0% |
150+
| API Response Time | <500ms | N/A |
151+
| Tool Execution Time | <2s | N/A |
152+
| Documentation | 100% | 50% |

0 commit comments

Comments
 (0)