Spaces:
Paused
Paused
| # 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 | |