Skip to content

q00Dree/fastapi-based-microservices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example of how to deploy microservices with FastAPI, PostgreSQL, docker-compose.

This project created from this title.

1) Clone repository and deploy all services with one command below.

git clone https://github.com/q00Dree/fastapi-based-microservices.git \
&& cd fastapi-based-microservices \
&& cd deploy \
&& bash deploy.sh

2) Check APIs documentation provided by Swagger OpenAPI.

  • Movies documentation.
curl -X 'GET' \
  'http://localhost:8080/api/v1/movies/docs' \
  -H 'accept: application/json'
  • Casts documentation.
curl -X 'GET' \
  'http://localhost:8080/api/v1/casts/docs' \
  -H 'accept: application/json'

3) Interact with APIs.

  • Create casts.
curl -X 'POST' \
  'http://localhost:8080/api/v1/casts/' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Samuel Jackson",
  "nationality": "USA"
}'
  • Create movies.
curl -X 'POST' \
  'http://localhost:8080/api/v1/movies/' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Pulp Fiction",
  "plot": "Tarantino's best plot ever.",
  "genres": ["Comedy","Neo-noir","Crime"],
  "casts_id": [1]
}'
  • Show all movies.
curl -X 'GET' \
  'http://localhost:8080/api/v1/movies/' \
  -H 'accept: application/json'
  • Find and show info about casts by given id.
curl -X 'GET' \
  'http://localhost:8080/api/v1/casts/1/' \
  -H 'accept: application/json'
  • Find and show info about movies by given id.
curl -X 'GET' \
  'http://localhost:8080/api/v1/movies/1/' \
  -H 'accept: application/json'
  • Update movies by given id and data in the body.
curl -X 'PUT' \
  'http://localhost:8080/api/v1/movies/' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Pulp Fiction.",
  "plot": "Tarantino's best plot ever. No need to film second part.",
  "genres": ["Comedy","Neo-noir","Crime"],
  "casts_id": [1]
}'
  • Delete movies by given id.
curl -X 'DELETE' \
  'http://localhost:8080/api/v1/movies/1' \
  -H 'accept: application/json'

4) Enjoy =)

About

Simple example of how to deploy microservices with FastAPI + PostgreSQL.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •