Skip to content
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
2a3b4a3
feat: Implement Nano ID generation utilities with createNanoId and cr…
ahargunyllib Apr 1, 2026
61be1ad
feat: Add initial database setup with todo schema and queries
ahargunyllib Apr 1, 2026
aed4080
feat: Implement core package with Todo service, types, and configuration
ahargunyllib Apr 1, 2026
7679995
feat: Enhance API with TRPC integration, Todo service, and database s…
ahargunyllib Apr 1, 2026
00fe3bf
chore: update dependencies in pnpm-workspace.yaml
ahargunyllib Apr 1, 2026
2665879
feat: Update worker configuration to use dynamic name and conditional…
ahargunyllib Apr 1, 2026
af9b16a
feat: Add react.json configuration for TypeScript with JSX support
ahargunyllib Apr 1, 2026
ab1b2cf
feat(dashboard): initialize dashboard application with routing and de…
ahargunyllib Apr 1, 2026
1101a89
feat: Update TypeScript configuration to include ESNext library support
ahargunyllib Apr 1, 2026
3f02b49
feat: add UI components and utilities
ahargunyllib Apr 1, 2026
2f1f15a
feat: update package dependencies and integrate TooltipProvider in ma…
ahargunyllib Apr 1, 2026
7c32703
chore: update pnpm workspace dependencies and add Tailwind CSS support
ahargunyllib Apr 1, 2026
c8329c7
feat: add typecheck script to package.json files across multiple pack…
ahargunyllib Apr 1, 2026
1db9f24
feat: add robots.txt to restrict web crawler access
ahargunyllib Apr 2, 2026
ea6a5dd
feat: implement ThemeProvider component and update theme handling in …
ahargunyllib Apr 2, 2026
cb814c5
feat: update API to use @hono/trpc-server and refine CORS settings
ahargunyllib Apr 2, 2026
9eab011
feat: remove description field from createTodo and updateTodo procedures
ahargunyllib Apr 2, 2026
683df83
feat: export TRPCRouter type alongside trpcRouter from routers
ahargunyllib Apr 2, 2026
f7450cb
feat: refactor context to create database instance before todo queries
ahargunyllib Apr 2, 2026
9d6573d
feat: implement todo management features with create, delete, and tog…
ahargunyllib Apr 2, 2026
ff24e42
fix: update zod version specification in pnpm-lock and pnpm-workspace…
ahargunyllib Apr 2, 2026
62fdc2c
feat: enhance todo toggle functionality with error handling and query…
ahargunyllib Apr 2, 2026
7a2e274
feat: implement error handling in todo service and add AppError class…
ahargunyllib Apr 2, 2026
c85c665
feat: add logger package with Logger class and type definitions
ahargunyllib Apr 2, 2026
41c804d
feat: integrate logger into context and TRPC procedures for enhanced …
ahargunyllib Apr 2, 2026
7df587f
feat: add logger integration and request ID generation in TRPC context
ahargunyllib Apr 2, 2026
91de69c
feat: add logger and utils package links in pnpm-lock.yaml
ahargunyllib Apr 2, 2026
f7ef021
feat: update TypeScript configuration by refining base.json and remov…
ahargunyllib Apr 2, 2026
60d44b9
feat: update TypeScript configuration for logger package to use ES202…
ahargunyllib Apr 2, 2026
1410b20
feat: update database name to include application stage in alchemy.ru…
ahargunyllib Apr 2, 2026
bcdfee9
feat: add GitHub Actions workflow for dashboard deployment and cleanup
ahargunyllib Apr 2, 2026
6b2e7c8
feat: remove requestId from logging context in TRPC baseProcedure
ahargunyllib Apr 2, 2026
b149c76
feat: update CORS configuration to allow multiple origins
ahargunyllib Apr 2, 2026
e781f0a
feat: add @realm/utils dependency and refactor useIsCompleteToggle to…
ahargunyllib Apr 2, 2026
c04155e
feat: add @realm/types package with Todo type and update imports in core
ahargunyllib Apr 3, 2026
c923b3b
feat: add @realm/kv package with KV and Todo operations, including ty…
ahargunyllib Apr 3, 2026
ced3acf
feat: add TODO comment for improving CORS handling in the future
ahargunyllib Apr 3, 2026
7fd839c
feat: implement todo key management and enhance TodoOperations with g…
ahargunyllib Apr 3, 2026
c9a80ea
feat: update updateTodo method to return SelectTodo or null on failure
ahargunyllib Apr 3, 2026
451fbb4
feat: add BaseContext type definition for context management
ahargunyllib Apr 3, 2026
976224c
feat: enhance BaseContext type definition with detailed waitUntil doc…
ahargunyllib Apr 3, 2026
6035bf4
feat: refactor TodoService to integrate TodoOperations and enhance ge…
ahargunyllib Apr 3, 2026
626aae9
feat: enhance context management by integrating KVNamespaceType and a…
ahargunyllib Apr 3, 2026
5c7e40e
feat: integrate KVNamespace for enhanced state management in alchemy.…
ahargunyllib Apr 3, 2026
196fa79
feat: add '@realm/kv' dependency and update related package versions …
ahargunyllib Apr 3, 2026
dd9c569
feat: improve KVSetOptions documentation and remove default expiratio…
ahargunyllib Apr 3, 2026
86cdfa7
feat: update getAllTodo return type to allow null values
ahargunyllib Apr 3, 2026
15e8c39
feat: update concurrency group names in deployment workflows for cons…
ahargunyllib Apr 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,6 @@ $RECYCLE.BIN/

# Alchemy
*.alchemy

# Tanstack
*.tanstack
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,14 @@
},
"[graphql]": {
"editor.defaultFormatter": "biomejs.biome"
},
"files.readonlyInclude": {
"**/routeTree.gen.ts": true
},
"files.watcherExclude": {
"**/routeTree.gen.ts": true
},
"search.exclude": {
"**/routeTree.gen.ts": true
}
}
22 changes: 16 additions & 6 deletions apps/api/alchemy.run.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import alchemy from "alchemy";
import { Worker } from "alchemy/cloudflare";
import { D1Database, Worker } from "alchemy/cloudflare";
import { GitHubComment } from "alchemy/github";
import { CloudflareStateStore } from "alchemy/state";

Expand All @@ -14,12 +14,22 @@ const app = await alchemy("realm-api", {
password: process.env.ALCHEMY_PASSWORD,
});

const db = await D1Database("db", {
name: "realm-db",
migrationsDir: "./node_modules/@realm/db/migrations",
});

export const worker = await Worker("api", {
name: "realm-api",
name: `realm-api-${app.stage}`,
entrypoint: "./src/index.ts",
url: true,
adopt: true,
bindings: {},
compatibilityDate: "2026-04-01",
compatibilityFlags: ["nodejs_compat"],
bindings: {
DB: db,
},
bundle: {
external: ["bun:sqlite", "@libsql/client"],
},
observability: {
enabled: true,
logs: {
Expand All @@ -34,7 +44,7 @@ export const worker = await Worker("api", {
persist: true,
},
},
domains: ["api.ahargunyllib.dev"],
domains: app.stage === "prod" ? ["api.ahargunyllib.dev"] : undefined,
dev: {
port: 3000,
},
Expand Down
5 changes: 5 additions & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
"dev": "alchemy dev --app realm-api"
},
"dependencies": {
"@hono/trpc-server": "^0.4.2",
"@realm/api": "workspace:*",
"@realm/db": "workspace:*",
"@realm/logger": "workspace:*",
"@realm/utils": "workspace:*",
"alchemy": "catalog:",
"hono": "^4.7.9"
},
Expand Down
3 changes: 0 additions & 3 deletions apps/api/src/env.ts

This file was deleted.

48 changes: 46 additions & 2 deletions apps/api/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,52 @@
import { trpcServer } from "@hono/trpc-server";
import { createContext, trpcRouter } from "@realm/api";
import type { D1Database } from "@realm/db";
import { createLogger } from "@realm/logger";
import { createNanoId } from "@realm/utils";
import { Hono } from "hono";
import { cors } from "hono/cors";
import { logger } from "hono/logger";

const app = new Hono();
const app = new Hono<{
Bindings: {
DB: D1Database;
};
}>();

app.use(logger());
app.use(
"/*",
cors({
origin: "http://localhost:5173",
allowMethods: ["GET", "POST", "OPTIONS"],
allowHeaders: ["Content-Type", "Authorization", "trpc-accept"],
credentials: true,
})
);

app.get("/", (c) => c.text("Hello World"));
app.get("/health", (c) => c.json({ status: "ok" }));

export default app;
app.use(
"/trpc/*",
trpcServer({
router: trpcRouter,
createContext: (opts, c) => {
const requestId = createNanoId();
const customLogger = createLogger({ requestId });

return createContext({
env: {
db: c.env.DB,
},
fetchCreateContextFnOptions: opts,
logger: customLogger,
requestId,
});
},
})
);

export default {
fetch: app.fetch,
};
3 changes: 3 additions & 0 deletions apps/dashboard/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# openssl rand -base64 32
ALCHEMY_STATE_TOKEN=your-generated-token-here
ALCHEMY_PASSWORD=your-generated-password-here
42 changes: 42 additions & 0 deletions apps/dashboard/alchemy.run.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import alchemy from "alchemy";
import { Vite } from "alchemy/cloudflare";
import { GitHubComment } from "alchemy/github";
import { CloudflareStateStore } from "alchemy/state";

const app = await alchemy("realm-dashboard", {
stateStore:
process.env.NODE_ENV === "production"
? (scope) =>
new CloudflareStateStore(scope, {
scriptName: "realm-api-state-store",
})
: undefined, // Uses default FileSystemStateStore
password: process.env.ALCHEMY_PASSWORD,
});

const worker = await Vite("dashboard", {
name: `realm-dashboard-${app.stage}`,
bindings: {
VITE_PUBLIC_API_URL: process.env.API_URL || "http://localhost:3000",
},
domains: app.stage === "prod" ? ["dash.ahargunyllib.dev"] : undefined,
});

if (process.env.PULL_REQUEST) {
// if this is a PR, add a comment to the PR with the preview URL
// it will auto-update with each push
await GitHubComment("preview-comment", {
owner: "ahargunyllib",
repository: "realm",
issueNumber: Number(process.env.PULL_REQUEST),
body: `### Preview Deployment

**Commit:** \`${process.env.GITHUB_SHA}\`
**Preview URL:** ${worker.url}
**Deployed at:** ${new Date().toUTCString()}`,
});
}

console.log(`Dashboard deployed at: ${worker.url}`);

await app.finalize();
13 changes: 13 additions & 0 deletions apps/dashboard/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Realm Dashboard</title>
</head>

<body>
<div id="root"></div>
<script type="module" async src="/src/main.tsx"></script>
</body>
</html>
39 changes: 39 additions & 0 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "dashboard",
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "alchemy dev --app realm-dashboard",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@realm/api": "workspace:*",
"@realm/ui": "workspace:*",
"@tailwindcss/vite": "catalog:",
"@tanstack/react-form": "^1.28.6",
"@tanstack/react-query": "^5.96.1",
"@tanstack/react-router": "^1.168.10",
"@tanstack/react-router-devtools": "^1.166.11",
"@trpc/client": "catalog:",
"@trpc/tanstack-react-query": "^11.16.0",
"alchemy": "catalog:",
"lucide-react": "^1.7.0",
"react": "catalog:",
"react-dom": "catalog:",
"sonner": "^2.0.7",
"superjson": "^2.2.6",
"tailwindcss": "catalog:",
"zod": "catalog:"
},
"devDependencies": {
"@realm/tsconfig": "workspace:*",
"@tanstack/devtools-vite": "^0.6.0",
"@tanstack/router-plugin": "^1.167.12",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"@vitejs/plugin-react": "^6.0.1",
"typescript": "catalog:",
"vite": "^8.0.3",
"vite-tsconfig-paths": "^6.1.1"
}
}
2 changes: 2 additions & 0 deletions apps/dashboard/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Disallow: /
61 changes: 61 additions & 0 deletions apps/dashboard/src/features/todo/components/create-todo-form.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Button } from "@realm/ui/components/button";
import { Field, FieldError, FieldGroup } from "@realm/ui/components/field";
import { Input } from "@realm/ui/components/input";
import { LoaderCircleIcon, PlusIcon } from "lucide-react";
import { useCreateTodoForm } from "../hooks/use-create-todo-form";

export function CreateTodoForm() {
const { form } = useCreateTodoForm();

return (
<form
className="flex flex-row gap-2"
id="create-todo-form"
onSubmit={(e) => {
e.preventDefault();
form.handleSubmit(e);
}}
>
<FieldGroup>
<form.Field name="title">
{(field) => {
const isInvalid =
field.state.meta.isTouched && !field.state.meta.isValid;

return (
<Field data-invalid={isInvalid}>
<Input
aria-invalid={isInvalid}
autoComplete="off"
id={field.name}
name={field.name}
onBlur={field.handleBlur}
onChange={(e) => field.handleChange(e.target.value)}
placeholder="New todo"
value={field.state.value}
/>
{isInvalid && <FieldError errors={field.state.meta.errors} />}
</Field>
);
}}
</form.Field>
</FieldGroup>
<form.Subscribe>
{({ isSubmitting }) => (
<Button
disabled={isSubmitting}
size="icon"
type="submit"
variant="outline"
>
{isSubmitting ? (
<LoaderCircleIcon className="animate-spin" />
) : (
<PlusIcon />
)}
</Button>
)}
</form.Subscribe>
</form>
);
}
87 changes: 87 additions & 0 deletions apps/dashboard/src/features/todo/components/todo-card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { Button } from "@realm/ui/components/button";
import {
Card,
CardContent,
CardFooter,
CardHeader,
CardTitle,
} from "@realm/ui/components/card";
import { Checkbox } from "@realm/ui/components/checkbox";
import { Label } from "@realm/ui/components/label";
import { LoaderCircleIcon, TrashIcon } from "lucide-react";
import { useDeleteTodoForm } from "../hooks/use-delete-todo-form";
import { useIsCompleteToggle } from "../hooks/use-is-complete-toggle";

type Props = {
todo: {
id: string;
title: string;
isCompleted: boolean;
createdAt: string;
updatedAt: string;
};
};

export function TodoCard({ todo }: Props) {
const { toggle, isCompleted } = useIsCompleteToggle({ todo });
const { onDelete, isDeleting } = useDeleteTodoForm({ id: todo.id });

const formattedDate = new Date(todo.createdAt).toLocaleDateString("en-US", {
month: "short",
day: "numeric",
year: "numeric",
hour: "2-digit",
minute: "2-digit",
});

return (
<Card>
<CardHeader>
<CardTitle>
<span className={todo.isCompleted ? "line-through opacity-60" : ""}>
{todo.title}
</span>
</CardTitle>
</CardHeader>
<CardContent>
<div className="flex flex-col gap-2">
<div className="flex items-center gap-2">
<Checkbox
checked={isCompleted}
id="isCompleted"
name="isCompleted"
onCheckedChange={() => {
toggle();
}}
/>
<Label
className="text-muted-foreground text-xs"
htmlFor="isCompleted"
>
{isCompleted ? "Completed" : "Mark as complete"}
</Label>
</div>
<p className="text-muted-foreground text-xs">
Created: {formattedDate}
</p>
</div>
</CardContent>
<CardFooter className="justify-end">
<Button
disabled={isDeleting}
onClick={onDelete}
size="sm"
type="button"
variant="destructive"
>
{isDeleting ? (
<LoaderCircleIcon className="size-4 animate-spin" />
) : (
<TrashIcon className="size-4" />
)}
Delete
</Button>
</CardFooter>
</Card>
);
}
Loading
Loading