Update agent docs and add Claude docs

This commit is contained in:
MartinBraquet
2026-05-24 00:14:50 +02:00
parent 6b3269b1c5
commit 7b10cf8af4
7 changed files with 193 additions and 60 deletions

View File

@@ -15,57 +15,5 @@ See those other useful documents as well:
- [PERFORMANCE_OPTIMIZATION.md](PERFORMANCE_OPTIMIZATION.md) for performance best practices
- [DATABASE_CONNECTION_POOLING.md](DATABASE_CONNECTION_POOLING.md) for database connection management
- [TROUBLESHOOTING.md](TROUBLESHOOTING.md) for resolving common development issues
### Adding a new profile field
A profile field is any variable associated with a user profile, such as age, politics, diet, etc. You may want to add a
new profile field if it helps people find better matches.
To do so, you can add code in a similar way as
in [this commit](https://github.com/CompassConnections/Compass/commit/940c1f5692f63bf72ddccd4ec3b00b1443801682) for the
`religion` field. If you also want people to filter by that profile field, you'll also need to add it to the search
filters, as done
in [this commit](https://github.com/CompassConnections/Compass/commit/a4bb184e95553184a4c8773d7896e4b570508fe5) (for the
`religion` field as well).
Note that you will also need to add a column to the `profiles` table in the dev database before running the code; you
can do so via this SQL command (change the type if not `TEXT`):
```sql
ALTER TABLE profiles
ADD COLUMN profile_field TEXT;
```
Store it in `add_profile_field.sql` in the [migrations](../backend/supabase/migrations) folder and
run [migrate.sh](../scripts/migrate.sh) from the root folder:
```bash
./scripts/migrate.sh backend/supabase/migrations/add_profile_field.sql
```
Then sync the database types from supabase to the local files (which assist Typescript in typing):
```bash
yarn regen-types dev
```
That's it!
### Adding a new language
Adding a new language is very easy, especially with translating tools like large language models (ChatGPT, etc.) which
you can use as first draft.
- Add the language to the LOCALES dictionary in [constants.ts](../common/src/constants.ts) (the key is the locale code,
the value is the original language name (not in English)).
- Duplicate [fr.json](../web/messages/fr.json) and rename it to the locale code (e.g., `de.json` for German). Translate
all the strings in the new file (keep the keys identical). LLMs like ChatGPT may not be able to translate the whole
file in one go; try to copy-paste by batch of 300 lines and ask the LLM to
`translate the values of the json above to <new language> (keep the keys unchanged)`. In order to fit the bottom
navigation bar on mobile, make sure the values for those keys are less than 10 characters: "nav.home", "
nav.messages", "nav.more", "nav.notifs", "nav.people".
- Duplicate the [fr](../web/public/md/fr) folder and rename it to the locale code (e.g., `de` for German). Translate all
the markdown files in the new folder. To do so, you can copy-paste each file into an LLM and ask it to
`translate the markdown above to <new language>`.
That's all, no code needed!
- [profile_fields.md](profile_fields.md) for adding new profile fields
- [internationalization.md](internationalization.md) for adding new languages

View File

@@ -0,0 +1,20 @@
# Adding a new language
Adding a new language is very easy, especially with translating tools like large language models (ChatGPT, Claude, etc.)
which
you can use as first draft.
- Add the language to the LOCALES dictionary in [constants.ts](../common/src/constants.ts) (the key is the locale code,
the value is the original language name (not in English)).
- Duplicate [fr.json](../common/messages/fr.json) and rename it to the locale code (e.g., `de.json` for German).
Translate
all the strings in the new file (keep the keys identical). LLMs like ChatGPT may not be able to translate the whole
file in one go; try to copy-paste by batch of 300 lines and ask the LLM to
`translate the values of the json above to <new language> (keep the keys unchanged)`. In order to fit the bottom
navigation bar on mobile, make sure the values for those keys are less than 10 characters: "nav.home", "
nav.messages", "nav.more", "nav.notifs", "nav.people".
- Duplicate the [fr](../web/public/md/fr) folder and rename it to the locale code (e.g., `de` for German). Translate all
the markdown files in the new folder. To do so, you can copy-paste each file into an LLM and ask it to
`translate the markdown above to <new language>`.
That's all, no code needed!

View File

@@ -15,7 +15,7 @@
- express node api server `/backend/api`
- one off scripts, like migrations `/backend/scripts`
- supabase postgres. schema in `/backend/supabase`
- supabase-generated types in `/backend/supabase/schema.ts`
- supabase-generated types in `/common/src/supabase/schema.ts`
- files shared between backend directories `/backend/shared`
- anything in `/backend` can import from `shared`, but not vice versa
- files shared between the frontend and backend in `/common`
@@ -333,7 +333,7 @@ export const placeBet: APIHandler<'bet'> = async (props, auth) => {
}
```
And finally, you need to register the handler in `backend/api/src/routes.ts`
And finally, you need to register the handler in the `handlers` map in `backend/api/src/app.ts`
```ts
import {placeBet} from './place-bet'
@@ -454,7 +454,7 @@ const t = useT()
t('common.key', 'English translations')
```
Translations should go to the JSON files in `web/messages` (`de.json` and `fr.json`, as of now).
Translations should go to the JSON files in `common/messages` (`de.json` and `fr.json`, as of now; English is the inline fallback passed to `t()`).
### Misc coding tips

49
docs/profile_fields.md Normal file
View File

@@ -0,0 +1,49 @@
# Adding a new profile field
A profile field is any variable associated with a user profile, such as age, politics, diet, etc. You may want to add a
new profile field if it helps people find better matches.
To do so, you add code here:
- common/src/supabase/schema.ts
- web/components/filters/choices.tsx (if multi choices)
- web/components/optional-profile-form.tsx
- web/components/profile-about.tsx
- backend/api/src/get-profiles.ts
- common/src/api/schema.ts ('get-profiles' props)
- common/src/api/zod-types.ts (optionalProfilesSchema)
- web/components/filters/filters.tsx
- common/src/filters.ts
- web/components/filters/use-filters.ts (yourFilters and isYourFilters)
Note that you will also need to add a column to the `profiles` table; you
can do so via this SQL command (change the type and index if not `TEXT`):
```sql
ALTER TABLE profiles
ADD COLUMN profile_field TEXT;
CREATE INDEX IF NOT EXISTS idx_profiles_profile_field ON profiles USING btree (mbti);
```
Store it in `add_<profile_field>.sql` in the [migrations](../backend/supabase/migrations) folder and
run [migrate.sh](../scripts/migrate.sh) from the root folder:
```bash
./scripts/migrate.sh backend/supabase/migrations/add_<profile_field>.sql
```
Optionally, if you use the remote dev DB, run the SQL above in the dev DB and sync the database types from supabase to
the local files (which assist Typescript in typing):
```bash
yarn --cwd=backend/api regen-types-dev
```
If you use your local DB, load the new schema with:
```bash
yarn test:db:reset
```
That's it!