In 2015, GOP legislators changed district lines 105 and 111 to make sure their representatives would stay in power after barely winning re-election the year prior. This practice is called "gerrymandering" and robs Georgian citizens the right for a fair vote. With sophisticated mapping technology, it is becoming easier for politicians to "rig" elections. Fair Districts GA is a non-profit that recruits volunteers to submit letters to newspapers in the hope of bringing more attention to the issue.
The platform we will build will automate this assignment process. Recently, Fair Districts GA has been having a hard time managing all their data and the assignment process and would like to streamline the process.
- Next.js
- PostgreSQL
- Prisma (ORM on top of Postgres)
Node 16.13.0 (you can use nvm
to alter this)
Run git clone https://github.com/bitsofgood/fair-districts-ga.git
to clone the repo onto your local machine and then run npm i
or yarn i
- If you don't have brew, install it using the command below in your terminal. Brew is a package manager that makes installing applications much easier
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Make sure to update brew and that it is healthy by running the commands below.
brew doctor
should report no errors.brew update brew doctor
- Run the command below to install PostgreSQL.
brew install postgresql
- If postgres is installed correct, the following command below should work. Please contact Manu if it doesn't work.
psql --version
- By default a database called
postgres
will be created. Type the following command to startpsql
.psql postgres
- Now, we will create a database called
fair_districts
, so run the followingCREATE DATABASE fair_districts;
- To ensure the database is created, type
\l
and see if it appears in your terminal as a database.
- Follow this installation tutorial: https://www.postgresqltutorial.com/install-postgresql/
- Open up the psql terminal, and run the following command.
-
CREATE DATABASE fair_districts;
- To ensure the database is created, type
\l
and see if it appears in your terminal as a database.
- Run the following commands.
sudo apt-get update sudo apt-get install postgresql
- Run this command to access the postgres user
sudo -i -u postgres
- Run the following command
mysql
- Now, we will create a database called
fair_districts
, so run the followingCREATE DATABASE fair_districts;
- To ensure the database is created, type
\l
and see if it appears in your terminal as a database.
- In the command line, run
docker run -p 5432:5432 --name NAME -e POSTGRES_PASSWORD=PASSWORD -d postgres
- The username by default is
postgres
and the password is whatever you set - SSH into your container
- psql -U postgres
- Create the
fair_districts
databaseCREATE DATABASE fair_districts;
- To ensure the database is created, type
\l
and see if it appears in your terminal as a database.
- Navigate to the repository you clone and run the following command
npm install prisma --save-dev
- Create a .env file and for your repo and type the following
DATABASE_URL="postgresql://{USER}:{PASSWORD}@localhost:5432/fair_districts" NEXTAUTH_URL="http://localhost:3000" GOOGLE_CLIENT_ID="651451308980-n2ucut2m4sk6sqecs7ap6q0j43b79bv0.apps.googleusercontent.com" GOOGLE_CLIENT_SECRET="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"
- Run the following command (make sure your .env is working). This will make our database have the appropriate schemas and tables.
npx prisma migrate dev
- You can verify this by accessing the database and running the following command
\c fair_districts \dt
- Populate the database with predefined values by adding
"seed": "node prisma/seed.js"
underscripts
inpackage.json
and runningnpm run seed
. This should populate the County relation with values. You can verify this by running the following commandSELECT * from "County";
Please contact Manu if you have any issues. Don't worry about email authentication for now. You will be using Google OAuth to sign in to your localhost repos whenever you are building out features. On Vercel previews, I'm working to make email authentication working, because Google OAuth is annoying. I'll be setting up an SMTP server soon and update you accordingly. You can use yarn dev
or npm dev
to run the application.
To contribute to the repo, we will be using a rather simple system. For each issue that you work on, all you need to do is create a new branch in the following format [your-name]/[brief title of issue] (ex: manu/analytics-integration). You should make all your changes in that branch.
As you make changes to your branch, because other developers will be working on the repository, I HIGHLY recommend running git stash
to stash your local copy in memory and run git pull
whenever you develop. This way in case there is an issue with git pull, you can always run git stash pop to return back locally.
Once you feel like your work is done, submit a pull request to merge your branch into the master branch, and I will review it. Please link it to the issue you are assigned.
The data provided was very structured and had natural relationships between different tables. Also, the data doesn't need to be horizontally scaled which means NoSQL isn't required here. SQL also provides more powerful analytics tools which keeps us flexible in case of changes