How shankar7055/cognify works
1. System Purpose and Entry Points
Cognify is a SaaS AI-operations platform for team-scoped workflow automation, multi-agent chat, document/vector memory, collaboration, analytics, and subscription billing. It is a split React SPA and Express API/worker system.
• Client bootstrap and route composition: cognify-client/src/main.tsx, cognify-client/src/App.tsx
• Server bootstrap/application wiring: cognify-server/src/server.ts, cognify-server/src/app.ts
2. Frontend Application Surfaces
The Vite/React/TypeScript client separates public marketing/auth screens from the authenticated operational dashboard. Dashboard pages expose the platform domains—chat, agents, workflows, files, memory, teams, integrations, analytics, billing, and settings.
• Dashboard shell and domain routes: cognify-client/src/pages/dashboard/DashboardLayout.tsx, cognify-client/src/pages/dashboard/ExecutiveDashboard.tsx
• AI chat composition: cognify-client/src/pages/dashboard/AIChat.tsx, cognify-client/src/pages/dashboard/chat/ChatMain.tsx
• Browser-to-API boundary: cognify-client/src/utils/api.ts
3. HTTP API, Identity, and Workspace Boundary
Express routes organize the API by product domain. Requests pass through authentication, validation/rate limiting, feature gates, API-key checks where applicable, and workspace membership authorization before services access tenant-owned data.
• Route boundary: cognify-server/src/routes/chat.routes.ts, cognify-server/src/routes/workflows.routes.ts, cognify-server/src/routes/workspace.routes.ts
• Cross-cutting authorization: cognify-server/src/middleware/auth.middleware.ts, cognify-server/src/middleware/workspaceAccess.middleware.ts, cognify-server/src/middleware/apiKey.middleware.ts
• Auth and workspace domain logic: cognify-server/src/services/auth/auth.service.ts, cognify-server/src/services/workspace/workspace.service.ts
4. Persistent Tenant Data and Storage
PostgreSQL, accessed through Prisma, is the system of record for users, workspaces, memberships, files, AI requests, embeddings, API keys, subscriptions, messages, prompts, and costs. File handling forms a separate storage/ingestion boundary backed by S3-compatible configuration.
• Schema and evolution: cognify-server/prisma/schema.prisma, cognify-server/prisma/migrations/
• Storage pipeline: cognify-server/src/services/storage/s3.service.ts, cognify-server/src/services/storage/fileParser.service.ts
• Infrastructure clients: cognify-server/src/config/db.ts, cognify-server/src/config/s3.ts
5. AI Execution and Memory Pipeline
Chat or agent requests are routed through an AI manager/model and agent router to specialized or autonomous agents. Provider adapters isolate external model APIs; tool routing exposes controlled capabilities. Embedding/vector-memory services support semantic retrieval over ingested workspace material, while streaming delivers incremental responses.
• Orchestration: cognify-server/src/services/ai/aiManager.service.ts, cognify-server/src/services/ai/agentRouter.service.ts, cognify-server/src/services/ai/modelRouter.service.ts
• Providers and agents: cognify-server/src/services/ai/providers/, cognify-server/src/services/ai/agents/
• Retrieval/stream boundary: cognify-server/src/services/ai/embedding.service.ts, cognify-server/src/services/ai/vectorMemory.service.ts, cognify-server/src/services/ai/stream.service.ts
6. Async Automation, Analytics, and Notifications
Redis/BullMQ decouples long-running AI work, workflow execution, usage aggregation, and email delivery from HTTP requests. Workflow services define triggers and step execution; workers consume queued jobs. Socket and email services provide user-facing asynchronous notifications.
• Queues/workers: cognify-server/src/queues/aiQueue.ts, cognify-server/src/queues/workers/workflow.worker.ts, cognify-server/src/config/redis.ts
• Automation engine: cognify-server/src/services/automation/workflow.service.ts, cognify-server/src/services/automation/triggerEngine.service.ts
• Analytics/notifications: cognify-server/src/services/analytics/usage.service.ts, cognify-server/src/services/notification/socket.service.ts
7. Commercial Integrations and Deployment
Billing routes/services mediate Stripe subscriptions/webhooks and Razorpay configuration. The service runs on Node.js with PostgreSQL, Redis, S3, external AI providers, Stripe, Razorpay, and integrations for Slack, Notion, and Sheets. Production supports Docker Compose and PM2 clustered deployment; the SPA has Vercel configuration.
• Billing boundary: cognify-server/src/services/billing/stripe.service.ts, cognify-server/src/services/billing/webhook.service.ts, cognify-server/src/config/razorpay.ts
• Third-party integrations: cognify-server/src/services/integrations/slack.service.ts, cognify-server/src/services/integrations/notion.service.ts
• Runtime/deployment: cognify-server/Dockerfile, cognify-server/docker-compose.yml, cognify-server/ecosystem.config.js, cognify-client/vercel.json
Main entry points: chat.routes.ts Domain routes · aiManager.service.ts AI orchestration · aiQueue.ts BullMQ queues · workflow.worker.ts Queue workers
Components 19
React SPA
- Client bootstrap
cognify-client/src/main.tsx - Dashboard surfaces · Chat, agents, workflows, files, memory, teams, analytics, and billing.
cognify-client/src/pages/dashboard/DashboardLayout.tsx - API client
cognify-client/src/utils/api.ts
Node API
- Express application
cognify-server/src/app.ts - Domain routes · Serves chat, workflow, and workspace product APIs.
cognify-server/src/routes/chat.routes.ts - Tenant access controls · Authenticates callers and enforces workspace membership or API-key access.
cognify-server/src/middleware/workspaceAccess.middleware.ts - Auth and workspace
cognify-server/src/services/workspace/workspace.service.ts - AI orchestration · Routes chat and agent work to models, agents, and tools.
cognify-server/src/services/ai/aiManager.service.ts - Vector memory and streaming · Retrieves workspace context and streams model output.
cognify-server/src/services/ai/vectorMemory.service.ts - File ingestion · Stores files and parses source material for memory.
cognify-server/src/services/storage/fileParser.service.ts
Async processing
- Workflow engine · Defines triggers and executes workflow steps.
cognify-server/src/services/automation/workflow.service.ts - BullMQ queues · Decouples AI, workflows, usage aggregation, and email work.
cognify-server/src/queues/aiQueue.ts - Queue workers
cognify-server/src/queues/workers/workflow.worker.ts - Usage and notifications
cognify-server/src/services/notification/socket.service.ts
Tenant data
- PostgreSQL tenant record · System of record for tenant data, messages, embeddings, subscriptions, and costs.
cognify-server/prisma/schema.prisma - Redis
cognify-server/src/config/redis.ts
External services
- AI model providers
cognify-server/src/services/ai/providers/base.providers.ts - Billing providers · Subscriptions and webhook processing.
cognify-server/src/services/billing/stripe.service.ts - Collaboration integrations
cognify-server/src/services/integrations/slack.service.ts
Connections 23
- Client bootstrap → Dashboard surfaces: renders
- Dashboard surfaces → API client: calls
- API client → Express application: HTTPS
- Express application → Domain routes: mounts
- Domain routes → Tenant access controls: enforces access
- Tenant access controls → Auth and workspace: authorizes tenant
- Auth and workspace → PostgreSQL tenant record: reads and writes
- Domain routes → AI orchestration: chat and agent requests
- AI orchestration → Vector memory and streaming: retrieves context
- Vector memory and streaming → PostgreSQL tenant record: stores embeddings
- AI orchestration → AI model providers: invokes models
- Domain routes → File ingestion: file requests
- File ingestion → Vector memory and streaming: ingested content
- Domain routes → Workflow engine: workflow requests
- Workflow engine → BullMQ queues: enqueues execution
- AI orchestration → BullMQ queues: enqueues long jobs
- BullMQ queues → Redis: uses
- Queue workers → BullMQ queues: consumes
- Queue workers → Workflow engine: executes
- Queue workers → Usage and notifications: emits updates
- Usage and notifications → PostgreSQL tenant record: records usage
- Domain routes → Billing providers: subscription and webhooks
- Domain routes → Collaboration integrations: connects