A mobile app that connects people through shared interests in events rather than superficial swipes
First, understand the tech stack:
- The back end is written in Go and utilizes ogen to generate API routes from OpenAPI specification. The back end stores data and serves API consumers, such as the mobile app
- The database is PostgreSQL, and it simply stores data and gives it to the back end upon request
- The front end is React Native written with TypeScript and uses Expo as a build tool. Users on iOS and Android will use the mobile app to interact with our core service while the app makes requests to our back end
Before we can compile and run our application, we need to install several languages, package managers, and various tools. The installation process can vary by tool and operating system, so follow the provided installation instructions for each item below
- Go, our primary backend language
- Afterwards, install all go dependencies with the command
go mod download
in thebackend/
directory. This needs to be re-run if dependencies change
- Afterwards, install all go dependencies with the command
- golangci-lint, a powerful Go linter (required for development)
- PostgreSQL, our SQL database
- Docker and Docker Compose, used to build our back end in isolated containers
- Node, our frontend package manager
- Afterwards, install all Node dependencies with the command
npm install
in thefrontend/
directory. This needs to be re-run if dependencies change
- Afterwards, install all Node dependencies with the command
- Task, a tool for running useful development tasks and a spiritual successor to Make. Our Taskfiles make it easy for developers to build and run our application quickly and consistently
- pre-commit, a tool for running shared Git hooks on pre-commit (required for development)
- Afterwards, install all Git hooks with the command
pre-commit install --hook-type commit-msg --hook-type pre-push
in the root directory. This needs to be re-run if hooks change
- Afterwards, install all Git hooks with the command
If everything was successful, you can now compile and run the project!
Use task
to check, test, build, and execute the project locally, as targets have already been defined for efficient development. Consider investigating the Taskfiles to learn how everything works!
Note
This won't work until you have the necessary tools installed on your system
The back end has two components, the PostgreSQL database and the Go server. These components can each be run either on your local machine or in a Docker container, and the choice is yours!
Note
Running locally will provide faster build times and better performance, while Docker will be more consistent/reliable and won't conflict with other installations and processes on your machine. Running the database in Docker and the server locally is a nice middle-ground
- The API endpoints defined in
openapi.yaml
are exposed to the public, and accessible over HTTP - The Handler defines methods for each API endpoint that validate inputs and delegate logic to the Controller
- The Controller executes business logic, performing operations and manipulating the database. The meat and potatoes of our code will live here
Regardless of how you choose to run them, the two components must be configured to speak to each other, which is accomplished with environment variables. If you have never used them, they are commonly specified with this format VAR1=value VAR2=value ./executable
. It can be annoying to specify multiple values every time, such as when we configure the server to find and connect to the database, so the root Taskfile and Docker have been configured to read values from an .env
file in the root directory. The back end should error and let you know if you are missing required variables, but you can also look at .env.sample
to see what variables you need to define in your environment
- Install PostgreSQL and start it (this is system dependent)
- Initialize the server's credentials by running
createuser ${DB_USER} --password ${DB_PASSWORD}
. Replace those fields with whatever you want, but make sure to add them to your.env
file - Initialize the actual database by running
createdb ${DB_NAME}
and add the name to your.env
file - Define
DB_HOST=localhost
in your.env
file - Define the
DB_PORT
in your.env
file as the port PostgreSQL is running on (5432 by default) - Run the server with
task backend:run
, optionally defining the server port asPORT
in the.env
file - Access the back end server at
localhost:${PORT}
, orlocalhost:8080
if a port was not specified
- Add the database credentials
DB_USER
andDB_PASSWORD
to your.env
file. Use whatever values you want, but make sure to add them to your.env
file - Add
DB_NAME=couplet
,DB_HOST=localhost
, andDB_PORT=5432
to your.env
file so the server can connect to the database in Docker - Run the database in Docker with
sudo docker-compose up database
- Run the server with
task backend:run
, optionally defining the server port asPORT
in the.env
file - Access the back end server at
localhost:${PORT}
, orlocalhost:8080
if a port was not specified
- Add the database credentials
DB_USER
andDB_PASSWORD
to your.env
file. Use whatever values you want, but make sure to add them to your.env
file - Add
DB_NAME=couplet
,DB_HOST=localhost
, andDB_PORT=5432
to your.env
file so the server can connect to the database in Docker - Optionally define the server port as
PORT
in the.env
file - Run the database and the server in Docker with
sudo docker-compose up --build
- Access the back end server at
localhost:${PORT}
, orlocalhost:8080
if a port was not specified Bonus: If running the back end server in Docker, you can view the API documentation with a simple UI atlocalhost:80
- Download the Expo Go app on your phone from either the App Store or the Google Play store
- From the
frontend/
directory, runnpx expo start
- Scan the QR code on your phone and wait for the app to load
- If you want to run the app on your computer, you will need to make sure you spin up the relevant emulator. This is either an Android Studio emulator if you want to run on Android, or an XCode simulator if you want to run on iOS
- To run on android, press a. To run on iOS, press i
- Nobody is allowed to push to
main
. Open a new branch, push to it, and open a pull request to get your changes intomain
- Your code must pass formatter and linter checks to make valid commits
- You must write useful tests for your pull requests to be accepted
- Your code must pass GitHub Actions checks (formatters, linters, and tests) for your pull requests to be accepted
- At least one TL must review and accept your PR before merging
- Read other developers' pull requests and give feedback! This is how we all improve and build a great product
- Be kind in code critique. Describe issues as properties of the code, not the developer (Good: "the code does not solve the issue", bad: "you failed to solve the problem)
- Give actionable feedback. Everyone wants to improve, but that requires advice on how to improve (and often an explanation of why improvement is necessary)