This is a monorepo with the following packages:
API- path
./api
- Go
- GraphQL
- PostgreSQL
- Minio
- path
Web- path
./web
- React-Router
- Mantine
- path
I've tried to make this pretty easy to develop with. We use Docker and Docker Compose to keep everything wrapped up nice and tidy.
- Docker
- For running all the services together and reducing the required deps to install
- Task
- For running commands in a simpler fashion
- Node >= v20
- Frontend
- Prettier
- GraphQL linting
- PNPM
- Package manager if you want to run the app without docker
- Go >= v1.22
- Backend
To start things off, we should run task bootstrap. This does a couple things:
- Sets up the
.envfiles in for the apps - Pulls all required Docker images
- Builds the local docker images
- Verifies dependencies
- Sets up git hooks
To spin up the application services, you just need to make sure you have the dependencies installed and run task up from the root directory. This will start all the services specifies in the docker-compose.yml. You can run task watch to start the services in watch mode. This will rebuild/restart the services when files change.
To bring the services down run task down.
The services run on the following ports:
| Service | Port |
|---|---|
| Web | 3000 |
| API | 8000 |
| PgWeb | 8081 |
| Minio Console | 9001 |
| Postgres | 5432 |
| Minio | 9000 |
When logging in or signing up by default we don't send the magic link emails. To complete the auth flow do the following:
- Either log in or sign up until you get to the "Please check your email screen"
- Look for the line in your terminal that looks like this:
MAGIC LINK CODE: ${CODE}- note: If running in detached mode, like running
task up, rundocker compose logs api
- In your browser go to
http://localhost:3000/auth/validate?code=${CODE}
🎉🎉🎉
We have a couple scripts setup inside the docker-compose.yml. I have setup additional shortcuts from them in the taskfile
We use gqlgen for generating Go types from our GraphQL schema. You can access this feature using the gqlgen compose service in the scripts profile. Here are some examples:
task gqlgen- This generates the GraphQL types for our API from the schema files.
We use go migrate for our DB migration tool. This manages the migrations in the migrations folder. Some examples of using this from docker-compose:
task migrate-new- This creates a new migration file
task migrate-up- This applies any needed migrations
task migrate-down- Roll back applied migrations
We use sqlc to generate typesafe go code based on our sql queries. This uses the queries in the queries folder. Some examples of using this from docker-compose:
task sqlc-gen- This generates go files for our queries
task seed- Generate and insert random data into the database
- task reset
- Alias for
task drop,task migrate-up, andtask seed
- Alias for
- task up
- Bring up all the main services in detached mode
- task down
- Bring down all the main services
- task watch
- Bring up all the main services and watches for changes
- task build
- Build all local docker images
- task pull
- Pull all the required docker images
- task lint:go
- Run golangci-lint
- task lint:go:fix
- Run golangci-lint with --fix flag
- task lint:ts
- Run ESLint
- task lint:ts:fix
- Run ESLint with --fix flag
- task lint
- Alias for
task lint:goandtask lint:ts
- Alias for
- task lint:fix
- Alias for
task lint:go:fixandtask lint:ts:fix
- Alias for
- task gofmt
- Run gofmt
- task gofmt:check
- Run gofmt and error if anything isn't formatted correctly
- task prettier
- Run prettier
- task prettier:check
- Run prettier and error if anything isn't formatted correctly
- task format
- Alias for
task gofmtandtask prettier
- Alias for
- task format:check
- Alias for
task gofmt:checkandtask prettier:check
- Alias for