diff --git a/package.json b/package.json
index b090d5c..d6461fe 100644
--- a/package.json
+++ b/package.json
@@ -3,11 +3,11 @@
"type": "module",
"private": true,
"scripts": {
- "dev": "bun --hot src/dev-server.tsx",
+ "dev": "bun --hot src/server/dev-server.tsx",
"build": "rm -rf dist && bun run build:client && bun run build:server && bun run build:mcp",
- "build:client": "bun build --target=browser --production --outdir ./dist/public ./src/index.html",
- "build:server": "mkdir -p ./dist/server && bun build --target=bun --production --outfile ./dist/server/server.js ./src/server.tsx",
- "build:mcp": "mkdir -p ./dist/mcp && bun build --target=bun --production --outfile ./dist/mcp/mcp-server.js ./src/mcp-server.ts",
+ "build:client": "bun build --target=browser --production --outdir ./dist/public ./src/client/index.html",
+ "build:server": "mkdir -p ./dist/server && bun build --target=bun --production --outfile ./dist/server/server.js ./src/server/http-server.tsx",
+ "build:mcp": "mkdir -p ./dist/mcp && bun build --target=bun --production --outfile ./dist/mcp/mcp-server.js ./src/mcp/server.ts",
"start": "DATABASE_PATH=./data/excalidraw.sqlite bun ./dist/server/server.js",
"test": "bun test",
"typecheck": "tsc --noEmit"
diff --git a/src/App.tsx b/src/client/App.tsx
similarity index 90%
rename from src/App.tsx
rename to src/client/App.tsx
index fb56cc2..fc4dac4 100644
--- a/src/App.tsx
+++ b/src/client/App.tsx
@@ -1,8 +1,8 @@
import { useCallback, useEffect, useRef, useState } from "react";
-import { DrawingSidebar, DrawingsToggle } from "./DrawingSidebar";
-import { EditorCanvas } from "./EditorCanvas";
-import { useDrawingSession } from "./useDrawingSession";
-import { useThemeTokenSync } from "./useThemeTokenSync";
+import { DrawingSidebar, DrawingsToggle } from "./components/DrawingSidebar";
+import { EditorCanvas } from "./components/EditorCanvas";
+import { useDrawingSession } from "./hooks/useDrawingSession";
+import { useThemeTokenSync } from "./hooks/useThemeTokenSync";
export function App() {
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
diff --git a/src/DrawingSidebar.tsx b/src/client/components/DrawingSidebar.tsx
similarity index 98%
rename from src/DrawingSidebar.tsx
rename to src/client/components/DrawingSidebar.tsx
index 30bf915..bfab44f 100644
--- a/src/DrawingSidebar.tsx
+++ b/src/client/components/DrawingSidebar.tsx
@@ -1,4 +1,4 @@
-import { type DrawingMeta } from "./shared";
+import { type DrawingMeta } from "../../core/shared";
type DrawingSidebarProps = {
open: boolean;
diff --git a/src/EditorCanvas.tsx b/src/client/components/EditorCanvas.tsx
similarity index 91%
rename from src/EditorCanvas.tsx
rename to src/client/components/EditorCanvas.tsx
index cc561e9..2f4eaf4 100644
--- a/src/EditorCanvas.tsx
+++ b/src/client/components/EditorCanvas.tsx
@@ -1,11 +1,11 @@
-import "../node_modules/@excalidraw/excalidraw/dist/prod/index.css";
+import "../../../node_modules/@excalidraw/excalidraw/dist/prod/index.css";
import { Excalidraw } from "@excalidraw/excalidraw";
import type {
AppState,
BinaryFiles,
ExcalidrawInitialDataState,
} from "@excalidraw/excalidraw/types";
-import { type ScenePayload } from "./shared";
+import { type ScenePayload } from "../../core/shared";
type EditorCanvasProps = {
activeId: string | null;
diff --git a/src/useDrawingSession.ts b/src/client/hooks/useDrawingSession.ts
similarity index 99%
rename from src/useDrawingSession.ts
rename to src/client/hooks/useDrawingSession.ts
index 2ffe9a8..5fa4968 100644
--- a/src/useDrawingSession.ts
+++ b/src/client/hooks/useDrawingSession.ts
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useRef, useState } from "react";
-import { DEFAULT_TITLE, type DrawingMeta, type ScenePayload } from "./shared";
+import { DEFAULT_TITLE, type DrawingMeta, type ScenePayload } from "../../core/shared";
type DrawingResponse = DrawingMeta & ScenePayload;
type ApiErrorBody = { ok: false; error?: string; drawing?: DrawingMeta };
diff --git a/src/useThemeTokenSync.ts b/src/client/hooks/useThemeTokenSync.ts
similarity index 100%
rename from src/useThemeTokenSync.ts
rename to src/client/hooks/useThemeTokenSync.ts
diff --git a/src/index.html b/src/client/index.html
similarity index 84%
rename from src/index.html
rename to src/client/index.html
index 0d8128e..5be76f5 100644
--- a/src/index.html
+++ b/src/client/index.html
@@ -6,7 +6,7 @@
excali-box
-
+
diff --git a/src/client.tsx b/src/client/main.tsx
similarity index 100%
rename from src/client.tsx
rename to src/client/main.tsx
diff --git a/src/styles.css b/src/client/styles.css
similarity index 100%
rename from src/styles.css
rename to src/client/styles.css
diff --git a/src/scene.test.ts b/src/core/scene.test.ts
similarity index 100%
rename from src/scene.test.ts
rename to src/core/scene.test.ts
diff --git a/src/scene.ts b/src/core/scene.ts
similarity index 100%
rename from src/scene.ts
rename to src/core/scene.ts
diff --git a/src/shared.ts b/src/core/shared.ts
similarity index 100%
rename from src/shared.ts
rename to src/core/shared.ts
diff --git a/src/mcp-server.test.ts b/src/mcp/server.test.ts
similarity index 95%
rename from src/mcp-server.test.ts
rename to src/mcp/server.test.ts
index 5b087b4..7fcb07c 100644
--- a/src/mcp-server.test.ts
+++ b/src/mcp/server.test.ts
@@ -2,9 +2,9 @@ import { afterEach, describe, expect, test } from "bun:test";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
-import { createDrawingStore, type DrawingStore } from "./db";
-import { createMcpToolHandlers, resolvePublicBaseUrl } from "./mcp-server";
-import { type ScenePayload } from "./shared";
+import { type ScenePayload } from "../core/shared";
+import { createDrawingStore, type DrawingStore } from "../server/db";
+import { createMcpToolHandlers, resolvePublicBaseUrl } from "./server";
const cleanup: Array<{ dir: string; store: DrawingStore }> = [];
diff --git a/src/mcp-server.ts b/src/mcp/server.ts
similarity index 97%
rename from src/mcp-server.ts
rename to src/mcp/server.ts
index dc020f0..3c44768 100644
--- a/src/mcp-server.ts
+++ b/src/mcp/server.ts
@@ -1,9 +1,9 @@
import { applyPatch, type Operation } from "fast-json-patch";
import { createMcpHandler } from "mcp-handler";
import { z } from "zod";
-import { createDrawingStore, type DrawingStore } from "./db";
-import { normalizeScene, normalizeTitle } from "./scene";
-import { type ScenePayload } from "./shared";
+import { normalizeScene, normalizeTitle } from "../core/scene";
+import { type ScenePayload } from "../core/shared";
+import { createDrawingStore, type DrawingStore } from "../server/db";
const sceneSchema = z.object({
elements: z.array(z.unknown()),
diff --git a/src/api.test.ts b/src/server/api.test.ts
similarity index 100%
rename from src/api.test.ts
rename to src/server/api.test.ts
diff --git a/src/api.ts b/src/server/api.ts
similarity index 98%
rename from src/api.ts
rename to src/server/api.ts
index f1508b6..35a6768 100644
--- a/src/api.ts
+++ b/src/server/api.ts
@@ -1,6 +1,6 @@
import { type DrawingStore } from "./db";
-import { type DrawingMeta } from "./shared";
-import { HttpError, normalizeTitle, parseJsonBody, parseSceneText } from "./scene";
+import { type DrawingMeta } from "../core/shared";
+import { HttpError, normalizeTitle, parseJsonBody, parseSceneText } from "../core/scene";
type RouteRequest = Request & {
params?: Record;
diff --git a/src/db.test.ts b/src/server/db.test.ts
similarity index 100%
rename from src/db.test.ts
rename to src/server/db.test.ts
diff --git a/src/db.ts b/src/server/db.ts
similarity index 98%
rename from src/db.ts
rename to src/server/db.ts
index adf2601..a921ae8 100644
--- a/src/db.ts
+++ b/src/server/db.ts
@@ -2,8 +2,8 @@ import { Database } from "bun:sqlite";
import { randomUUID } from "node:crypto";
import { mkdirSync } from "node:fs";
import { dirname } from "node:path";
-import { DEFAULT_TITLE, type DrawingMeta, type DrawingRecord, type ScenePayload } from "./shared";
-import { emptyScene, normalizeScene, normalizeTitle } from "./scene";
+import { DEFAULT_TITLE, type DrawingMeta, type DrawingRecord, type ScenePayload } from "../core/shared";
+import { emptyScene, normalizeScene, normalizeTitle } from "../core/scene";
type DrawingRow = {
id: string;
diff --git a/src/dev-server.tsx b/src/server/dev-server.tsx
similarity index 80%
rename from src/dev-server.tsx
rename to src/server/dev-server.tsx
index 942a942..3f053c8 100644
--- a/src/dev-server.tsx
+++ b/src/server/dev-server.tsx
@@ -1,5 +1,5 @@
-import index from "./index.html";
-import { createServer } from "./server";
+import index from "../client/index.html";
+import { createServer } from "./http-server";
export function createDevServer() {
const server = createServer();
diff --git a/src/server.test.ts b/src/server/http-server.test.ts
similarity index 97%
rename from src/server.test.ts
rename to src/server/http-server.test.ts
index b00a27e..08cff3c 100644
--- a/src/server.test.ts
+++ b/src/server/http-server.test.ts
@@ -3,7 +3,7 @@ import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { createDrawingStore, type DrawingStore } from "./db";
-import { createServer } from "./server";
+import { createServer } from "./http-server";
const cleanup: string[] = [];
const stores: DrawingStore[] = [];
diff --git a/src/server.tsx b/src/server/http-server.tsx
similarity index 100%
rename from src/server.tsx
rename to src/server/http-server.tsx