Skip to content

Commit 341fd11

Browse files
committed
introduce different improvements
1 parent 065c519 commit 341fd11

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1963
-1206
lines changed

.cursor/rules/comments.mdc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@ globs:
44
alwaysApply: true
55
---
66

7-
87
# how and when to write comments (llm rules)
98

109
## guiding principles
11-
1. **minimize comments:** code should be self-explanatory; comment only when necessary.
12-
2. **clarity through naming:** use clear, descriptive names for variables, functions, classes, and components.
10+
1. **minimize comments:** code should be self-explanatory; comment only when needed.
11+
2. **clarity through naming:** use clear, descriptive names for variables, functions, classes, components.
1312
3. **comment the "why," not the "what":** explain *why* an approach was taken, especially for non-obvious logic or trade-offs. don't restate what the code does.
1413
4. **avoid obvious comments:** don't comment on simple or standard code; assume the reader knows language basics.
15-
5. **consistency:** use a consistent style for comments and documentation across the codebase.
14+
5. **consistency:** keep comment and doc style consistent across the codebase.
1615

1716
## when to add comments
18-
* **complex logic:** for algorithms or flows not immediately clear from code.
17+
* **complex logic:** for algorithms or flows not clear from code.
1918
* **non-obvious decisions (the "why"):** explain reasoning behind design choices, workarounds, or optimizations, especially if nonstandard or counterintuitive.
2019
* **business rules/context:** briefly note domain-specific rules or context driving code.
2120
* **security/performance notes:** note important security or performance implications if not obvious.
@@ -36,15 +35,16 @@ alwaysApply: true
3635
* **outdated comments:** remove or update comments that no longer match the code.
3736

3837
## humor, tone, and informality
39-
* **full informal freedom:** feel free to use informal, conversational, or humorous language in comments and documentation—just like a real, quirky senior developer. puns, memes, pop culture references, and playful banter are all fair game, as long as it's not offensive or unprofessional. if a joke helps make a point or keeps things lively, go for it!
38+
* **full informal freedom:** use informal, conversational, or humorous language in comments and docs—just like a real, quirky senior dev. puns, memes, pop culture, playful banter are all fair game, as long as it's not offensive or unprofessional. if a joke helps make a point or keeps things lively, go for it!
4039
* **be yourself:** comments can have personality. if you want to drop a "don't touch this unless you like pain", that's totally fine.
41-
* **clarity first:** even with informality, make sure the comment's intent is clear, helpful to both code beginners and seniors.
40+
* **clarity first:** even with informality, make sure the comment's intent is clear and helpful to both beginners and seniors.
4241

4342
## lowercase comment style
44-
* **all comments must be written in lowercase, even at the beginning of sentences.** the only exception is for code identifiers (like function or variable names), which should retain their original casing.
43+
* **all comments must be written in lowercase, even at the beginning of sentences.** the only exception is for code identifiers (like function or variable names), which should keep their original casing.
4544

4645
## important
4746
* when asked to "clean up" comments, don't add new comments explaining what was removed or which functions/variables were renamed. the user uses cursor ide, which shows diffs. explain important changes in your message, not in code comments.
47+
* remember: these rules apply only to comments, e.g. `// ` `/** */` `{/* */}`. do not apply these rules to end-user content, e.g. frontend text.
4848

49-
by following these rules, the codebase stays clean, readable, and maintainable—while also being a little more fun and human.
49+
by following these rules, the codebase stays clean, readable, maintainable—and a little more fun and human.
5050

.cursor/rules/drizzle-orm.mdc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
description: Read this rule when working with Drizzle ORM
3+
globs:
4+
alwaysApply: false
5+
---
6+
7+
# how to work with drizzle orm (ai rules)
8+
9+
## debugging: `typeerror: cannot read properties of undefined (reading 'referencedtable')`
10+
11+
this error happens when drizzle can't find relationship metadata for a relational query (e.g., `db.query.someTable.findMany({ with: { relatedTable: true } })`).
12+
13+
**checklist:**
14+
15+
1. **missing `relations` definition:**
16+
* define a `relations` object for the source table (e.g., `userRelations = relations(userTable, ({ many }) => ({ uploads: many(uploadsTable) }))`).
17+
* `.references()` only sets up the db foreign key; it doesn't create drizzle's relation for queries.
18+
2. **relations not exported:**
19+
* export all `relations` objects from schema files.
20+
* ensure your schema barrel file (e.g., `src/db/schema/index.ts`) exports all tables and relations.
21+
3. **wrong schema passed to drizzle:**
22+
* when initializing, pass a schema object with both tables and relations:
23+
`import * as schema from './schema';`
24+
`const db = drizzle(conn, { schema });`
25+
4. **build issues:**
26+
* in monorepos or complex setups, make sure all schema/relation files are included in the build.
27+
5. **multiple drizzle instances:**
28+
* use a single shared drizzle client (e.g., export `db` from `src/db/index.ts`).
29+

.cursor/rules/general-rules.mdc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ description:
33
globs:
44
alwaysApply: true
55
---
6-
## General Rules
7-
- You are a code agent. Always make changes without asking if the user wants you to make them. Unless the user explicitly asks you not to make changes.
6+
7+
8+
## general rules
9+
- you are a code agent. always make changes without asking if the user wants you to make them. unless the user explicitly asks you not to make changes.
810

.cursor/rules/orm-drizzle.mdc

Lines changed: 0 additions & 29 deletions
This file was deleted.

.cursor/rules/uploadthing.mdc

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@ globs:
44
alwaysApply: false
55
---
66

7+
# how to work with uploadthing (llm guide)
78

8-
# How to Work with Uploadthing (LLM Guide)
9+
## key files
910

10-
## Key Files
11+
- config: `core.ts` (upload routes, middleware, db)
12+
- api handler: `route.ts` (webhook/callback)
13+
- db schema: `tables.ts` (`uploads` table, `type` enum)
14+
- db types: `types.ts` (`MediaUpload`)
15+
- frontend ui: `page.client.tsx` (`UploadButton`)
16+
- media api: `/api/media/route.ts` (fetch media)
17+
- display: `bento-media-gallery.tsx` (renders images/videos)
18+
- auth: `~/lib/auth`
1119

12-
- **Config:** `core.ts` (upload routes, middleware, db)
13-
- **API Handler:** `route.ts` (webhook/callback)
14-
- **DB Schema:** `tables.ts` (`uploads` table, `media_type` enum)
15-
- **DB Types:** `types.ts` (`MediaUpload`)
16-
- **Frontend UI:** `page.client.tsx` (`UploadButton`)
17-
- **Media API:** `/api/media/route.ts` (fetch media)
18-
- **Display:** `bento-media-gallery.tsx` (renders images/videos)
19-
- **Auth:** `~/lib/auth`
20+
## core concepts
2021

21-
## Core Concepts
22+
- routes: defined in `core.ts` with `createUploadthing()`. each route (e.g., `imageUploader`, `videoUploader`) sets allowed types, size, count.
23+
- auth: middleware in `core.ts` uses `auth.api.getSession` to check user; throws if unauthorized.
24+
- db insert: `onUploadComplete` inserts into `uploads` table, sets `type` based on route, uses `createId()` for `id`.
25+
- frontend: `UploadButton` for each endpoint; `onClientUploadComplete` refetches media via `/api/media`.
26+
- media fetch: `/api/media/route.ts` authenticates, fetches uploads for user, returns json.
27+
- display: `bento-media-gallery.tsx` renders `<img>` or `<video>` based on `type`.
2228

23-
- **Routes:** Defined in `core.ts` with `createUploadthing()`. Each route (e.g., `imageUploader`, `videoUploader`) sets allowed types, size, count.
24-
- **Auth:** Middleware in `core.ts` uses `auth.api.getSession` to check user; throws if unauthorized.
25-
- **DB Insert:** `onUploadComplete` inserts into `uploads` table, sets `type` based on route, uses `createId()` for `id`.
26-
- **Frontend:** `UploadButton` for each endpoint; `onClientUploadComplete` refetches media via `/api/media`.
27-
- **Media Fetch:** `/api/media/route.ts` authenticates, fetches uploads for user, returns JSON.
28-
- **Display:** `bento-media-gallery.tsx` renders `<img>` or `<video>` based on `type`.
29+
## tips
2930

30-
## Tips
31+
- check `core.ts` for routes, middleware, and upload logic.
32+
- set `type` in `onUploadComplete` based on route.
33+
- adding new media types: update `core.ts`, `tables.ts` enum, run migrations, add `UploadButton`, update display and api as needed.
34+
- media fetch requires auth.
35+
- error handling: `onUploadComplete` logs/throws; production may need more.
3136

32-
- **Check `core.ts`** for routes, middleware, and upload logic.
33-
- **Set `type`** in `onUploadComplete` based on route.
34-
- **Adding new media types:** update `core.ts`, `tables.ts` enum, run migrations, add `UploadButton`, update display and API as needed.
35-
- **Media fetch requires auth.**
36-
- **Error handling:** `onUploadComplete` logs/throws; production may need more.

.env.example

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,63 @@
1-
# ============================================
21
# 📖 https://docs.reliverse.org/relivator/env
3-
# ============================================
42

5-
# Metadata
3+
# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
4+
# ―― APP ―――――――――――――――――――――――――――――――――――
5+
# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
6+
7+
# use https://example.com in production
68
NEXT_PUBLIC_APP_URL="http://localhost:3000"
79
NEXT_SERVER_APP_URL="http://localhost:3000"
810

9-
# Database
11+
# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
12+
# ―― DATABASE ――――――――――――――――――――――――――――――
13+
# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
14+
1015
# https://console.neon.tech/app/projects
11-
DATABASE_URL="postgresql://postgres:password@localhost:5432/db"
16+
DATABASE_URL="postgresql://..."
1217

13-
# Authentication
14-
# bunx randomstring length=32
15-
AUTH_SECRET="your-auth-secret-key-at-least-32-chars"
18+
# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
19+
# ―― AUTHENTICATION ――――――――――――――――――――――――
20+
# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
1621

17-
# https://github.com/settings/developers
18-
# https://example.com/api/auth/callback/github
19-
AUTH_GITHUB_ID="your-github-client-id"
20-
AUTH_GITHUB_SECRET="your-github-client-secret"
22+
# bunx randomstring length=32
23+
AUTH_SECRET="..."
2124

2225
# https://console.cloud.google.com/apis/credentials
2326
# Create credentials > OAuth client ID
2427
# Authorized JavaScript origins: https://example.com && http://localhost:3000
2528
# Authorized redirect URIs: https://example.com/api/auth/callback/google && http://localhost:3000/api/auth/callback/google
26-
AUTH_GOOGLE_ID="your-google-client-id"
27-
AUTH_GOOGLE_SECRET="your-google-client-secret"
29+
AUTH_GOOGLE_ID="..."
30+
AUTH_GOOGLE_SECRET="..."
31+
32+
# https://github.com/settings/developers
33+
# https://example.com/api/auth/callback/github
34+
AUTH_GITHUB_ID="..."
35+
AUTH_GITHUB_SECRET="..."
36+
37+
# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
38+
# ―― UPLOADS ―――――――――――――――――――――――――――――――
39+
# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
2840

2941
# https://uploadthing.com/dashboard
30-
UPLOADTHING_TOKEN=""
31-
UPLOADTHING_SECRET_KEY="sk_live_"
42+
UPLOADTHING_TOKEN="..."
43+
UPLOADTHING_SECRET_KEY="sk_live_..."
44+
45+
# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
46+
# ―― PAYMENTS ――――――――――――――――――――――――――――――
47+
# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
48+
49+
# 🔜
50+
51+
# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
52+
# ―― EMAILS ――――――――――――――――――――――――――――――――
53+
# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
54+
55+
# 🔜
56+
57+
# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
58+
# ―― INSTRUCTIONS ――――――――――――――――――――――――――
59+
# ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
3260

33-
# Instructions:
3461
# 1. Copy .env.example file to .env
3562
# 2. Replace the values with your own credentials
3663
# 3. Restart your development server if it's running

.eslintcache

Lines changed: 0 additions & 1 deletion
This file was deleted.

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
tsconfig.tsbuildinfo
21
/auth-schema.ts
32
/node_modules
43
next-env.d.ts
4+
*.tsbuildinfo
55
.eslintcache
6+
.DS_Store
67
.vercel
8+
*.log*
9+
.venv
10+
.idea
711
.next
8-
.env
912
.exe
1013
.dll
14+
.env

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"biomejs.biome",
66
"dbaeumer.vscode-eslint",
77
"chunsen.bracket-select",
8-
"davidanson.vscode-markdownlint"
8+
"davidanson.vscode-markdownlint",
9+
"yzhang.markdown-all-in-one"
910
]
1011
}

0 commit comments

Comments
 (0)