Skip to content

Commit 50c0f91

Browse files
Merge pull request #79 from curehht/refactor/data-layer
Refactor/data layer
2 parents d849eb1 + 9fbb66f commit 50c0f91

71 files changed

Lines changed: 9622 additions & 13816 deletions

Some content is hidden

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

.cursor/rules/common.mdc

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@ description:
33
globs:
44
alwaysApply: true
55
---
6-
You are an expert full-stack developer proficient in TypeScript, React, Next.js, Apollo GraphQL, and PostgreSQL with drizzle ORM.
6+
# Common
7+
8+
You are an expert full-stack developer proficient in TypeScript, React, Next.js, and PostgreSQL with drizzle ORM.
79
Your task is to produce the most optimized and maintainable Next.js version 15+ code, following best practices and adhering to the principles of clean code and robust architecture.
810

11+
## Code Style and Structure
912

10-
### Code Style and Structure
1113
- Write concise, technical TypeScript code with accurate examples.
1214
- Use functional and declarative programming patterns; avoid classes.
1315
- Favor iteration and modularization over code duplication.
1416

1517
### Optimization and Best Practices
18+
1619
- Minimize the use of `'use client'`, `useEffect`, and `setState`; favor React Server Components (RSC) and Next.js SSR features.
1720
- Use 'use client' only when necessary for interactivity, such as:
1821
- Rich text editors (Tiptap, Slate)
@@ -24,36 +27,42 @@ Your task is to produce the most optimized and maintainable Next.js version 15+
2427
- Optimize images: use WebP format, include size data, implement lazy loading.
2528

2629
### Error Handling and Validation
30+
2731
- Prioritize error handling and edge cases:
28-
- Use early returns for error conditions.
29-
- Implement guard clauses to handle preconditions and invalid states early.
30-
- Use custom error types for consistent error handling.
32+
- Use early returns for error conditions.
33+
- Implement guard clauses to handle preconditions and invalid states early.
34+
- Use custom error types for consistent error handling.
3135

3236
### UI and Styling
37+
3338
- Do not use any UI frameworks or library.
3439
- Implement consistent design and responsive patterns across platforms.
3540

3641
### State Management and Data Fetching
42+
3743
- Do not use any State Management
38-
- Use Apollo for Data Fetching
3944

4045
### Security and Performance
46+
4147
- Implement proper error handling, user input validation, and secure coding practices.
4248
- Follow performance optimization techniques, such as reducing load times and improving rendering efficiency.
4349

4450
### Testing and Documentation
51+
4552
- Write unit tests for components using Jest and React Testing Library.
4653
- Provide clear and concise comments for complex logic.
4754

4855
### Methodology
56+
4957
1. **System 2 Thinking**: Approach the problem with analytical rigor. Break down the requirements into smaller, manageable parts and thoroughly consider each step before implementation.
5058
2. **Tree of Thoughts**: Evaluate multiple possible solutions and their consequences. Use a structured approach to explore different paths and select the optimal one.
5159
3. **Iterative Refinement**: Before finalizing the code, consider improvements, edge cases, and optimizations. Iterate through potential enhancements to ensure the final solution is robust. Finally check the TS types.
5260
4. Suggest a variant first let me take a look at the suggestion.
5361

5462
**Process**:
63+
5564
1. **Deep Dive Analysis**: Begin by conducting a thorough analysis of the task at hand, considering the technical requirements and constraints.
5665
2. **Planning**: Develop a clear plan that outlines the architectural structure and flow of the solution, using <PLANNING> tags if necessary.
5766
3. **Implementation**: Implement the solution step-by-step, ensuring that each part adheres to the specified best practices.
5867
4. **Review and Optimize**: Perform a review of the code, looking for areas of potential optimization and improvement.
59-
5. **Finalization**: Finalize the code by ensuring it meets all requirements, is secure, and is performant.
68+
5. **Finalization**: Finalize the code by ensuring it meets all requirements, is secure, and is performant.

.cursor/rules/database.mdc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ description:
33
globs:
44
alwaysApply: true
55
---
6-
## Tech stack
6+
7+
# Tech stack
8+
79
- PostgreSQL
810
- Drizzle ORM
911

@@ -13,6 +15,6 @@ Define the entire database schema in TypeScript using Drizzle ORM. The schema in
1315
Use drizzle-kit generate to generate SQL migration files automatically from changes in the TypeScript schema.
1416
Apply SQL migrations to the database at runtime (e.g., during app startup or deployment) using Drizzle’s migration API.
1517

16-
Use apollo for data request:
17-
- on the client-side use useQuery, useMutation hooks from '@apollo/client'
18+
## Data request
19+
1820
- on the server-side create api in src/db/api with drizzle and use it

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
/.pnp
44
.pnp.js
55

6+
# build
7+
tsconfig.tsbuildinfo
8+
69
# testing
710
/coverage
811

@@ -30,3 +33,4 @@ yarn-error.log*
3033
# editors
3134
.idea/
3235
.vercel
36+
.env*.local

.prettierrc

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

.prettierrc.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"endOfLine": "auto",
3+
"semi": true,
4+
"singleQuote": true,
5+
"tabWidth": 2,
6+
"trailingComma": "es5",
7+
"printWidth": 100,
8+
"plugins": ["@ianvs/prettier-plugin-sort-imports"],
9+
"importOrder": [
10+
"^react$",
11+
"<THIRD_PARTY_MODULES>",
12+
"",
13+
"^@/utils/(.*)$",
14+
"^@/database/(.*)$",
15+
"^@/db/(.*)$",
16+
"@/auth",
17+
"^@/components/(.*)$",
18+
"^@/controllers/(.*)$",
19+
"",
20+
"^[./]"
21+
]
22+
}

.vscode/settings.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
{
22
"typescript.tsdk": "node_modules/typescript/lib",
3-
"githubPullRequests.ignoredPullRequestBranches": ["dev"]
4-
}
3+
"githubPullRequests.ignoredPullRequestBranches": [
4+
"dev"
5+
],
6+
"cSpell.words": [
7+
"Baumgertner",
8+
"neondatabase",
9+
"Osler",
10+
"Rendu"
11+
]
12+
}

README.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
## О проекте
2-
Сайт русскоязыного сообщества поддержки пациентов с болезнью Рандю-Ослера-Вебера.
1+
# About the Project
32

3+
A website for the Russian-speaking community supporting patients with [Osler–Weber–Rendu](https://en.wikipedia.org/wiki/Hereditary_hemorrhagic_telangiectasia) disease.
44

5-
### Технологии
6-
- [Next.js 15](https://nextjs.org/) - React фреймворк для создания веб-приложений
7-
- [React 19](https://react.dev/) - JavaScript библиотека для создания пользовательских интерфейсов
8-
- [TypeScript](https://www.typescriptlang.org/) - Типизированный JavaScript
9-
- [Apollo Client](https://www.apollographql.com/docs/react/) - GraphQL клиент для работы с API
10-
- [NextAuth.js](https://next-auth.js.org/) - Аутентификация и авторизация
11-
- [Drizzle ORM](https://orm.drizzle.team/) - ORM для работы с базой данных
12-
- [Vercel Postgres](https://vercel.com/storage/postgres) - База данных PostgreSQL
13-
- [Vercel Blob](https://vercel.com/storage/blob) - Хранилище файлов
14-
- [Vercel Analytics & Speed Insights](https://vercel.com/analytics) - Аналитика и мониторинг производительности
15-
- [ESLint](https://eslint.org/) & [Prettier](https://prettier.io/) - Линтинг и форматирование кода
5+
## Technologies
166

17-
## Добавить поле в базу данных
18-
1. Добавить поле в схему
19-
2. Запустить `drizzle-kit generate`
20-
3. Запустить `drizzle-kit migrate`
7+
- [Next.js 15](https://nextjs.org/) - React framework for building web applications
8+
- [React 19](https://react.dev/) - JavaScript library for building user interfaces
9+
- [TypeScript](https://www.typescriptlang.org/) - Typed JavaScript
10+
- [NextAuth.js](https://next-auth.js.org/) - Authentication and authorization
11+
- [Drizzle ORM](https://orm.drizzle.team/) - ORM for working with the database
12+
- [Vercel Postgres](https://vercel.com/storage/postgres) - PostgreSQL database
13+
- [Vercel Blob](https://vercel.com/storage/blob) - File storage
14+
- [Vercel Analytics & Speed Insights](https://vercel.com/analytics) - Analytics and performance monitoring
15+
- [ESLint](https://eslint.org/) & [Prettier](https://prettier.io/) - Code linting and formatting
16+
17+
## Add a Field to the Database
18+
19+
1. Add the field to the schema
20+
2. Run `drizzle-kit generate`
21+
3. Run `drizzle-kit migrate`

ROADMAP.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# ROADMAP
22

33
## Deploy
4-
Оставить одну ветку dev, с нее деплоить на beta.curehht-ru.org
5-
curehht-ru.org деплоить из api beta.curehht-ru.org как статический сайт, раз в сутки/неделю
6-
Добавить карту учатников
4+
5+
Keep a single branch "dev", deploy from it to beta.curehht-ru.org
6+
Deploy curehht-ru.org as a static site generated from the beta.curehht-ru.org API once per day/week
7+
Add a participant map

docker-compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
services:
2+
postgres:
3+
image: postgres:16-alpine
4+
container_name: curehht-postgres
5+
restart: unless-stopped
6+
environment:
7+
POSTGRES_USER: postgres
8+
POSTGRES_PASSWORD: postgres
9+
POSTGRES_DB: curehht
10+
ports:
11+
- "5432:5432"
12+
volumes:
13+
- postgres_data:/var/lib/postgresql/data
14+
healthcheck:
15+
test: ["CMD-SHELL", "pg_isready -U postgres"]
16+
interval: 5s
17+
timeout: 5s
18+
retries: 5
19+
20+
volumes:
21+
postgres_data:

drizzle/0003_redundant_marvex.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ALTER TABLE "pages" ADD COLUMN "description" text;
1+
ALTER TABLE "pages" ADD COLUMN IF NOT EXISTS "description" text;

0 commit comments

Comments
 (0)