Skip to content

smcclure17/api.jedwal.co

Repository files navigation

api.jedwal.co

FastAPI app powering the backend for Jedwal, a tool to turn Google Sheets into REST APIs.

Taxonomy

API

The API routes are served via a FastAPI/Starlette ASGI web server.

Auth

Google Oauth is used for user authentication, integrated with Starlette sessions.

Infrastructure

The app is hosted on AWS via a Cloudformation Template. We use AWS SAM to configure the app as a Serverless project. Front to back, the infrastructure is:

  • ECR: Repository containing the App's Docker Image
  • Lambda: Serverless function that executes containers from the Docker image
  • DynamoDB: Data storage to persist user data and spreadsheet API configurations
  • API Gateway: Gateway to route HTTPS traffic to the Lambda function
  • CloudFront: CDN to cache JSON responses via custom headers emitted from the REST API
  • Route53: DNS hosting to hook up the API to https://api.jedwal.co

The Cloudformation template used to deploy this stack is in lambda.yaml

Alternatively, we could deploy this as an ECS Fargate service. See ecs.yaml

Local Development

Local development is a litle scuffed until we figure out/wire up local auth (Google Oauth) and storage (DynamoDB).

Setup

If necessary, install Python, pyenv, and virtualenv.

brew update
brew install python pyenv pyenv-virtualenv

Install Python 3.12

pyenv install 3.12

Create a virtualenv for this project. We'll use "jedwal" as the name

pyenv virtualenv 3.12 jedwal

Activate the environment

pyenv activate jedwal

Dependencies

Install the necessary requirements

pip install -r requirements.txt

Install the local packages

pip install -e .

Execution

Run the FastAPI dev server with

fastapi dev api.py  # served to localhost:8000