• Stars
    star
    110
  • Rank 316,770 (Top 7 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 5 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple asynchronous API implemented with Fast-Api framework utilizing Postgres as a Database and SqlAlchemy as ORM . GitHub Actions as CI/CD Pipeline

FastAPI Example App

fastapi-0.104.1-informational CodeQL Docker Compose Actions Workflow

"Buy Me A Coffee" Twitter

This repository contains code for asynchronous example api using the Fast Api framework ,Uvicorn server and Postgres Database to perform crud operations on notes.

Fast-api

Accompanying Article

Read the full tutorial here

Installation method 1 (Run application locally)

  1. Clone this Repo

    git clone (https://github.com/KenMwaura1/Fast-Api-example)

  2. Cd into the Fast-Api folder

    cd Fast-Api-example

  3. Create a virtual environment

    python3 -m venv venv

  4. Activate virtualenv

    source venv/bin/activate

    For zsh users

    source venv/bin/activate.zsh

    For bash users

    source venv/bin/activate.bash

    For fish users

    source venv/bin/activate.fish

  5. Cd into the src folder

    cd src

  6. Install the required packages

    python -m pip install -r requirements.txt

  7. Start the app

    python main.py

    7b. Start the app using Uvicorn

    uvicorn app.main:app --reload --workers 1 --host 0.0.0.0 --port 8002
  8. Ensure you have a Postgres Database running locally. Additionally create a fast_api_dev database with user **fast_api** having required privileges. OR Change the DATABASE_URL variable in the .env file inside then app folder to reflect database settings (user:password/db)

  9. Check the app on notes Open your browser and navigate to docs to view the swagger documentation for the api.

Vue Frontend (Optional)

The is a simple Vue frontend using vite that was added. However it is an optional step in running the application.

Installation

Ensure you have Node.js installed. any version above 16 should work.

While inside the root folder Fast-Api-example

  1. Cd into the vue-client folder.

       cd vue-client
  2. Install the required dependencies. for NPM:

       npm install

    for Yarn:

       yarn install
  3. Start the Vue app for NPM:

       npm run serve

    for Yarn:

       yarn serve
  4. Open your browser and navigate to notes

Installation method 2 (Run Locally using Docker)

  1. Ensure Docker is installed.

  2. Ensure Docker Compose is installed.

  3. Clone this Repo

    git clone (https://github.com/KenMwaura1/Fast-Api-example)

  4. Change into the directory

    cd Fast-Api-example

  5. Use Docker-Compose to spin up containers

    docker-compose up -d --build

  6. If everything completes should be available on notes

  7. Docs are generated on docs

Tests

Tests are available using pytest Run them using pytest . while in the root directory (/Fast-Api-example)

Documentation

Open API Documentation is provided by Redoc

Contributing

Contributions are welcome, please open an issue or submit a PR.

Github Actions

Github actions are used to run tests and build the docker image. The docker image is pushed to Docker Hub. Inorder to effectively use the actions you will need to add the following secrets to your repository settings. DOCKER_USERNAME and DOCKER_PASSWORD for the docker hub account. This is to enable the docker login step in the workflow and push the image to the docker hub repository. Alternatively you can remove the step from the workflow by commenting it out.

It is also possible to use Github Packages to store the docker image. In this case you will need to add the following secrets to your repository settings. CR_PAT and CR_USERNAME for the github packages account. In our case the username is the github username. The CR_PAT is a personal access token with the write:packages scope. This is to enable the docker login step in the workflow and push the image to the github packages repository. Alternatively you can remove the step from the workflow by commenting it out.

The docker image is also tagged with the commit sha and pushed to the docker hub repository. This is to enable the image to be pulled by the docker-compose file in the root directory. The docker-compose file is used to spin up the containers locally. It is available on Github Packages as well.

Docker Hub

The docker image is available on Docker Hub

License

MIT

More Repositories

1

py-crypto-bot

simple python crypto bot to trade crypto on Binance based on RSI. Utilizing web sockets to get real-time prices. Store the data in a Redis instance then a Postgres DB on candle close
Python
32
star
2

Fast-Api-Grafana-Starter

Simple asynchronous API implemented with Fast-Api framework utilizing Postgres as a Database and SqlAlchemy as ORM . Grafana for monitoring using Prometheus
Python
11
star
3

simple-web-scraper

Simple web scraper to get player data using beatiful-soup4 and PostgreSQL as a database. SQLAlchemy as an ORM
Python
9
star
4

nse-stock-scraper

This is Web Scraper utilizing Scrapy Framework, MongoDB and AfricasTalking to get stock prices for companies listed on the Nairobi Stock Exchange. This project will store ticker name and price as well notify via SMS once properly setup via AfricasTalking.
Python
9
star
5

zoo_Django_Actions

Sample Django Web App for GitHub Actions
Python
8
star
6

Fast-Api-Vue

Simple asynchronous API implemented with Fast-Api framework utilizing Postgres as a Database and SqlAlchemy as ORM . GiHub Actions as CI/CD Pipeline. Vue + Daisy UI for the frontend
Python
8
star
7

twilio-quest

This repo contains my solutions from the various Twilio Quest Challenges
Python
6
star
8

flask_starter_app

simple flask starter app utilizing docker
Python
5
star
9

daily-news-scraper

This a simple news scraper and notification script
Python
5
star
10

anime

simple flask app to showcase anime using myanimelist unofficial api.
CSS
4
star
11

customer-rewards

This is a simple program to query a PostgreSQL database for customer details and reward them with airtime
Python
4
star
12

stock-price-scraper

Web scraper utilizing scrapy to scrape live stock prices from the Nairobi Stock Exchange
Python
4
star
13

py-amazon-scraper

This is an amazon.com web scraper for laptop prices utilizing python and the scrapy framework
Python
4
star
14

FastAPI-Backend-Template

A backend project template with FastAPI, PostgreSQL with asynchronous SQLAlchemy 2.0, Alembic for asynchronous database migration, and Docker.
Python
3
star
15

go-todo-api

A REST api in Go
Go
3
star
16

fastapi_docker_starter

Fastapi docker app
Python
3
star
17

stock-automation

simple script to retrieve stock information for various companies and analyze with pandas
Python
3
star
18

react-login-form

Simple login form made with React, Chakra UI
JavaScript
3
star
19

zoo_neighborhood

A Django web application that allows you to be in the loop about everything happening in your neighborhood. From contact information of different handyman to meeting announcements or even alerts.
Python
3
star
20

Automated-Airtime-Disbursal

This is a simple python script to automate airtime disbursal using google forms, python and AfricasTalking
Python
3
star
21

Fast-Api-HTMX-Example

This repository serves as a demonstration of building a web application using FastAPI on the backend and htmx on the frontend. FastAPI, a modern, fast web framework for building APIs with Python 3.7+ based on standard Python type hints, pairs seamlessly with htmx, a lightweight JavaScript library for AJAX interactions.
Python
3
star
22

z-blog

Blog platform for the AWS cloud bootcamp
JavaScript
2
star
23

budgetApp

Django app for budgeting
Python
2
star
24

zoo_pitch

A flask application that allows users to use that one minute wisely. The users will submit their one minute pitches and other users will vote on them and leave comments to give their feedback on them.
Python
2
star
25

zoo-gram

a Django clone of the website for the popular photo app Instagram
HTML
2
star
26

python-sort

Simple python script to generate a list of random numbers and insert them in a db
Python
2
star
27

Africas-Talking-Multiple-SMS

Python
2
star
28

docker-setup

This repo holds the config files and commands to spin up development containers for my personal setup.
Shell
2
star
29

dotnet

C#
2
star
30

Python_News_Updates

A flask application that will help people list and preview news articles from various sources. Using the News Api
Python
2
star
31

zoo-texts

Simple flask application using Flask and Africas Talking sdk to get and update the client when a streamer is online
HTML
1
star
32

pusher-realtime-table

Build a realtime table using Flask and Pusher Channels
HTML
1
star
33

web-blog

This is simple blog-web app created using Flask,Bootstrap and MongoDB
JavaScript
1
star
34

Moringa_Core_3

Project for Flask Week 3
Python
1
star
35

FastApi-Signoz-App

Simple asynchronous API implemented with Fast-Api framework utilizing Postgres as a Database and SqlAlchemy as ORM . GitHub Actions as CI/CD Pipeline
Python
1
star
36

tribune

simple Django news web app
Python
1
star
37

twitter_unfollow

Using Tweepy and Pandas to unfollow accounts that don't tweet frequently
Python
1
star
38

KenMwaura1

Personal Github profile
1
star
39

Moringa_Core_2

simple scripts for week 2 in the core section of Moringa School
Python
1
star
40

movie-app

Vue Frontend for a movie app using the OMDB api
Vue
1
star
41

permit

Python
1
star
42

Nuvo-data-cleaning-functions

Created with CodeSandbox
TypeScript
1
star
43

bubble

Termianl apps using bubbletea package
Go
1
star
44

django-portfolio

Simple portfolio website to showcase projects and an additional blog
Python
1
star
45

twitch-updates

Python script to notify a user via text once their favorite stream starts.
Python
1
star
46

laravel-news-app

Laravel News app using the News Api to get and display current news
PHP
1
star
47

Happy-Birthday

Simple html css page for my birthday.
CSS
1
star
48

Python_Pasword_Store

a password locker CLI application that allows adding of details, a login username and password and account name.
Python
1
star
49

affinidi-capstone

JavaScript
1
star
50

zoo_pictures

A Django project that is a personal gallery application that you display your photos for others to see.
HTML
1
star
51

zoo_blog

a personal blogging website where you can create and share your opinions and other users can read and comment on them. Additionally, add a feature that displays random quotes to inspire your users.
Python
1
star
52

NFT_Marketplace

With the rise of web 3 and Block-chain technology recently. Products and services built on or using the technology have gained traction. Non fungible Tokens are among the top, however most people would like an easy experience when buying and listing their assets. The app will aim to allow users easy time to buy via a local payment method(Mpesa) or existing wallets and list NFTs.
1
star
53

price_tracker_backend

A Django API to display items and their current up-to-date prices from different online retailers in one platform. Utilizing scrapy to periodically scrape the latest prices from different online retailers. Store in a PostgreSQL database and make available via an API.
Python
1
star
54

python-hacks

Python
1
star