https://github.com/code4mk/fastapi-template
production ready fastapi template
https://github.com/code4mk/fastapi-template
Last synced: 10 months ago
JSON representation
production ready fastapi template
- Host: GitHub
- URL: https://github.com/code4mk/fastapi-template
- Owner: code4mk
- Created: 2025-01-15T09:20:43.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-02-18T20:31:57.000Z (10 months ago)
- Last Synced: 2025-02-18T21:33:24.195Z (10 months ago)
- Language: Python
- Size: 331 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FastApi project template
## Setup project
```bash
# Activate virtual environment
pipenv shell
# Install dependencies
pipenv install
```
## Add env
* add env file in root directory
* copy from `.env.example`
```bash
.env
```
## Run project
run the project
```bash
uvicorn app.main:app --reload --port 8000
# or
./run-project.sh
```
## Database migration process with Alembic
Alembic is a database migration tool for SQLAlchemy.
### revision (migration)
you can use the following command to create a new migration file.
```bash
alembic revision --autogenerate -m "initial project"
```
this will create a new migration file in the `alembic/versions` directory.
### upgrade (migrate)
you can use the following command to migrate the database.
```bash
alembic upgrade head
```
## Directory structure
```bash
├── app/
│ ├── api/
│ │ ├── v1/
│ │ │ └── user.py
│ │ ├── health.py
│ │ └── root_index.py
│ ├── config/
│ │ ├── authorization.py
│ │ └── cors.py
│ ├── database/
│ │ └── database.py
│ ├── middleware/
│ │ └── authorization_middleware.py
│ ├── models/
│ │ └── users.py
│ ├── schemas/
│ │ └── user_schema.py
│ ├── serializers/
│ │ └── user_serializer.py
│ ├── services/
│ │ └── user_service.py
│ ├── templates/
│ │ ├── mails/
│ │ │ ├── css/
│ │ │ │ └── mail.css
│ │ │ └── welcome_email.html
│ │ └── user.html
│ ├── utils/
│ │ ├── mailer/
│ │ │ ├── inline_css.py
│ │ │ ├── mail.py
│ │ │ └── mail_templating.py
│ │ ├── base.py
│ │ ├── jwt_utils.py
│ │ ├── paginate.py
│ │ ├── password.py
│ │ └── validation.py
│ ├── __init__.py
│ └── main.py
├── alembic/*
├── docker/*
├── alembic.ini
├── .env
├── .env.example
├── .gitignore
├── build.sh
├── Pipfile
├── Pipfile.lock
├── README.md
└── run-project.sh
```
> [!NOTE]
> This project needs python 3.12 or higher
## postman collection documentation
* [postman collection documentation](https://documenter.getpostman.com/view/9920489/2sAYQZGBNJ)
## docs
* [linting and formatting](_docs/lint-formatting.md)
* [testing](_docs/testing.md)