···11+# Development Guide for Takes
22+33+## Commands
44+- `bun run dev` - Start development server with watch mode
55+- `bun run db:generate` - Generate database migrations with Drizzle
66+- `bun run db:migrate` - Apply database migrations
77+- `bun run db:studio` - Start Drizzle Studio on port 3001
88+- `npx biome lint .` - Lint codebase
99+- `npx biome format . --write` - Format codebase
1010+1111+## Code Style
1212+- **Formatting**: Use tabs for indentation, double quotes for strings (enforced by Biome)
1313+- **Imports**: Organize imports automatically with Biome
1414+- **Types**: Use TypeScript with strict mode enabled; prefer explicit return types
1515+- **Error Handling**: Use try/catch blocks with specific error types when possible
1616+- **Naming**:
1717+ - camelCase for variables and functions
1818+ - PascalCase for classes and types
1919+ - ALL_CAPS for constants
2020+- **Database**: Use Drizzle ORM with SQLite
2121+- **API**: Use Slack Edge API for bot interactions
2222+- Always do await context.respond and then return rather than returning the function
2323+- Always use Bun APIs when available as they're faster (e.g. `bun.randomUUID7()` instead of `crypto.uuid`)
2424+2525+## Architecture
2626+Slackbot that uses a SQLite database through Drizzle ORM to manage "takes" sessions.
2727+Keep feature implementations in the `src/features` directory and common utilities in `src/libs`.
···11+CREATE TABLE `takes` (
22+ `id` text PRIMARY KEY NOT NULL,
33+ `user_id` text NOT NULL,
44+ `channel_id` text NOT NULL,
55+ `status` text DEFAULT 'active' NOT NULL,
66+ `started_at` integer NOT NULL,
77+ `paused_at` integer,
88+ `completed_at` integer,
99+ `duration_minutes` integer DEFAULT 5 NOT NULL,
1010+ `paused_time_ms` integer DEFAULT 0 NOT NULL,
1111+ `notes` text
1212+);
1313+--> statement-breakpoint
1414+CREATE TABLE `users` (
1515+ `id` text PRIMARY KEY NOT NULL,
1616+ `name` text NOT NULL,
1717+ `is_active` integer DEFAULT true NOT NULL
1818+);
···11+import { drizzle } from "drizzle-orm/bun-sqlite";
22+import { Database } from "bun:sqlite";
33+import * as schema from "./schema";
44+55+// Use environment variable for the database path in production
66+const dbPath = process.env.DATABASE_PATH || "./local.db";
77+88+// Create a SQLite database instance using Bun's built-in driver
99+const sqlite = new Database(dbPath);
1010+1111+// Create a Drizzle instance with the database and schema
1212+export const db = drizzle(sqlite, { schema });
1313+1414+// Export the sqlite instance and schema for use in other files
1515+export { sqlite, schema };