···1651654. Test with `bun run dev`
1661665. See `packages/client/CLAUDE.md` for patterns
167167168168-### Type Sharing Between Packages
168168+### Path Aliases
169169170170-If you need to share types from server to client:
171171-1. Add workspace dependency in `packages/client/package.json`:
172172- ```json
173173- "dependencies": {
174174- "@watproto/server": "workspace:*"
175175- }
176176- ```
177177-2. Import types (not runtime code):
178178- ```typescript
179179- import type { Account } from '@watproto/server/src/db/schema'
180180- ```
170170+The monorepo uses TypeScript path aliases for cleaner imports:
171171+172172+**Configured in `tsconfig.root.json`:**
173173+- `@api/*` → `packages/server/src/*` - Server internal imports
174174+- `@www/*` → `packages/client/app/*` - Client internal imports
175175+176176+**Server Usage** (`packages/server`):
177177+```typescript
178178+import { db } from '@api/db/db'
179179+import env from '@api/lib/env'
180180+import { createOrUpdateAccount } from '@api/lib/account'
181181+```
182182+183183+**Client Usage** (`packages/client`):
184184+```typescript
185185+// Client internal imports
186186+import { Header } from '@www/components/Header'
187187+import { apiClient } from '@www/lib/api'
188188+189189+// Import server types (type-only imports)
190190+import type { app } from '@api/index'
191191+import type { Account } from '@api/db/schema'
192192+```
193193+194194+**Benefits:**
195195+- Clean, consistent import paths across the monorepo
196196+- No relative path traversal (`../../..`)
197197+- Type sharing between packages without workspace dependencies
198198+- Vite and Bun automatically resolve these paths
199199+200200+**Note:** Only import types from server to client, never runtime code.
181201182202## Future Expansion
183203
+47-7
packages/client/CLAUDE.md
···118118}
119119```
120120121121-**Type Sharing** (when needed):
122122-- Can import types from server package via workspace dependencies
123123-- Add to dependencies: `"@watproto/server": "workspace:*"`
124124-- Import: `import type { AccountType } from '@watproto/server/src/db/schema'`
121121+**Type Sharing with Server:**
122122+The client can import server types using the `@api/*` path alias:
123123+124124+```typescript
125125+// Import server types (type-only imports)
126126+import type { app } from '@api/index' // For Eden Treaty type-safe API client
127127+import type { Account } from '@api/db/schema' // Database types
128128+import type { SessionData } from '@api/lib/session' // Session types
129129+130130+// Use in your code
131131+const apiClient = treaty<typeof app>(API_URL) // Type-safe API client
132132+```
133133+134134+**Important:** Only import types from server (`import type`), never runtime code
125135126136### Styling
127137···180190- Access via `import.meta.env.VITE_*`
181191- Never commit `.env.local` to git
182192183183-### TypeScript Configuration
184184-- Path aliases configured in `tsconfig.json`
185185-- Vite handles path resolution via `vite-tsconfig-paths` plugin
193193+### Path Aliases
194194+195195+The client uses path aliases for clean imports:
196196+197197+**Configuration** (in root `tsconfig.root.json`):
198198+- `@www/*` → `packages/client/app/*` - Client internal imports
199199+- `@api/*` → `packages/server/src/*` - Server type imports
200200+201201+**Usage Examples:**
202202+```typescript
203203+// Client internal imports
204204+import { Header } from '@www/components/Header'
205205+import { UserMenu } from '@www/components/UserMenu'
206206+import { apiClient } from '@www/lib/api'
207207+import { env } from '@www/lib/env'
208208+209209+// Server type imports (type-only)
210210+import type { app } from '@api/index'
211211+import type { Account } from '@api/db/schema'
212212+```
213213+214214+**Benefits:**
215215+- Clean, consistent import paths
216216+- No relative path traversal (`../../../components/Header`)
217217+- Type-safe API calls using server types
218218+- Better refactoring support
219219+220220+**Vite Configuration:**
221221+- Uses `vite-tsconfig-paths` plugin to resolve aliases
222222+- Automatically picks up paths from root `tsconfig.root.json`
223223+224224+**TypeScript:**
186225- Type generation via `react-router typegen` command
226226+- Strict mode enabled for better type safety
187227188228### Build & Deployment
189229- Production build outputs to `build/` directory
+22-2
packages/server/CLAUDE.md
···175175## Key Implementation Details
176176177177### Path Aliases
178178-- Use `@/*` imports for `src/*` files (configured in tsconfig.json)
179179-- Use `@/../*` for parent directory access (e.g., `@/../jwks.json`)
178178+179179+The server uses the `@api/*` path alias for clean internal imports:
180180+181181+**Configuration** (in root `tsconfig.root.json`):
182182+- `@api/*` → `packages/server/src/*`
183183+184184+**Usage Examples:**
185185+```typescript
186186+import { db } from '@api/db/db'
187187+import env from '@api/lib/env'
188188+import { createOrUpdateAccount } from '@api/lib/account'
189189+import { type Account } from '@api/db/schema'
190190+import keys from '@api/../jwks.json' // Parent directory access
191191+```
192192+193193+**Benefits:**
194194+- Consistent import paths regardless of file depth
195195+- No relative path hell (`../../../lib/env`)
196196+- Better refactoring support
197197+- Shared with client for type imports
198198+199199+**Note:** Use `@api/../*` for accessing files in the package root (e.g., `jwks.json`)
180200181201### OAuth Security
182202- Cookies are httpOnly, secure, sameSite=lax