Skip to content

πŸ”¨ This is a template that serves as a kickstarter for a back-end API application. Implemented with FastAPI, Pydantic, SQLAlchemy with a layered architecture structure.

Notifications You must be signed in to change notification settings

douglaschalegre/fastapi-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

42 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

About πŸ§‘πŸ»β€πŸ’»

This repository contains a simple API that serves as a kickstart for new projects using FastAPI, SQLAlchemy and PostgreSQL. It's built with a simple layered architecture, containing domain, service, repository and controller layers. With this layered architecture approach, it's possible to separate concerns and make the codebase more maintainable and scalable.

It's also possible to add more layers if responsibilities grow within a specific layer. That being said, it's important to keep in mind that layers should be as independent as possible, and the dependencies should always point inwards, otherwise, could lead to ciclic dependencies mainly because of Pydantic schemas.

How to run πŸƒπŸ»β€β™‚οΈβ€βž‘οΈ

Install Python

Install Python (version 3.10).

Set and activate virtual environment βš™

In project folder, execute the following commands:

pip install pipenv
export PIPENV_VENV_IN_PROJECT="enabled"
mkdir .venv
pipenv shell
source .venv/Scripts/activate

Set environment variables βš™

Create a .env file with the required environment variables see [.env.example]

Install required dependencies

Run the following installation command:

pipenv install --dev

Run server πŸš€

On virtual environment, execute

pipenv run start

Documentation πŸ“š

While running the server, one can access the API documentation.

TO DO πŸ› 

  • Improve middleware inclusion on app
  • Add profiler (pyinstrument)

About

πŸ”¨ This is a template that serves as a kickstarter for a back-end API application. Implemented with FastAPI, Pydantic, SQLAlchemy with a layered architecture structure.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages