Skip to content

Commit 7f846a7

Browse files
committed
refactor: Optimize codebase and improve code quality
- Remove unnecessary console logs - Eliminate unused files and commented code - Prune unnecessary dependencies - Enhance type safety and consistency - Introduce constants to replace hardcoded values - Reorganize and rename types and constants - Improve overall project structure and maintainability
1 parent 50063e1 commit 7f846a7

38 files changed

+147
-3280
lines changed

README.md

481 Bytes

# Turborepo starter This Turborepo starter is maintained by the Turborepo core team. ## Using this example Run the following command: ```sh npx create-turbo@latest ``` ## What's inside? This Turborepo includes the following packages/apps: ### Apps and Packages - `docs`: a [Next.js](https://nextjs.org/) app - `web`: another [Next.js](https://nextjs.org/) app - `@repo/ui`: a stub React component library shared by both `web` and `docs` applications - `@repo/eslint-config`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`) - `@repo/typescript-config`: `tsconfig.json`s used throughout the monorepo Each package/app is 100% [TypeScript](https://www.typescriptlang.org/). ### Utilities This Turborepo has some additional tools already setup for you: - [TypeScript](https://www.typescriptlang.org/) for static type checking - [ESLint](https://eslint.org/) for code linting - [Prettier](https://prettier.io) for code formatting ### Build To build all apps and packages, run the following command: ``` cd my-turborepo pnpm build ``` ### Develop To develop all apps and packages, run the following command: ``` cd my-turborepo pnpm dev ``` ### Remote Caching > [!TIP] > Vercel Remote Cache is free for all plans. Get started today at [vercel.com](https://vercel.com/signup?/signup?utm_source=remote-cache-sdk&utm_campaign=free_remote_cache). Turborepo can use a technique known as [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines. By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can [create one](https://vercel.com/signup?utm_source=turborepo-examples), then enter the following commands: ``` cd my-turborepo npx turbo login ``` This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview). Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo: ``` npx turbo link ``` ## Useful Links Learn more about the power of Turborepo: - [Tasks](https://turbo.build/repo/docs/core-concepts/monorepos/running-tasks) - [Caching](https://turbo.build/repo/docs/core-concepts/caching) - [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) - [Filtering](https://turbo.build/repo/docs/core-concepts/monorepos/filtering) - [Configuration Options](https://turbo.build/repo/docs/reference/configuration) - [CLI Usage](https://turbo.build/repo/docs/reference/command-line-reference) # Collaborative-Excalidraw # Collaborative-Excalidraw # CollabyDraw

CollabyDraw

CollabyDraw is a real-time collaborative drawing application inspired by Excalidraw and a project built by Harkirat Singh Sir in his Cohort 3. While working on the project, I made some modifications and introduced features that make CollabyDraw slightly different from what project built during Cohort and possibly from other students' implementations.

🚀 Features

🎨 Standalone Mode (No Authentication Required)

  • Users can start drawing without signing up or logging in.
  • Offers the same features as collaboration mode, except live room functionality.
  • Data is stored in local storage, ensuring privacy and no dependency on a database.

🎨 Live Collaboration Mode

  • Users can join rooms and collaborate in real-time.
  • Participants are visibly displayed in an interactive UI, similar to Excalidraw.
  • Built-in WebSocket-based syncing for smooth collaboration.

🎨 Next.js Server Actions (No Separate HTTP Services)

  • The cohort project used a separate HTTP service for:
    • Room creation & management
    • User authentication & management
  • CollabyDraw eliminates separate HTTP services by using Next.js server actions, making the architecture cleaner and more efficient.

🎨 Privacy-Focused Architecture

  • Standalone mode does not require a database; it relies on local storage.
  • Planning to fully eliminate database usage in the future, similar to Excalidraw.

🎨 Interactive and Responsive UI

  • Built with a focus on high performance and smooth UX.
  • WebSocket connections are hookified for better state management.
  • The UI is highly interactive and visually appealing, improving the user experience over the cohort project.

🛠️ Tech Stack

  • Frontend: Next.js 15
  • Real-time Sync: WebSockets
  • State Management: React hooks
  • Storage: Local Storage (Standalone Mode), Database (for authentication in Collaboration Mode)

🆚 Differences from Cohort Project

Feature Cohort Project by Harkirath CollabyDraw
Authentication Required Yes No (Standalone Mode)
Local Storage Support No Yes
Database Dependency Yes No (Standalone Mode)
Separate HTTP Services Yes No (Uses Next.js Server Actions)
Live Collaboration UI Basic Interactive UI with participant list
Performance Optimizations Basic Hookified WebSocket connection & responsive UI

🎯 Future Plans

  • Fully eliminate database dependency to enhance privacy.
  • Enhance UI further with better collaboration tools.
  • Improve performance with optimizations in WebSocket handling.

🌍 Open Source & Contributions

I want CollabyDraw to be open source so that other students and developers can explore and learn from it.
If you'd like to contribute—whether it's improving the UI, optimizing performance, or adding new features—feel free to open an issue or submit a pull request!

📜 License

This project is open-source and available under the MIT License.


apps/collabydraw/actions/room.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ export async function getRoom(data: { roomName: string }) {
9696
return { success: false, error: "Room not found" };
9797
}
9898

99-
console.log("room = ", room);
100-
10199
const session = await getServerSession(authOptions);
102100
const cookieToken = session?.accessToken;
103101

apps/collabydraw/app/(canvas)/canvas/[roomName]/page.tsx renamed to apps/collabydraw/app/(canvas)/room/[roomName]/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ export default async function CanvasPage({ params }: { params: Promise<{ roomNam
2020
const user = session?.user;
2121
if (!user || !user.id) {
2222
console.error('User from session not found.');
23-
redirect('/auth/signin?callbackUrl=' + encodeURIComponent(`/canvas/${decodedParam}`));
23+
redirect('/auth/signin?callbackUrl=' + encodeURIComponent(`/room/${decodedParam}`));
2424
}
25-
console.log('CanvasPage loaded')
2625

2726
return (
2827
<CanvasSheet

apps/collabydraw/app/(main)/chat-room/[roomName]/page.tsx

Lines changed: 0 additions & 60 deletions
This file was deleted.

apps/collabydraw/app/(main)/page.tsx

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,4 @@ export default async function Home() {
44
return (
55
<StandaloneCanvas />
66
)
7-
}
8-
// return (
9-
// <>
10-
// <main className="flex-1">
11-
// <section className="space-y-6 pb-8 pt-6 md:pb-12 md:pt-10 lg:py-32">
12-
// <div className="container flex max-w-[64rem] flex-col items-center gap-4 text-center">
13-
// <h1 className="font-heading text-3xl sm:text-5xl md:text-6xl lg:text-7xl">
14-
// Draw Together in Real-time
15-
// </h1>
16-
// <p className="max-w-[42rem] leading-normal text-muted-foreground sm:text-xl sm:leading-8">
17-
// Create, collaborate, and share drawings in real-time. No installation required.
18-
// </p>
19-
// <div className="flex flex-col md:flex-row items-center justify-center gap-3">
20-
// <Link href="/draw">
21-
// <Button size="lg" className="bg-primary text-primary-foreground hover:bg-primary/90">
22-
// Start Drawing
23-
// <Sparkles className="ml-2 h-4 w-4" />
24-
// </Button>
25-
// </Link>
26-
// <Button size="lg" variant="outline" className="border-primary text-primary hover:bg-primary/10">
27-
// Learn More
28-
// </Button>
29-
// </div>
30-
// </div>
31-
// </section>
32-
33-
// <section className="container space-y-6 py-8 md:py-12 lg:py-24">
34-
// <div className="mx-auto grid max-w-5xl gap-8 lg:grid-cols-3">
35-
// {[
36-
// {
37-
// icon: PenLine,
38-
// title: "Easy Drawing Tools",
39-
// description: "Intuitive tools for sketching, diagramming, and illustrating your ideas.",
40-
// },
41-
// {
42-
// icon: Users,
43-
// title: "Real-time Collaboration",
44-
// description: "Work together with your team in real-time, no matter where they are.",
45-
// },
46-
// {
47-
// icon: Share2,
48-
// title: "Easy Sharing",
49-
// description: "Share your drawings with a simple link or export them in various formats.",
50-
// },
51-
// ].map((feature) => (
52-
// <div key={feature.title}
53-
// className="flex flex-col items-center space-y-2 text-center">
54-
// <div className="h-16 w-16 rounded-full bg-primary/20 flex items-center justify-center">
55-
// <feature.icon className="h-8 w-8 text-primary" />
56-
// </div>
57-
// <h3 className="text-xl font-bold">{feature.title}</h3>
58-
// <p className="text-muted-foreground">{feature.description}</p>
59-
// </div>
60-
// ))}
61-
// </div>
62-
// </section>
63-
// </main>
64-
// </>
65-
// )
66-
// }
67-
7+
}

apps/collabydraw/components/ChatRoom.tsx

Lines changed: 0 additions & 223 deletions
This file was deleted.

apps/collabydraw/components/CollaborationStartBtn.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { cn } from "@/lib/utils";
1111
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./ui/tooltip";
1212
import { RoomParticipants } from "@repo/common/types";
1313
import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";
14+
import { BASE_URL } from "@/config/constants";
1415

1516
export default function CollaborationStartBtn({ slug, participants, onCloseRoom }: { slug?: string, participants?: RoomParticipants[], onCloseRoom?: () => void; }) {
1617
const pathname = usePathname();
@@ -87,7 +88,7 @@ export default function CollaborationStartBtn({ slug, participants, onCloseRoom
8788

8889
{session?.user && session?.user.id ? (
8990
roomSlug ? (
90-
<RoomSharingDialog onCloseRoom={onCloseRoom} open={isOpen} onOpenChange={setIsOpen} link={`${process.env.NODE_ENV !== 'production' ? 'http://localhost:3000' : 'https://collabydraw.com'}/${decodedPathname}`} />
91+
<RoomSharingDialog onCloseRoom={onCloseRoom} open={isOpen} onOpenChange={setIsOpen} link={`${BASE_URL}/${decodedPathname}`} />
9192
) : (
9293
<CollaborationStartdDialog open={isOpen} onOpenChange={setIsOpen} />
9394
)

apps/collabydraw/components/CollaborationStartdDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function CollaborationStartdDialog({ open, onOpenChange }: { open
3131
if (result.success) {
3232
toast.success(`Created room: ${data.roomName} with code: ${result.room?.slug}`);
3333
onOpenChange(false);
34-
router.push(`/canvas/${result.room?.slug}`);
34+
router.push(`/room/${result.room?.slug}`);
3535
} else {
3636
toast.error('Error: ' + result.error);
3737
}

0 commit comments

Comments
 (0)