Skip to content

ethanyanjiali/penny-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Penny API CircleCI

Penny (http://mypenny.co) is a free tool to help people split complicated group expenses with their friends. The service is launched in 2016 and getting more and more popular nowadays because it's so easy to use. Not like other group expense tool, Penny doesn't require sign up or login. You just need to share the URL to your friends, then everyone can start filling the expense they paid from their own device. In the meantime, the settlement will be calculated automatically to guide you how to pay out.

In order to make it not only free for users, but also for developers, I've open sourced this project in 2018. This backend service is running on Google Compute Engine. DNS is managed by AWS Route 53, where the CNAME http://api.mypenny.co is defined.

Devlopement

  1. Make sure Python 3.7.0 is installed
  2. Setup virtualenv
    python3 -m venv env
  3. Activate virtual env
    source ./env/bin/activate
  4. Download dependencies
    pip install -r requirements.txt
  5. Start server
    ./scripts/debug.sh
  6. Deactivate after development
    deactivate

Deployment

This project use Circle CI to build and publish the docker image, and then update the Google Compute Engine with the new container image.

I built a custom image which contains both gcloud-sdk and python3.7 here

https://hub.docker.com/r/liyanjia92/gcloudpython/

Circle CI will pull this image, authenticate through gcloud with the JSON key of the service account, then download the instance config for the app. Next, docker will build a new image for the project, login with GCP JSON key, then push to gcr.io (Google Container Registry)

If you need to deploy manually:

  1. Make sure Docker is installed
  2. Make sure gcloud is also installed
  3. Build the image
    docker build -t penny-api:$(git log -1 --pretty=%h) .
  4. Run a container with this image for testing
    docker run -p 80:8000 penny-api:$(git log -1 --pretty=%h)
  5. GET http://localhost/common/lang to ensure the container runs correctly
  6. Push the image to gcr.io
    docker push gci.io/mypennyco/penny-api:$(git log -1 --pretty=%h)

TODOS

  1. Refactor the validation logic for event/expense
  2. Add unit tests

About

The API server of Penny

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published