Giter VIP home page Giter VIP logo

mahmudjewel / fastapi-starter-kit Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 5.0 68 KB

FastAPI is modern and super fast Python framework. As a professional Python developer, I developed the repo for FastAPI in a professional way. If the repo will help you, please give a star and fork it.

Python 96.21% Mako 3.79%
fastapi-base fastapi-boilerplate fastapi-scaffold fastapi-starter fastapi-starter-template fastapi-template fastapi-seed fastapi-starter-kit fastapi-boilerplate-code fastapi-project-layout

fastapi-starter-kit's Introduction

FastAPI Starter Kit

A professional FastAPI template

If the repo is helpful, please give a star and fork it.

Click here to clone/fork the repository

Features:

  • FastAPI project structure tree
  • user module
    • id, first name, last name, email as username, password, role, is_active created_at, updated_at
  • admin dashboard => sqladmin
  • authentication => JWT
  • db migration => alembic
  • CORS middleware

Structured Tree

├── alembic     # Manages database migrations
├── alembic.ini
├── app
│   ├── api
│   │   ├── endpoints   # Contains modules for each feature (user, product, payments).
│   │   │   ├── __init__.py
│   │   │   └── user
│   │   │       ├── auth.py
│   │   │       ├── functions.py
│   │   │       ├── __init__.py
│   │   │       └── user.py
│   │   ├── __init__.py
│   │   └── routers     # Contains FastAPI routers, where each router corresponds to a feature.
│   │       ├── api.py
│   │       ├── __init__.py
│   │       └── user.py
│   ├── core    # Contains core functionality like database management, dependencies, etc.
│   │   ├── database.py
│   │   ├── dependencies.py
│   │   ├── __init__.py
│   │   └── settings.py
│   ├── __init__.py
│   ├── main.py     # Initializes the FastAPI app and brings together various components.
│   ├── models      # Contains modules defining database models for users, products, payments, etc.
│   │   ├── admin.py
│   │   ├── common.py
│   │   ├── __init__.py
│   │   └── user.py
│   ├── schemas   # Pydantic model for data validation
│   │   ├── __init__.py
│   │   └── user.py
│   └── utils       # Can include utility functions that are used across different features.
├── requirements.txt # Lists project dependencies.

app/api/endpoints/: Contains modules for each feature (user, product, payments).

app/api/routers/: Contains FastAPI routers, where each router corresponds to a feature.

app/models/: Contains modules defining database models for users, products, payments, etc.

app/core/: Contains core functionality like database management, dependencies, etc.

app/utils/: Can include utility functions that are used across different features.

app/main.py: Initializes the FastAPI app and brings together various components.

tests/: Houses your test cases.

alembic/: Manages database migrations.

docs/: Holds documentation files.

scripts/: Contains utility scripts.

requirements.txt: Lists project dependencies.

Setup

The first thing to do is to clone the repository:

$ https://github.com/MahmudJewel/fastapi-starter-kit

Create a virtual environment to install dependencies in and activate it:

$ cd fastapi-starter-kit
$ python -m venv venv
$ source venv/bin/activate

Then install the dependencies:

# for fixed version
(venv)$ pip install -r requirements.txt

# or for updated version
(venv)$ pip install -r dev.txt

Note the (venv) in front of the prompt. This indicates that this terminal session operates in a virtual environment set up by virtualenv2.

Once pip has finished downloading the dependencies:

# db migrations
(venv)$ alembic upgrade head

# start the server
(venv)$ uvicorn app.main:app --reload

User module's API

SRL METHOD ROUTE FUNCTIONALITY Fields
1 POST /login Login user email, password
2 POST /users/ Create new user email, password, first name, last name
3 GET /users/ Get all users list email, password, first name, last name, role, is_active, created_at, updated_at, id
4 GET /users/me/ Get current user details email, password, first name, last name, role, is_active, created_at, updated_at, id
5 GET /users/{user_id} Get indivisual users details email, password, first name, last name, role, is_active, created_at, updated_at, id
6 PATCH /users/{user_id} Update the user partially email, password, is_active, role
7 DELETE /users/{user_id} Delete the user None
8 GET / Home page None
9 GET /admin Admin Dashboard None

Tools

Back-end

Language:

Python

Frameworks:

FastAPI
pydantic

Other libraries / tools:

SQLAlchemy
starlette
uvicorn
python-jose
alembic

For production level project, Please follow this repo https://github.com/MahmudJewel/fastapi-production-kit

Happy Coding

fastapi-starter-kit's People

Contributors

mahmudjewel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fastapi-starter-kit's Issues

Initial startup, create of new user

Hi,

This starting point for fastapi looks promising to me, however i have some questions, maybe the readme could be updated with this information.

  1. Can you give some more details on how users are stored, what is the location of the DB file for example backup purposes?
  2. Everyone can create a user and update the role of users, shouldn't this be only available for admin roles?
  3. The passwords transferred to login are readable?

thx for feedback!

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.