Skip to content

Commit a6594e2

Browse files
docs: update .clinerules
1 parent cd1f9a5 commit a6594e2

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

.clinerules

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ This is a Nuxt 3 + Supabase project using TypeScript
1313
- /components: Vue components organized by feature
1414
- /server: Server-side TypeScript configuration
1515
- /supabase: Local Supabase instance configuration
16+
- /supabase/volumes/db/init/*.sql: Initial database schema definitions
1617
- /public: Static assets
18+
- /types: TypeScript type definitions
19+
- /types/supabase.ts: Database schema types
20+
- /types/index.ts: Central type exports
1721

1822
## Component Organization
1923

2024
- SiteHeader: Main navigation and search
2125
- HomeHero: Hero section with side-by-side video and content
2226
- ProjectsList: Grid display of projects from Supabase
27+
- FeaturedProjects: Featured projects grid for homepage
2328
- GetInvolved: Call-to-action section with engagement options
2429
- SiteFooter: Site navigation and links
2530

@@ -46,6 +51,85 @@ This is a Nuxt 3 + Supabase project using TypeScript
4651
- Environment variables handled through FRONTEND_ENV_BASE64 secret
4752
- Custom domain configured through CNAME
4853

54+
## Data Models and Supabase Integration
55+
56+
### Backend Schema (supabase/volumes/db/init/*.sql)
57+
58+
- Database schema defined in SQL migration files
59+
- Key tables:
60+
- projects: Core project information
61+
- tags: Reusable tags for projects
62+
- project_tags: Many-to-many relationship
63+
- Enums:
64+
- project_stage: Project lifecycle stages
65+
- tag_class: Tag categories (tech, topic, event)
66+
67+
### Frontend Types (types/supabase.ts)
68+
69+
- TypeScript types mirror the database schema
70+
- Key types:
71+
- Project: Base project attributes
72+
- Tag: Tag metadata
73+
- ProjectTag: Junction table type
74+
- ProjectWithTags: Extended project with nested tags
75+
- Database: Complete Supabase schema type
76+
77+
### Using Supabase in Components
78+
79+
1. Import types:
80+
81+
```typescript
82+
import type { Project, Database } from '~/types/supabase'
83+
```
84+
85+
2. Type the Supabase client:
86+
87+
```typescript
88+
const client = useSupabaseClient<Database>()
89+
```
90+
91+
3. Use with useLazyAsyncData:
92+
93+
```typescript
94+
const { data, pending, error } = await useLazyAsyncData<Project[]>('key', async () => {
95+
const { data, error } = await client
96+
.from('projects')
97+
.select('*')
98+
if (error) throw error
99+
return data
100+
})
101+
```
102+
103+
4. Handle nested relationships:
104+
105+
```typescript
106+
// Example: Fetching projects with tags
107+
.from('projects')
108+
.select(`
109+
*,
110+
project_tags (
111+
tags (
112+
id,
113+
title,
114+
class
115+
)
116+
)
117+
`)
118+
```
119+
120+
### Best Practices
121+
122+
- Transform data after fetching to match frontend needs
123+
- Use type predicates for filtering:
124+
125+
```typescript
126+
.filter((tag): tag is Tag => tag.class === 'tech')
127+
```
128+
129+
- Handle loading and error states consistently
130+
- Use computed properties for filtered data
131+
- Keep database types in sync with Supabase schema
132+
49133
## Important Considerations
50134

51135
- Always ensure Supabase Docker containers are running before development

0 commit comments

Comments
 (0)