22
33English | [ 简体中文] ( ./README.zh-CN.md )
44
5- This is a base project of the FastAPI framework, in production
5+ This is a basic project of the FastAPI framework, using a pseudo three-tier architecture, ** still in production**
66
7- It‘s purpose is to allow you to develop your project directly with it
8- as your base project
7+ It‘s purpose is to allow you to develop your project directly with it as your base project
98
109Support python3.10 and above
1110
@@ -15,6 +14,7 @@ Support python3.10 and above
1514- [x] Pydantic
1615- [x] SQLAlchemy
1716- [x] Alembic
17+ - [x] Casbin
1818- [x] MySQL
1919- [x] Redis
2020- [x] APScheduler
@@ -32,49 +32,62 @@ git clone https://github.com/wu-clan/fastapi_best_architecture.git
3232
33331 . Install dependencies
3434
35- ``` shell
36- pip install -r requirements.txt
37- ```
35+ ``` shell
36+ pip install -r requirements.txt
37+ ```
3838
39392 . Create a database ` fba ` , choose utf8mb4 encode
40403 . Install and start Redis
41414 . create a ` .env ` file in the ` backend/app/ ` directory
4242
43- ` ` ` shell
44- cd backend/app/
45-
46- touch .env
47- ` ` `
43+ ``` shell
44+ cd backend/app/
4845
49- 5. Copy ` .env.example` to ` .env` and view ` backend/app/core/conf.py` , update database configuration information
46+ touch .env
47+ ```
48+
49+ 5 . Copy ` .env.example ` to ` .env `
50+
51+ ``` shell
52+ cp .env.example .env
53+ ```
54+
50556 . Perform a database migration [ alembic] ( https://alembic.sqlalchemy.org/en/latest/tutorial.html )
5156
52- ` ` ` shell
53- cd backend/app/
54-
55- # Generate the migration file
56- alembic revision --autogenerate
57-
58- # Perform the migration
59- alembic upgrade head
60- ` ` `
57+ ``` shell
58+ cd backend/app/
6159
60+ # Generate the migration file
61+ alembic revision --autogenerate
62+
63+ # Perform the migration
64+ alembic upgrade head
65+ ```
66+
62677 . Execute the ` backend/app/main.py ` file startup service
63688 . Browser access: http://127.0.0.1:8000/v1/docs
6469
6570---
6671
6772### 2:Docker
6873
69- 1. Run the one-click start command in the directory where the ` docker-compose.yml` file is located
74+ 1 . Go to the directory where the ` docker-compose.yml ` file is located and create the environment variable file ` .env `
7075
71- ` ` ` shell
72- docker-compose up -d --build
73- ` ` `
76+ ``` shell
77+ cp .env.server ../../backend/app/.env
7478
75- 2. Wait for the command to finish automatically
79+ # This command is optional
80+ cp .env.docker .env
81+ ```
82+
83+ 2 . Execute the one-click start command
7684
77- 3. Browser access: http://127.0.0.1:8000/v1/docs
85+ ``` shell
86+ docker-compose up -d -build
87+ ```
88+
89+ 3 . Wait for the command to finish automatically
90+ 4 . Browser access: http://127.0.0.1:8000/v1/docs
7891
7992## Init the test data
8093
@@ -85,13 +98,12 @@ Execute the `backend/app/init_test_data.py` file
8598Perform tests via pytest
8699
871001 . Create a database ` fba_test ` , choose utf8mb4 encode
88-
891012 . First, go to the app directory
90102
91103 ``` shell
92104 cd backend/app/
93105 ```
94-
106+
951073 . Init the test data
96108
97109 ``` shell
0 commit comments