You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
│ ├── package.json # Frontend dependencies and scripts
77
+
│ ├── postcss.config.mjs
78
+
│ ├── public # Static assets
79
+
│ ├── schema.d.ts # Generated type definitions
80
+
│ ├── tsconfig.json
81
+
│ ├── types # TypeScript type definitions
82
+
│ └── utils # Frontend utility functions
83
+
├── package-lock.json
84
+
├── package.json
85
+
├── spec.json # API specification (generated by script)
86
+
└── tsconfig.json # Root TypeScript configuration
87
+
88
+
```
89
+
90
+
### Running the App
91
+
To deploy the app using Docker Compose run one of the following commands:
92
+
```bash
93
+
MODE="dev" LOG_VOLUME_MOUNT="./backend/log" docker compose up --build --watch # in dev more
94
+
MODE="prod" LOG_VOLUME_MOUNT="./backend/log" docker compose up --build --watch # in production mode
95
+
```
96
+
97
+
This will mount both the frontend and backend. `LOG_VOLUME_MOUNT` can be changed to redirect runtime logging. Note that running the backend in dev mode requires your local Supabase to be running - see [Database Management](#database-management) below for instructions.
98
+
99
+
If you want to run only the backend:
100
+
```bash
101
+
cd backend
102
+
bun run dev # dev mode
103
+
# OR
104
+
bun run start # prod mode
105
+
```
106
+
107
+
If you want to run only the frontend
108
+
```bash
109
+
cd frontend
110
+
bun run dev # dev mode
111
+
# OR
112
+
bun run start # prod mode
113
+
```
114
+
115
+
The backend will be available at [localhost:3001](http://localhost:3001/) and the frontend at [localhost:3000](http://localhost:3000/)
116
+
117
+
118
+
### Database Management
119
+
120
+
We use [Supabase](https://supabase.com/) as a PostgreSQL development platform to manage our databases combined with [TypeORM](https://typeorm.io/).
121
+
122
+
To get a Supabase instance running locally, install the Supabase CLI, make sure your Docker engine is running, and run the following commands:
123
+
```bash
124
+
cd backend/
125
+
bun run supabase start
126
+
```
127
+
128
+
See your local Supabase studio at localhost:54323
129
+
130
+
To migrate your local DB to match the state of prod/git, run:
131
+
```bash
132
+
bun run migration:dev
133
+
```
134
+
135
+
To run a migration on production (use this command with caution!), run:
136
+
```bash
137
+
bun run migration:prod
138
+
```
139
+
140
+
To revert a migration in either environment, run:
141
+
```bash
142
+
bun run migration:dev:revert
143
+
# OR
144
+
bun run migration:prod:revert
145
+
```
146
+
147
+
To stop your local instance of Supabase, run:
148
+
```bash
149
+
bun run supabase stop
150
+
```
151
+
152
+
See [MIGRATION_TUTORIAL.md](./backend/supabase/MIGRATION_TUTORIAL.md) for more information about managing migrations with TypeORM.
153
+
154
+
### Type Generation
155
+
We use OpenAPI documentation to generate types for the layer between the frontend and the backend for consistency. The development process should be as follows:
156
+
157
+
1. Make changes to an api endpoint in the backend.
158
+
2. Update the OpenAPI routes in the associated file in the `/openapi` module.
159
+
3. From the root directory, run `bun run gen-types` or `bun run g` to generate new `spec.json` and `schema.d.ts` files.
160
+
4. In the `types` folder in the frontend, update imports from the `schema.d.ts` as necessary and use the types in the frontend.
161
+
162
+
This ensures consistent type expectations for a safe contract between the frontend and the backend.
Copy file name to clipboardExpand all lines: backend/supabase/MIGRATION_TUTORIAL.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
We are using a Supabase-hosted Postgres database. Our schema is relational and we handle changes by making migration scripts so that we have a changelog of the database schema history. Because we are using TypeORM a lot of this work is done for you!
4
4
5
+
TypeORM will read the current state of your local database and the entities in the codebase and find the changeset between the two (any columns, tables, constraints, etc. that are different). Using the changeset, it generates a migration that, when run, will modify your local DB to match the state of the entities in the code. **Note that you should run all migrations before generating new ones to avoid duplication of migration scripts/errors in deployment**
6
+
5
7
The following pathway allows you to make and test schema changes locally via migration script without affecting the shared database until you're ready. More information on local development best practices can be found in the [Supabase docs](https://supabase.com/docs/guides/cli/local-development). **Note that running the DB locally requires Docker to be installed and running.**
6
8
7
9
0. Install the Supabase CLI by following directions [here](https://supabase.com/docs/guides/local-development/cli/getting-started?queryGroups=access-method&access-method=postgres&queryGroups=platform&platform=macos).
0 commit comments