GithubHelp home page GithubHelp logo

fastapi-api's Introduction

Requirements

python 3.9.10

Project setup

  1. create virtual environment
python -m venv venv
  1. activate virtual environment
source venv/bin/activate
  1. install requirements
pip install -r api/requirements.txt
  1. create api/.env using api/.env.example

Run locally

  1. start the api server
cd api
uvicorn main:app --reload

API docs

API docs are available when running locally: http://127.0.0.1:8000/docs

Infrastructure

Make sure you stay in the same region!

AWS S3

Used to store files uploaded via the API and the lambda deployment package.

  1. Create an S3 bucket

AWS Lambda

Serverless deployment of our API.

  1. Create new lambda function with Python 3.9 runtime
  2. Upload deployment package from S3 (see Deployment)
  3. Update lambda handler to main.handler
  4. Add S3_BUCKET environment variable to the lambda configuration

AWS API Gateway

  1. Create new public REST API.
  2. Create a new method for ANY action.
    • Select the Lambda Function integration type
    • Check "on" Use Lambda Proxy Integration
    • Set Lambda Function to the Lambda function name
    • Confirm that you are giving API Gateway permissions to invoke the Lambda function
  3. Create a resource
    • Check "on" the option to Configure as proxy resource
    • Select the Lambda Function integration type
    • Set Lambda Function to the Lambda function name
    • Confirm that you are giving API Gateway permissions to invoke the Lambda function
  4. Deploy API
    • Create new stage

Deployment

It's a manual process right now

  1. Zip up a deployment package for AWS Lambda.
source venv/bin/activate
rm -rf api.zip
cd ./venv/lib/python3.9/site-packages
zip -r9 ../../../../api.zip .
cd ../../../../api && zip -x .env -g ../api.zip -r .
  1. Upload your zip file to your AWS S3 bucket.
  2. Update lambda source code

TODO

  • containerize local dev environment
  • debgging and logging tools
  • review and organize code
  • define branching structure
  • authentication
  • automate infrastructure creation
  • automate deployments, CI/CD
  • testing automation and tooling
  • figure out how to deploy docs

Helpful links

fastapi-api's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.