Skip to content
/ Fastapi-boilerplate Public template

The boilerplate for the project using restful Fastapi framework

Notifications You must be signed in to change notification settings

tranlv/Fastapi-boilerplate

Repository files navigation

Fastapi-boilerplate


The boilerplate for the project using restful Fastapi framework


Table of contents

  1. Directory Convention
  2. Development instruction
  3. Test and Code quality
  4. Versioning
  5. Contribution

Directory Convention

/app

/app/manage.py

  • The entry point of the code

/app/config.py

  • Store configuration from env variables

app/extensions

we put everything else here, i.e. interfaces, cache, databases, ORM, i18n, monitor, logging, etc.

/sql

  • sql migration files

/test

  • unit test directory

/docs

  • Store documents files

Development instruction

Running service with docker

  • Init the database (do this only for the first time)
$ make prestart-db-init
  • Run the app:
$ make run
  • Open browser at: http://localhost:8000/docs
  • Authentication
    • Login at api/v1/login/access-token with username, pass predefined in .env
    • Add header Authorization: Bearer {{access_token}} for any request

Test and Code quality

Unit test

$ pytest tests

Code quality

$ pylint ./app
$ mypy ./app
$ black ./tests
  • API design: guide
  • Code style: Pep8 coding style
  • import statement: better to import only necessary function not entire package, i.e. if you only need sqrt():
	Recommended:  		from math import sqrt
	Not recommended:  	import math
  • Exception - EAFP principle: use except/try instead of if/else, and try to use specific exceptions instead of generic exception.

Versioning

We use SemVer for versioning. Please see CHANGELOG.md for more details.

Contribution

Please follow our contribution convention at contribution instructions and code of conduct.

To set up development environment, simply run:

$ pip install -r requirements.txt

If you like this project, you can buy buy me a pizza to motivate me improve on the project.

About

The boilerplate for the project using restful Fastapi framework

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published