Spaces:
Paused
Paused
File size: 21,939 Bytes
5a81b95 e78514a 5a81b95 e78514a 5a81b95 e78514a 5a81b95 e78514a 5a81b95 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | # WidgeTDC - Enterprise AI Platform Architecture
**Last Updated:** 2025-12-13
**Status:** β
PRODUCTION LIVE - Cloud Deployment Active
## System Overview
WidgeTDC is an Enterprise-grade Autonomous Intelligence Platform featuring:
- **Semantic Vector Database** with multi-provider embeddings
- **Autonomous Task Engine** with learning loops
- **Distributed Event System** for scalability
- **Production-ready Infrastructure** with monitoring and logging
- **Modern Frontend** with React 19 and Tailwind CSS v4
---
## π Production Deployment (2025-12-13)
### Live URLs
| Service | Platform | URL |
|---------|----------|-----|
| **Frontend** | Vercel Edge | `https://matrix-frontend-claus-krafts-projects.vercel.app` |
| **Backend API** | HuggingFace Spaces | `https://kraft102-widgettdc-api.hf.space` |
### Cloud Infrastructure
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PRODUCTION ARCHITECTURE β
β "Headless Ghost" Pattern β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Browser βββΆ Vercel CDN βββΆ HuggingFace Spaces βββΆ Cloud Databases
β β β
React 19 PWA Node.js 20 ββββββ΄βββββ
185 Widgets 63 MCP Tools β Redis β
Zustand State Express API β Neo4j β
β Neon PG β
βββββββββββ
```
### Database Layer
| Database | Provider | Purpose |
|----------|----------|---------|
| **Redis** | Redis Cloud (EU-North-1) | Cache, Sessions, Event Bus |
| **Neo4j** | AuraDB Cloud | Knowledge Graph (4274 nodes, 5252 rels) |
| **PostgreSQL** | Neon Serverless | Vector Store (pgvector), Prisma ORM |
| **SQLite** | sql.js (in-memory) | Fallback for HF Spaces free tier |
### AI/LLM Providers
| Provider | Use Case |
|----------|----------|
| Google Gemini Pro | Primary reasoning |
| OpenAI GPT-4 | Fallback, embeddings |
| Anthropic Claude | Analysis tasks |
| DeepSeek V3 | Code generation |
---
## Recent Updates (2025-12-13)
### β
HuggingFace Spaces Deployment Fixed
- **Dockerfile Optimized**: Skip Puppeteer Chromium download
- **Memory Limits**: Reduced to 512MB for free tier compatibility
- **package-lock.json**: Regenerated correct monorepo lockfile
- **Data Directories**: `/app/data/*` created with proper permissions
- **Environment Variables**: `HF_SPACE=true`, `DOCKER=true` set
### β
Frontend Widgets Fixed
- **Icon Imports**: Added missing `Target`, `Video` imports
- **DataSources**: Added `threatIntel` to SourceLink.tsx
- **useEffect Fix**: Removed undefined `width/height` from dependency array
- **185 Widgets**: All rendering correctly
### β
Previous Updates (2025-11-26)
- CSS Architecture rebuilt for Tailwind v4
- PowerShell scripts standardized (PSScriptAnalyzer compliant)
- Build system fully functional
---
## Architecture Diagram
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FRONTEND (React 19) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Widget Board β β MCP Client β β Dashboard β β
β ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ β
β β β β β
β ββββββββββββββββββββ΄βββββββββββββββββββ β
β β WebSocket + REST API β
ββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββ
β BACKEND (Node.js + Express) β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β API LAYER β β
β β βββββββββββ βββββββββββ βββββββββββ βββββββββββ β β
β β β MCP β β SRAG β β PAL β β AI β ... β β
β β β Router β β API β β API β β Proxy β β β
β β ββββββ¬βββββ ββββββ¬βββββ ββββββ¬βββββ ββββββ¬βββββ β β
β β β β β β β β
β βββββββββΌβββββββββββββΌβββββββββββββΌββββββββββββββΌββββββββββββββββββ β
β β β β β β
β βββββββββ΄βββββββββββββ΄βββββββββββββ΄ββββββββββββββ΄ββββββββββββββββββ β
β β COGNITIVE LAYER β β
β β β β
β β ββββββββββββββββββββ ββββββββββββββββββββ β β
β β β Autonomous Agent β β UnifiedGraphRAG β β β
β β β ββββββββββββββ β β Multi-hop RAG β β β
β β β β Task Engineβ β ββββββββββ¬ββββββββββ β β
β β β β & Learning β β β β β
β β β βββββββ¬βββββββ β β β β
β β ββββββββββΌββββββββββ β β β
β β β β β β
β β ββββββββββ΄ββββββββββββββββββββββββ΄βββββββββββ β β
β β β Unified Memory System β β β
β β β ββββββββββββ ββββββββββββ βββββββββββββ β β
β β β β Working β β Episodic β βProceduralββ β β
β β β β Memory β β Memory β β Memory ββ β β
β β β ββββββββββββ ββββββββββββ βββββββββββββ β β
β β ββββββββββββββββββββββ¬ββββββββββββββββββββββββ β β
β β β β β
β βββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββ β
β β DATA & EMBEDDING LAYER β β
β β β β
β β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β
β β β Embedding Service (Multi-Provider) β β β
β β β βββββββββββ ββββββββββββββ ββββββββββββββββ β β β
β β β β OpenAI β βHuggingFace β βTransformers.jsβ β β β
β β β β 1536D β β 768D β β 384D β β β β
β β β ββββββ¬βββββ βββββββ¬βββββββ ββββββββ¬ββββββββ β β β
β β β βββββββββββββββ΄βββββββββββββββββ΄β Auto-select β β β
β β βββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ β β
β β β Generate embeddings β β
β β βββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ β β
β β β PgVectorStoreAdapter (pgvector) β β β
β β β β’ Auto-embedding generation β β β
β β β β’ Semantic text search β β β
β β β β’ Cosine similarity β β β
β β β β’ Namespace isolation β β β
β β βββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ β β
β β β β β
β ββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββ β
β β EVENT & INTEGRATION LAYER β β
β β β β
β β ββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββ β β
β β β Redis EventBus ββββββ€ Ingestion Pipeline β β β
β β β (Production) β β β’ Data Sources (20+) β β β
β β β OR β β β’ Browser History β β β
β β β In-Memory β β β’ Email (Gmail, Outlook) β β β
β β β (Development) β β β’ Cloud (Drive, OneDrive) β β β
β β ββββββββββββββββββββ β β’ Social (Twitter, LinkedIn) β β β
β β ββββββββββββββββββββββββββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββ
β PERSISTENCE LAYER β
β βΌ β
β ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ β
β β PostgreSQL β β Redis β β Neo4j β β
β β + pgvector β β Event Store β β Knowledge Graph β β
β β β’ Embeddings β β β’ Pub/Sub β β β’ Entities β β
β β β’ Documents β β β’ Cache β β β’ Relations β β
β β β’ Metadata β β β’ Sessions β β β’ Inference β β
β ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
---
## Directory Structure
```
WidgeTDC/
βββ apps/
β βββ backend/ # Express.js backend
β β βββ src/
β β β βββ mcp/ # MCP protocol implementation
β β β βββ cognitive/ # AI agents & RAG
β β β βββ memory/ # Memory systems
β β β βββ ingestion/ # Data ingestion
β β β βββ api/ # REST endpoints
β β βββ package.json
β β
β βββ matrix-frontend/ # React 19 frontend β
BUILD FIXED
β βββ src/
β β βββ components/ # React components
β β βββ widgets/ # Widget implementations
β β βββ mcp/ # MCP client
β βββ App.css # β
REBUILT - All keyframes fixed
β βββ App.tsx
β βββ package.json
β
βββ packages/
β βββ shared/ # Shared types & utilities
β βββ types/
β βββ utils/
β
βββ scripts/ # β
UPDATED - PowerShell scripts
β βββ update_agent.ps1 # β
NEW - Agent updater
β βββ update_agent_github.ps1 # β
NEW - GitHub workflow updater
β βββ update_agent_readme.ps1 # β
NEW - README updater
β βββ build-shared.ps1
β βββ install-deepseek.ps1
β βββ setup-enterprise.ps1
β βββ test_rag_flow.ps1
β
βββ database/
β βββ migrations/ # SQL migrations
β βββ schema.sql
β
βββ .github/
β βββ workflows/ # GitHub Actions
β βββ agent-*.yml # Agent workflows
β βββ ci.yml
β
βββ docs/ # Documentation
βββ tests/ # Test suites
βββ dist/ # β
Build output (created successfully)
```
---
## Technology Stack
### Frontend
- **Framework**: React 19 (latest)
- **Build Tool**: Vite 6.4.1
- **Styling**: Tailwind CSS v4 (PostCSS)
- **State Management**: Zustand
- **Real-time**: WebSocket client
- **Testing**: Vitest + React Testing Library
### Backend
- **Runtime**: Node.js 20+
- **Framework**: Express.js
- **Language**: TypeScript (strict mode)
- **Real-time**: WebSocket (`ws` library)
- **MCP**: Custom implementation
### Database
- **Primary**: PostgreSQL 15+ with pgvector
- **Cache/Events**: Redis 7+
- **Graph**: Neo4j 5+ (optional)
- **Development**: SQLite (fallback)
### DevOps
- **Containerization**: Docker + Docker Compose
- **CI/CD**: GitHub Actions
- **Deployment**: Railway (configured)
- **Monitoring**: PM2 ecosystem
---
## Key Components
### 1. MCP (Model Context Protocol)
- **Location**: `apps/backend/src/mcp/`
- **Purpose**: Standardized AI agent communication
- **Features**:
- Tool registration and execution
- Resource management
- Event broadcasting
- WebSocket transport
### 2. UnifiedGraphRAG
- **Location**: `apps/backend/src/cognitive/UnifiedGraphRAG.ts`
- **Purpose**: Multi-hop semantic retrieval
- **Features**:
- Entity extraction
- Relation mapping
- Context-aware search
- Hybrid retrieval (vector + graph)
### 3. Autonomous Task Engine
- **Location**: `apps/backend/src/cognitive/AutonomousAgent.ts`
- **Purpose**: Self-directed task execution
- **Features**:
- Goal decomposition
- Learning from outcomes
- Dynamic replanning
- Memory integration
### 4. Widget System
- **Location**: `apps/matrix-frontend/src/widgets/`
- **Purpose**: Modular UI components
- **Features**:
- Dynamic loading
- MCP integration
- Drag-and-drop layout
- Settings persistence
---
## Build & Deployment Status
### β
Frontend Build
```bash
npm run build --prefix apps/matrix-frontend
# Status: β
SUCCESS (6.40s)
# Output: dist/ directory created
# Issues: None
```
### β
CSS Architecture
- **File**: `apps/matrix-frontend/App.css`
- **Status**: Completely rebuilt
- **Keyframes**: All properly structured
- **Tailwind**: v4 compatible (no @apply)
- **Animations**: All functional
### β
PowerShell Scripts
- **Location**: `scripts/`
- **Status**: PSScriptAnalyzer compliant
- **Issues**: None
---
## Configuration Files
### Build Configuration
- `vite.config.ts` - Vite build settings
- `tsconfig.json` - TypeScript compiler options
- `tailwind.config.js` - Tailwind CSS v4 config
- `postcss.config.js` - PostCSS plugins
### Runtime Configuration
- `ecosystem.config.js` - PM2 process management
- `docker-compose.yml` - Container orchestration
- `railway.json` - Railway deployment config
---
## Development Workflow
### Local Development
```bash
# Install dependencies
npm install
# Start backend
npm run dev:backend
# Start frontend (separate terminal)
npm run dev:frontend
# Run tests
npm test
```
### Production Build
```bash
# Build frontend
npm run build --prefix apps/matrix-frontend
# Build backend
npm run build --prefix apps/backend
# Start production server
npm start
```
---
## Security & Compliance
### Authentication
- JWT-based authentication
- Session management via Redis
- CORS configured for production
### Data Protection
- Encryption at rest (PostgreSQL)
- TLS for all network traffic
- Environment variable isolation
### Compliance
- GDPR-ready data handling
- Audit logging
- Data retention policies
---
## Monitoring & Observability
### Logging
- Structured JSON logs
- Log levels: ERROR, WARN, INFO, DEBUG
- Persistent storage in `logs/`
### Metrics
- PM2 monitoring
- Database connection pooling
- WebSocket connection tracking
### Health Checks
- `/health` endpoint
- Database connectivity
- Redis availability
- Memory usage
---
## Known Issues & Limitations
### β
Resolved
- ~~CSS build errors in App.css~~ **FIXED 2025-11-26**
- ~~PowerShell script warnings~~ **FIXED 2025-11-26**
- ~~Tailwind @apply compatibility~~ **FIXED 2025-11-26**
### Active
- None currently blocking
---
## Future Enhancements
### Planned Features
1. **Multi-tenant Support**: Workspace isolation
2. **Advanced Analytics**: Usage dashboards
3. **Plugin System**: Third-party widget support
4. **Mobile App**: React Native client
### Infrastructure
1. **Kubernetes**: Container orchestration
2. **Prometheus**: Metrics collection
3. **Grafana**: Visualization
4. **ELK Stack**: Log aggregation
---
## Contributing
See [CONTRIBUTING.md](./CONTRIBUTING.md) for development guidelines.
## License
See [LICENSE](./LICENSE) for details.
---
**Architecture maintained by**: WidgeTDC Development Team
**Last reviewed**: 2025-11-26
**Next review**: 2025-12-26
|