How rohanshrma222/inksync works
Project type and purpose
• This is a TypeScript‐based Turborepo monorepo hosting a full-stack, collaborative canvas application.
• It consists of three “apps”:
• main-frontend – a Next.js React app for the UI (sign-in, sign-up, room selection, drawing canvas).
• http-backend – a Node/Express (or similar) HTTP API for authentication, user management, room metadata, and database interactions.
• ws-backend – a WebSocket server that handles real-time drawing events in each room.
• Shared code lives under packages/ (common types, Prisma DB layer, shared UI, lint/ts configs).
File structure
• Top-level apps/: three deployments
• Each has its own package.json and tsconfig → independent services.
• main-frontend contains Next.js pages under app/ and reusable React components under components/.
• http-backend exposes REST endpoints (src/index.ts, middleware.ts).
• ws-backend exposes WebSocket endpoints (src/index.ts).
• packages/ contains:
• common – shared TypeScript types.
• backend-common – shared server utilities (error handling, middleware).
• db – Prisma schema + migrations + database client.
• ui – shared React UI library.
• eslint-config, typescript-config – repo-wide linting and TS settings.
• docker/ folder with three Dockerfiles → containerization of each app.
• CI/CD pipelines in .github/workflows for each app → separate build/deploy jobs.
README for additional insights
• The generic Turborepo README doesn’t describe this custom canvas app, but confirms the use of Next.js, TypeScript, ESLint, Prettier, and remote caching via Turborepo.
a. Main components:
• User’s Browser (UI)
• Next.js Frontend (main-frontend)
• HTTP API Server (http-backend)
• WebSocket Server (ws-backend)
• Database (PostgreSQL via Prisma in packages/db)
• Shared Libraries (Type definitions, UI components, backend utilities)
• CI/CD Platform (GitHub Actions + Turborepo caching)
• Container Registry / Deployment Platform (e.g., Docker Hub, Kubernetes, Vercel)
b. Relationships and interactions:
• Browser ←→ Next.js Frontend (HTTP + SSR)
• Frontend → HTTP API Server (REST for login, room list, save/load canvas state)
• Frontend ↔ WS Server (WebSocket for real-time drawing events)
• HTTP Server ↔ Database (Prisma ORM for user/room meta)
• WS Server ↔ Database (optionally, for persisting drawing logs)
• Apps share code by importing from packages/
• CI/CD pushes built Docker images from each dockerfile.* to the registry and deploys them.
c. Architectural patterns & design principles:
• Micro-services style: separate deployable units for HTTP and WS
• Monorepo code-sharing via Turborepo & pnpm workspaces
• Layered separation: UI layer, API layer, real-time layer, persistence layer
• Shared type safety (TypeScript across all layers)
d. Key technologies/frameworks:
• Next.js (React, app router)
• Node.js with TypeScript for both backends
• WebSocket (e.g., ws or socket.io)
• Prisma ORM + PostgreSQL
• Turborepo for monorepo task orchestration & caching
• pnpm workspaces
• GitHub Actions for CI/CD
• Docker for containerization