Skip to content

Commit 96ab80d

Browse files
authored
Merge pull request #11 from brylie/refactor-app-and-animation-structure
Refactor app and animation structure, add harmonic app
2 parents 9653cf6 + 15a5030 commit 96ab80d

File tree

12 files changed

+868
-15
lines changed

12 files changed

+868
-15
lines changed

AGENTS.md

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This document provides essential context for AI coding agents (Claude, Gemini, G
55
## Project Overview
66

77
**brylie.music** is a personal music website built with modern web technologies, featuring:
8+
89
- Music releases with Creative Commons licensing
910
- Blog posts about music and technology
1011
- Interactive musical applications (Svelte-based)
@@ -14,22 +15,25 @@ This document provides essential context for AI coding agents (Claude, Gemini, G
1415
## Technology Stack
1516

1617
### Core Framework
18+
1719
- **Astro 5.x**: Static site generator with content collections
1820
- File-based routing in `src/pages/`
1921
- Type-safe content collections in `src/content/`
2022
- MDX support for enhanced markdown
2123
- Server-side rendering capabilities
2224

2325
### UI & Styling
26+
2427
- **Svelte 5**: Interactive components with runes (modern reactive patterns)
2528
- Use `$state`, `$derived`, `$effect` runes
26-
- Components in `src/components/` and `src/components/apps/`
29+
- Components in `src/components/` and `src/apps/`
2730
- **Tailwind CSS 4.x**: Utility-first CSS framework
2831
- Modern Vite integration (`@tailwindcss/vite`)
2932
- Typography plugin for markdown styling
3033
- Custom configuration in `tailwind.config.js`
3134

3235
### Development
36+
3337
- **TypeScript 5.x**: Type-safe development
3438
- Strict mode enabled
3539
- Configuration in `tsconfig.json`
@@ -41,6 +45,7 @@ This document provides essential context for AI coding agents (Claude, Gemini, G
4145
## Coding Conventions
4246

4347
### Astro Components
48+
4449
```astro
4550
---
4651
// TypeScript in frontmatter for SSR logic
@@ -60,6 +65,7 @@ const { prop1, prop2 } = Astro.props;
6065
```
6166

6267
### Svelte 5 Components
68+
6369
```svelte
6470
<script lang="ts">
6571
// Use runes for reactive state
@@ -78,22 +84,24 @@ const { prop1, prop2 } = Astro.props;
7884
```
7985

8086
### TypeScript
81-
- Use explicit types for function parameters and return values
87+
88+
- Use explicit types for function parameters and return values (including `: void`)
8289
- Prefer `interface` over `type` for object shapes
8390
- Use `const` by default, `let` when mutation is needed
8491
- Avoid `any`; use `unknown` if type is truly unknown
8592

8693
### Styling with Tailwind
94+
8795
- Prefer Tailwind utilities over custom CSS
8896
- Use semantic class names when combining multiple utilities
8997
- Dark theme optimized: use `dark:` variants sparingly
9098
- Component-specific styles: use Astro's scoped `<style>` tags if needed
9199

92100
### File Organization
101+
93102
```text
94103
src/
95104
├── components/ # Reusable Astro/Svelte components
96-
│ ├── apps/ # Interactive musical apps (Svelte)
97105
│ └── *.astro # Layout components
98106
├── content/ # Content collections (type-safe)
99107
│ ├── blog/ # Blog posts (MDX)
@@ -105,12 +113,13 @@ src/
105113
│ ├── blog/ # Blog routes
106114
│ └── releases/ # Release routes
107115
├── styles/ # Global CSS
108-
└── utils/ # Utility functions (with tests)
116+
└── apps/ # Interactive musical apps (Svelte + Logic + Tests)
109117
```
110118

111119
## Content Collections
112120

113121
### Schema Definitions
122+
114123
Content collections use Zod schemas in `src/content.config.ts`:
115124

116125
```typescript
@@ -131,12 +140,14 @@ const blog = defineCollection({
131140
### Testing Strategy
132141

133142
#### Unit Tests (Vitest)
143+
134144
- Test utility functions in isolation
135145
- Place tests adjacent to implementation: `bpm.ts``bpm.test.ts`
136146
- Use descriptive test names: `test('converts BPM to whole note duration', ...)`
137147
- Run with `npm run test` or `npm run test:ui`
138148

139149
#### Example Test Structure
150+
140151
```typescript
141152
import { describe, test, expect } from 'vitest';
142153
import { functionName } from './module';
@@ -154,16 +165,18 @@ describe('functionName', () => {
154165

155166
## Musical Apps Guidelines
156167

157-
Interactive musical applications are built with Svelte and documented in `src/content/APPS_README.md`.
168+
Interactive musical applications are built with Svelte and documented in `src/apps/README.md`.
158169

159170
### App Structure
160-
- Component: `src/components/apps/AppName.svelte` (interactive UI)
171+
172+
- Component: `src/apps/AppName.svelte` (interactive UI)
173+
- Logic: `src/apps/appName.ts` (business logic)
174+
- Tests: `src/apps/appName.test.ts` (unit tests)
161175
- Metadata: `src/content/apps/app-name.mdx` (description, documentation)
162-
- Utils: `src/utils/appName.ts` (business logic, with tests)
163-
- Route: `src/pages/apps/[...slug].astro` (dynamic routing)
164176

165177
### App Best Practices
166-
1. **Separation of Concerns**: Business logic in utils, UI in Svelte components
178+
179+
1. **Separation of Concerns**: Business logic in `.ts` files, UI in Svelte components, both co-located in `src/apps/`
167180
2. **Type Safety**: TypeScript for all logic functions
168181
3. **Testing**: Unit tests for all utility functions
169182
4. **Accessibility**: WCAG 2.1 AA compliance (semantic HTML, ARIA labels)
@@ -172,12 +185,15 @@ Interactive musical applications are built with Svelte and documented in `src/co
172185
## Git Workflow
173186

174187
### Branch Strategy
188+
175189
- `main`: Production-ready code
176190
- Feature branches: `feature/description` or `fix/description`
177191
- Create PR for review before merging
178192

179193
### Commit Messages
194+
180195
Follow conventional commits:
196+
181197
```text
182198
feat(apps): add BPM calculator with millisecond subdivisions
183199
fix(blog): correct date formatting in post metadata
@@ -186,6 +202,7 @@ test(utils): add edge cases for bpm calculations
186202
```
187203

188204
### Code Review Focus Areas
205+
189206
1. **Type Safety**: Ensure TypeScript types are properly defined
190207
2. **Performance**: Check for unnecessary re-renders, large bundle sizes
191208
3. **Accessibility**: Verify semantic HTML and ARIA attributes
@@ -196,22 +213,26 @@ test(utils): add edge cases for bpm calculations
196213
## Common Pitfalls to Avoid
197214

198215
### Astro
216+
199217
- ❌ Don't use React hooks in Astro components (use Svelte or vanilla JS)
200218
- ❌ Don't import client components without proper directives
201219
- ✅ Use `client:load`, `client:visible`, etc. for interactive islands
202220

203221
### Svelte 5
222+
204223
- ❌ Don't use legacy `$:` reactive statements (use `$derived` instead)
205224
- ❌ Don't use `onMount` for simple effects (use `$effect` instead)
206225
- ✅ Embrace runes: `$state`, `$derived`, `$effect`, `$props`
207226

208-
### TypeScript
227+
### TypeScript Common Errors
228+
209229
- ❌ Don't use `any` type
210230
- ❌ Don't ignore TypeScript errors (fix them properly)
211231
- ✅ Use explicit return types for functions
212232
- ✅ Leverage type inference when appropriate
213233

214234
### Tailwind
235+
215236
- ❌ Don't create duplicate utility classes in custom CSS
216237
- ❌ Don't use overly complex class strings (consider component extraction)
217238
- ✅ Use Tailwind's built-in responsive and dark mode utilities
@@ -227,6 +248,7 @@ test(utils): add edge cases for bpm calculations
227248
## SEO Requirements
228249

229250
All pages should include:
251+
230252
- Canonical URLs
231253
- OpenGraph metadata
232254
- Twitter card metadata
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
generateFoamParticles,
1010
type OceanWaveConfig,
1111
type FoamParticle,
12-
} from "../../animations/oceanWaves";
12+
} from "./oceanWaves";
1313
1414
interface Props {
1515
width?: number;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { calculateAllSubdivisions } from "../../utils/bpm";
2+
import { calculateAllSubdivisions } from "./bpmCalculator";
33
44
let bpm = $state(120);
55
let subdivisions = $derived(calculateAllSubdivisions(bpm));

0 commit comments

Comments
 (0)