How anugrah-singh/coordra works
Purpose and Entry Points
Coordra is a multi-tenant project/workspace coordination system with live collaboration and an approval-gated AI assistant (“Pulse”). The backend starts through src/server.ts, composing the Express API in src/app.ts and Socket.IO in src/socket.ts. The browser application is a Next.js App Router frontend rooted at frontend/src/app/layout.tsx and frontend/src/app/page.tsx.
API Boundary and Request Pipeline
Express exposes versioned/domain-organized HTTP endpoints through src/domains/api.ts. Each domain separates transport from business logic: routes parse requests and services enforce domain behavior, e.g. src/domains/workspaces/route.ts, src/domains/workspaces/service.ts, and src/domains/tasks/service.ts. Cross-cutting middleware establishes the security and API boundary: authentication, CSRF, validation, RBAC, rate limiting, normalized envelopes, and error handling under src/middlewares/.
Identity, Tenancy, and Collaboration
Workspace membership and roles are the central authorization model. Authentication is implemented in src/domains/auth/service.ts; authorization gates are src/middlewares/auth.middleware.ts and src/middlewares/rbac.middleware.ts. Workspace ownership, members, invitations, audit events, and notifications are persisted through schemas including src/db/schema/workspaces.ts, src/db/schema/invites.ts, and src/db/schema/auditLogs.ts. Invitation deep links enter through frontend/src/app/invite/[token]/page.tsx.
Project Delivery Domain
Work is organized as workspace → projects → task boards, with task comments, labels, assignments, dates, and status movement. Backend write/read services are concentrated in src/domains/projects/service.ts, src/domains/tasks/service.ts, and src/domains/comments/service.ts. The primary UI surfaces are workspace/project routes such as frontend/src/app/app/workspaces/[workspaceId]/projects/[projectId]/page.tsx, rendered by frontend/src/features/projects/ProjectBoardPage.tsx and frontend/src/features/projects/KanbanBoard.tsx.
Real-Time Consistency and Audit Flow
Socket.IO uses workspace-scoped rooms to broadcast relevant changes after backend mutations; the server boundary is src/socket.ts, with shared event definitions in src/utils/socketEvents.ts. The frontend subscribes at frontend/src/features/collaboration/useWorkspaceSocket.ts, then invalidates/refetches API-backed state rather than treating socket payloads as authoritative. Backend transactional mutation paths are responsible for associated audit history and live emission.
Pulse AI: Verified Reads, Proposed Writes
Pulse is a workspace-scoped assistant whose model access is mediated by deterministic tools and resolution logic, not raw database access. The AI layer is src/ai/provider.ts, src/ai/tools.ts, and src/ai/risks.ts; its HTTP/domain orchestration is src/domains/assistant/service.ts. It derives risks from verified tenant-scoped data, generates expiring pending action proposals, and requires an explicit, role-checked approval to execute a mutation. Proposal persistence is defined in src/db/schema/aiActionProposals.ts; the interactive client is frontend/src/features/assistant/PulseDrawer.tsx.
Persistence, Runtime, and Deployment
The Node.js/TypeScript API uses PostgreSQL through Drizzle (src/db/index.ts, src/db/schema/index.ts), with committed SQL migrations in drizzle/. The frontend is Next.js/React with Tailwind and is configured for Vercel in frontend/vercel.json; backend deployment configuration is render.yaml. External services are PostgreSQL/Neon-compatible database hosting, Groq through the Vercel AI SDK, and Socket.IO WebSockets. OpenAPI/Swagger documentation is mounted from src/docs/openapi.ts.
Main entry points: api.ts Domain API routes · index.ts PostgreSQL via Drizzle · app.ts Express API app · service.ts Assistant orchestration
Components 20
Node API
Express and Socket.IO runtime.
- Server bootstrap
src/server.ts - Express API app
src/app.ts - Domain API routes
src/domains/api.ts - Auth and RBAC gates · Authentication, CSRF, validation, roles, and API protections.
src/middlewares/auth.middleware.ts - Identity service
src/domains/auth/service.ts - Workspace Socket.IO · Broadcasts workspace-scoped mutation events.
src/socket.ts - OpenAPI docs
src/docs/openapi.ts
Next.js client
Browser workspace application.
- Next.js app shell
frontend/src/app/layout.tsx - Project board · Workspace project and Kanban experience.
frontend/src/features/projects/ProjectBoardPage.tsx - Workspace socket client · Invalidates and refetches API state after events.
frontend/src/features/collaboration/useWorkspaceSocket.ts - Pulse drawer
frontend/src/features/assistant/PulseDrawer.tsx - Invitation deep link
frontend/src/app/invite/[token]/page.tsx
Delivery domain
Projects, tasks, and comments.
- Workspace membership · Owns memberships, roles, and invitations.
src/domains/workspaces/service.ts - Projects service
src/domains/projects/service.ts - Tasks service · Transactional task mutations create audit history and live events.
src/domains/tasks/service.ts - Comments service
src/domains/comments/service.ts
Pulse AI
Verified reads and approval-gated writes.
- Assistant orchestration · Creates proposals and executes only approved actions.
src/domains/assistant/service.ts - Verified AI tools · Resolves tenant-scoped data without raw model database access.
src/ai/tools.ts
Persistence
Tenant-scoped PostgreSQL storage.
- PostgreSQL via Drizzle · Schemas cover workspaces, invites, audit logs, and AI proposals.
src/db/index.ts - SQL migrations
Connections 27
- Server bootstrap → Express API app: starts
- Server bootstrap → Workspace Socket.IO: hosts
- Express API app → Domain API routes: mounts
- Express API app → Auth and RBAC gates: applies
- Domain API routes → Identity service: identity requests
- Domain API routes → Workspace membership: workspace requests
- Domain API routes → Projects service: project requests
- Domain API routes → Tasks service: task requests
- Domain API routes → Comments service: comment requests
- Domain API routes → Assistant orchestration: Pulse requests
- Express API app → OpenAPI docs: mounts
- Auth and RBAC gates → Workspace membership: authorizes by membership
- Workspace membership → PostgreSQL via Drizzle: persists tenancy
- Projects service → PostgreSQL via Drizzle: persists
- Tasks service → PostgreSQL via Drizzle: persists and audits
- Comments service → PostgreSQL via Drizzle: persists
- Tasks service → Workspace Socket.IO: emits mutations
- Assistant orchestration → Verified AI tools: uses verified reads
- Assistant orchestration → PostgreSQL via Drizzle: stores proposals
- Assistant orchestration → Tasks service: executes approved actions
- SQL migrations → PostgreSQL via Drizzle: evolves schema
- Next.js app shell → Project board: renders
- Next.js app shell → Invitation deep link: routes to
- Project board → Domain API routes: reads and mutates
- Workspace socket client → Workspace Socket.IO: subscribes to rooms
- Workspace socket client → Domain API routes: refetches state
- Pulse drawer → Domain API routes: submits and approves proposals