This repository contains a GoLang web application that exposes APIs over HTTP. The purpose of this backend is to communicate with mobile/web apps and help users who suffer from Obsessive Compulsive Disorder track their recovery process and reduce rumination (article).
The application is designed to be used with Amazon Web Services. The following services are in use:
- VPC (Virtual Private Cloud)
- EC2 (Elastic Compute Cloud)
- RDS (Relational Database Service)
- IAM (Identity and Access Management)
- ECR (Elastic Container Registry)
- S3 (Simple Storage Service)
- Secrets Manager
- CloudFormation
- Create a Firebase project and enable
Auth
- Generate private key for the Firebase Admin SDK service account in the same project
- Create an AWS account with billing enabled in order to be able to provision all required cloud resources
- Create an S3 bucket called
ocdtracker-api
and upload the file from step 2, but rename it togoogle-app-creds.json
- Download the CloudFormation template and create a CloudFormation stack with it
- Wait until all resources in the stack are fully provisioned (~10m)
- Find the EC2 instance with name
ocdtracker-api
and get the public ip address. This is the base url for the REST API...
Authentication is delegated to Firebase Auth because it provides an efficient way for mobile/web apps to communicate with the API. It gives users the freedom to choose from various auth strategies: Google, email/password, phone number.
In order to gain access to the API, the users have to attach an authorization (bearer) token to each request. All requests to the web server are tied to your personal account. It's not possible to access or modify other users' data.
GET
: fetch all ocd logsPOST
: create a single ocd log entryDELETE
: remove all ocd logs
GET
: fetch a single ocd log entryPATCH
: update a single ocd log entryDELETE
: remove a single ocd log entry
GET
: fetch account dataPATCH
: update account dataDELETE
: remove account and its data