Skip to content

Commit 3dc5983

Browse files
aster-voidclaude
andauthored
feat: file upload (#5)
Co-authored-by: Claude <[email protected]>
1 parent 287549b commit 3dc5983

23 files changed

+1371
-146
lines changed

CLAUDE.md

Lines changed: 68 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -22,75 +22,6 @@ This is a TypeScript monorepo using a Convex backend and SvelteKit frontend with
2222
- `packages/client/` - SvelteKit frontend with Tauri integration
2323
- `packages/convex/` - Convex backend with database schema and functions
2424

25-
## Development Commands
26-
27-
### Setup
28-
29-
```bash
30-
bun install --frozen-lockfile
31-
```
32-
33-
### Development Servers
34-
35-
```bash
36-
# Main development (Convex + Web Client)
37-
bun dev
38-
39-
# All development servers including Storybook
40-
bun dev:all
41-
42-
# Individual servers
43-
bun dev:web # Web client at http://localhost:5173
44-
bun dev:convex # Convex at http://localhost:3210, Dashboard at http://localhost:6790
45-
bun dev:storybook # Storybook at http://localhost:6006
46-
bun dev:tauri # Desktop app (conflicts with web client)
47-
```
48-
49-
### Building and Testing
50-
51-
```bash
52-
# Build all apps
53-
bun run --filter=* build
54-
55-
# Run tests
56-
bun test
57-
58-
# Type checking and linting
59-
bun check # Runs lint + format + all app checks
60-
bun check:lint # Biome linting only
61-
bun check:format # Prettier formatting check only
62-
63-
# Auto-fix
64-
bun fix # Auto-fix lint + format issues
65-
bun fix:lint # Biome auto-fix
66-
bun fix:format # Prettier auto-format
67-
```
68-
69-
### Convex Operations
70-
71-
```bash
72-
# Convex CLI commands
73-
bun convex [command]
74-
75-
# Code generation (run after schema changes)
76-
bun sync
77-
```
78-
79-
### Internationalization
80-
81-
```bash
82-
# Compile i18n messages
83-
bun paraglide
84-
```
85-
86-
## Code Architecture
87-
88-
### Svelte Documentation
89-
90-
When working with Svelte code, always reference the latest documentation:
91-
92-
- **Latest Svelte Docs**: https://svelte.dev/llms-small.txt
93-
9425
### Frontend (SvelteKit)
9526

9627
- **Routes**: Standard SvelteKit routing in `packages/client/src/routes/`
@@ -100,9 +31,33 @@ When working with Svelte code, always reference the latest documentation:
10031
- `@@``../..` (workspace root)
10132
- `$components``src/components`
10233
- `~``src/`
34+
- `@packages/{package}` → monorepo
10335
- **Convex Integration**: Uses `convex-svelte` for reactive queries
10436
- **State Pattern**: Logic components (e.g., TaskList.svelte) separate from presentation (TaskListSkin.svelte)
10537

38+
### Backend (Convex)
39+
40+
- **Schema**: Defined in `packages/convex/src/convex/schema.ts`
41+
- **Functions**: Database operations in `packages/convex/src/convex/[feature].ts`
42+
- **Type Safety**: Auto-generated types from schema shared with frontend via workspace dependency
43+
44+
### Data Flow
45+
46+
1. Convex schema defines database structure
47+
2. Convex functions provide type-safe CRUD operations
48+
3. Frontend uses `convex-svelte` hooks for reactive data
49+
4. Automatic type generation ensures type safety across stack
50+
51+
## Framework - Convex
52+
53+
### Convex の Import について
54+
55+
```ts
56+
import { api, type Id } from "@packages/convex";
57+
58+
// use api and type Id ...
59+
```
60+
10661
### 注意点: convex-svelte の `useQuery` について
10762

10863
`useQuery` に渡す引数は、関数の形式で渡してください。そうでないと、期待しない動作を引き起こす可能性があります。
@@ -141,60 +96,61 @@ createOrganization.processing; // boolean, use for button disabled state / loadi
14196
createOrganization.error; // string | null, use for error messages
14297
```
14398

144-
### Backend (Convex)
145-
146-
- **Schema**: Defined in `packages/convex/src/convex/schema.ts`
147-
- **Functions**: Database operations in `packages/convex/src/convex/[feature].ts`
148-
- **Type Safety**: Auto-generated types from schema shared with frontend via workspace dependency
149-
150-
### Data Flow
99+
## Framework - Svelte
151100

152-
1. Convex schema defines database structure
153-
2. Convex functions provide type-safe CRUD operations
154-
3. Frontend uses `convex-svelte` hooks for reactive data
155-
4. Automatic type generation ensures type safety across stack
101+
### Syntax
156102

157-
## Code Quality
103+
Never use logacy svelte syntax. This project uses Svelte 5 runes mode.
158104

159-
### Linting and Formatting
105+
- ❌ FORBIDDEN: `$: reactiveVar = ...` (reactive statements)
106+
- ❌ FORBIDDEN: `let count = 0` for reactive state
107+
- ✅ REQUIRED: `let count = $state(0)` for reactive state
108+
- ✅ REQUIRED: `$effect(() => { ... })` for side effects
109+
- ✅ REQUIRED: `const sum = $derived(a + b);` for derived variables
110+
- ✅ REQUIRED: `const sum = $derived.by(() => { if (a + b < 0) return 0; return a + b; );` for derived variables which needs a block.
160111

161-
- **Biome**: Primary linter with strict rules
162-
- **Prettier**: Code formatting (Biome formatter disabled)
163-
- **Lefthook**: Pre-commit hooks for code generation and formatting
112+
### Svelte Capabilities
164113

165-
### Special Biome Rules
114+
- clsx: Svelte has clsx builtin to its class. `<div class={["text-lg", isError && "text-error"]}>{text}</div>`
166115

167-
- Svelte files have relaxed rules for unused variables/imports
168-
- Convex files exempt from import extension requirements
169-
- Strict style rules including parameter assignment, const assertions
116+
- reactive class: Svelte allows defining reactive controller classes inside ".svelte.ts" files for reusability and separation of concerns.
170117

171-
### Pre-commit Hooks
172-
173-
- Automatic code generation (`bun sync`)
174-
- Automatic formatting (`bun fix:format`)
118+
```ts
119+
// my-controller.svelte.ts
120+
class MyController {
121+
foo = $state(3);
122+
bar: number;
123+
baz = $derived.by(() => bar + baz); // use derived.by if it needs to be lazy-initialized
124+
doubleQux: number;
125+
// unless it doesn't change at runtime (e.g. static configuration - initBar in this example),
126+
// using getter function is better for reactivity.
127+
constructor(initBar: number, props: () => { qux: number }) {
128+
this.bar = $state(initBar);
129+
this.doubleQux = $derived(props().qux * 2);
130+
}
131+
}
132+
```
175133

176-
## Tauri Desktop App
134+
## Code Quality / Coding Rules
177135

178-
Tauri integration requires separate development workflow:
136+
### Common Rules
179137

180-
```bash
181-
# Start backend first
182-
bun dev:convex
138+
- FILE LENGTH: Prefer short files, 30 ~ 50 lines recommended, 100 lines MAX.
139+
- CHECK: Always run `bun check` after writing code.
140+
- DOCUMENTATION: document the behavior (and optionally the expected usage) of the code, not the implementation
183141

184-
# Then start Tauri (in separate terminal)
185-
bun dev:tauri
186-
```
142+
### Svelte
187143

188-
Tauri conflicts with the web development server and requires more resources for compilation.
144+
- NAMING: Name snippets with camelCase instead of PascalCase to avoid confusion with components.
145+
- ALIAS: Use TypeScript import alias for client code. `import component from "~/features/foo/component.svelte";`
146+
- STYLING: Don't use style blocks in Svelte components, instead use TailwindCSS and DaisyUI.
147+
- STYLING: Always prefer using DaisyUI classes, and use minimal Tailwind classes.
148+
- SEPARATE COMPONENTS: Separate components into smallest pieces for readability.
149+
- SEPARATE LOGIC: Separate Logic from .svelte files into .svelte.ts files.
150+
- .svelte.ts files should handle Calculation / Reactivity, while .svelte files should handle UI changes (e.g. navigation, modal open).
151+
- if it has any reusable utility function, it should be separated again into plain .ts files / .svelte.ts
152+
- An Ideal import tree would look like this: `UI component [.svelte] -> controller [.svelte.ts] -> processor [.svelte.ts] -> pure logic utility [.ts]`
189153

190-
## Coding Instructions
154+
### Convex Rules
191155

192-
- **🚫 NEVER USE LEGACY SVELTE SYNTAX**: This project uses Svelte 5 runes mode
193-
- ❌ FORBIDDEN: `$: reactiveVar = ...` (reactive statements)
194-
- ❌ FORBIDDEN: `let count = 0` for reactive state
195-
- ✅ REQUIRED: `const reactiveVar = $derived(...)`
196-
- ✅ REQUIRED: `let count = $state(0)` for reactive state
197-
- ✅ REQUIRED: `$effect(() => { ... })` for side effects
198-
- Always prefer using DaisyUI classes, and use minimal Tailwind classes.
199-
- Separate components into smallest pieces for readability.
200-
- Name snippets with camelCase instead of PascalCase to avoid confusion with components.
156+
- AUTHORIZATION: write authorization determinator in `packages/convex/src/convex/perms.ts`

0 commit comments

Comments
 (0)