First of all, welcome to the team 😄 let's get you up and running in a jiffy! To get the core backend code running on your laptop is fairly straightforward, all you need to be aware of are some of the basic tools we use in the Axiom backend.
- Git - our favourite version control, make sure you pick that up (paired with Gitlab)
- Golang - head on over here if you need help getting that installed
- Go modules - makes go so much easier to deal with
- gqlgen - our GraphQL client, uses go generate to create graphql resolvers as you will see in the future steps
- Postgres - the SQL database of choice
- Docker - containerise all the things 🐳, grab that here
- docker-compose - we use this for rudimentary container orchestration at the developer level
If you have trouble or don't understand any of the above mentioned tools entirely, feel free to take some time now to get used to them. Also approach any of our more senior developers, and they would be glad to lend you a hand 😜
Make sure once again that all the aformentioned tools are installed on your system, then follow these steps to start your own local development instance of the Axiom backend.
- Run your own postgres instance using Docker 🐳
docker run --name axiom -e POSTGRES_PASSWORD=password -d postgres
This creates the default postgres database, which is all we need to play around with. Specifically, it creates a database with the connection url postgresql://postgres:axiom@127.0.0.1:5432/postgres?sslmode=disable
.
- Populate your database with actual test data
psql run testData.sql
Having an empty database is kind of useless so let's populate it with some dummy data we can use later on when we call the GraphQL endpoints 😉
- Set your environmental variables
PORT
: API access port, defaults to 8080DB_URL
: Database connection URL, defaults to the connection URL shown aboceSERVER_SECRET
: The server secret used to encode the JWT tokens, defaults to passwordGOOGLE_APPLICATION_CREDENTIALS
: Firebase credentials for notifications
God yes, we know you hate these, we forget to set them all the time too 😠. So it might be wise to add a script that sets all of these in one fell sweep, or to add it to your .bashrc
or .zshrc
. Be careful not to commit this script to the repository though, store it outside the repository directory!
- Run the holy grail commands 👍
git clone ssh://git@gitlab.solderneer.me:8002/axiom/backend.git
go get -u ./...
go run github.com/99designs/gqlgen generate
go run ./server.go
This clones and runs the instance of the backend which is on the master
branch right now. Do note that the go generate call is what triggers the regeneration of the resolver stubs for GraphQL, so remember to run the generate call whenever you touch the GraphQL schema implementation, and as general practice whenever you push code to the repository.