You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+135Lines changed: 135 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,48 @@ The above listed technologies are just the main ones. There are other technologi
43
43
44
44
My choice for a project development worklow is usually the [Trunk-Based Development](https://trunkbaseddevelopment.com/) because of the straight forward approach in the collaboration workflow, hence the name `trunk` for the main branch repository instead of `master` or `main`.
45
45
46
+
## What Code is included?
47
+
48
+
For the backend application:
49
+
* The project, linter, and test configurations in `backend/pyproject.toml`.
50
+
* 3 settings classes (development, staging, production) with the super class in `backend/src/config/settings/base.py`.
51
+
* Event logger in `backend/src/config/events.py`.
52
+
* The `Account` object table model in `backend/src/models/tables/account.py`.
53
+
* The `Account` object schema model in `backend/src/models/schemas/account.py`.
54
+
* PostgreSQL database via asynchronous SQLAlchemy 2.0 in `backend/src/repository/database`.
55
+
* Database-related events e.g. databse table registration by app startup in `backend/src/repository/events.py`.
56
+
* C. R. U. D. methods for `Account` object in `backend/src/repository/crud/account.py`.
57
+
* Table classes registration file in `backend/src/repository/base.py`.
58
+
* Alembic setup for auto generating asynchronous database migrations in `backend/src/repository/migration/**`.
59
+
* Alembic main configuration file in `backend/alembic.ini`.
60
+
* Dependency injection for database session and repository in `backend/src/api/**`.
61
+
* API endpoints for `Account` signup and signin in `backend/src/api/routes/authentication.py`.
62
+
* API endpoints for `Account` get all, get 1, update, and delete in `backend/src/api/routes/account.py`.
63
+
* API endpoints registration file in `backend/src/api/endpoints`.
64
+
* Password hashing, JWT for authorization, and simple verification functions in `backend/src/securities/**`.
65
+
* Helper functions, string messages, and error handling in `backend/src/utilities/**`.
66
+
* A comprehensive FastAPI application initialization in `backend/src/main.py`.
67
+
68
+
For testing I have prepared the following simple code to kick start your test-driven development:
69
+
* A simple replication of the backend application for testing purposes and the asynchronous test client in `backend/tests/conftest.py`.
70
+
* 2 simple test functions to test the backend application initialization in `tests/unit_tests/test_src.py`.
71
+
72
+
For the DevOps:
73
+
* A simple `build` job to test the compilation of the source code for the backend application in `.github/workflows/ci-backend.yaml`.
74
+
* A simple linting job called `code-style` with black, isort, flake8, and mypy in `.github/workflows/ci-backend.yaml`.
75
+
* An automated testing with `PyTest` and an automated test reporting with `Codecov` in in `.github/workflows/ci-backend.yaml`.
76
+
* A source code responsibility distribution file in `.github/CODEOWNERS` (Please change the username into your own).
77
+
* A `YAML` file for an automated semantic commit message.
78
+
79
+
For containerization:
80
+
* A `Docker` configuration that utilizes the latest Python image in `backend/Dockerfile`.
81
+
* A script that ensure the backend application will restart when postgres image hasn't started yet in `backend/entrypoint.sh`.
82
+
* Setting up `Postgres` image for our database server, `Adminer` for our database editor, and `backend_app` for our backend application's container in `docker-compose.yaml`.
83
+
84
+
For the team development environment:
85
+
* A pre-commit hooks for `Black`, `Isort`, and `MyPy` to ensure the conventional commit message before pushing an updated code into the remote repository.
86
+
* All secret variables are listed in `.env.example`.
87
+
46
88
## Setup Guide
47
89
48
90
This backend application is setup with `Docker`. Nevertheless, you can see the full local setup without `Docker` in [backend/README.md](https://github.com/Aeternalis-Ingenium/FastAPI-Backend-Template/blob/trunk/backend/README.md).
@@ -130,6 +172,99 @@ This backend application is setup with `Docker`. Nevertheless, you can see the f
130
172
**IMPORTANT**: Without the secrets registered in Codecov and GitHub, your `CI` will fail and life will be horrible 🤮🤬
131
173
**IMPORTANT**: Remember to always run the container update every once in a while. Without the arguments `-d --build`, your `Docker` dashboard will be full of junk containers!
132
174
175
+
## Project Structure
176
+
177
+
```shell
178
+
.github/
179
+
├── workflows/
180
+
├── ci-backend.yaml # A CI file for the backend app that consits of `build`, `code-style`, and `test`
181
+
├── CODEOWNERS # A configuration file to distribute code responsibility
182
+
├── semantic.yaml # A configuration file for ensuring an automated semantic commit message
183
+
184
+
backend/
185
+
├── coverage/
186
+
├── src/
187
+
├── api/
188
+
├── dependencies/ # Dependency injections
189
+
├── session.py
190
+
├──repository.py
191
+
├── routes/ # Endpoints
192
+
├── account.py # Account routes
193
+
├── authentication.py # Signup and Signin routes
194
+
├── endpoints.py # Endpoint registration
195
+
├── config/
196
+
├── settings/
197
+
├── base.py # Base settings / settings parent class
198
+
├── development.py # Development settings
199
+
├── environments.py # Enum with PROD, DEV, STAGE environment
200
+
├── production.py # Production settings
201
+
├── staging.py # Test settings
202
+
├── events.py # Registration of global events
203
+
├── manager.py # Manage get settings
204
+
├── models/
205
+
├── domains/
206
+
├── account.py # Account class for database entity
207
+
├── schemas/
208
+
├── account.py # Account classes for data validation objects
209
+
├── base.py # Base class for data validation objects
210
+
├── repository/
211
+
├── crud/
212
+
├── account.py # C. R. U. D. operations for Account entity
213
+
├── base.py # Base class for C. R. U. D. operations
214
+
├── migrations/
215
+
├── versions/
216
+
├── env.py # Generated via alembic for automigration
217
+
├── script.py.mako # Generated via alembic
218
+
├── base.py # Entry point for alembic automigration
219
+
├── database.py # Database class with engine and session
220
+
├── events.py # Registration of database events
221
+
├── table.py # Custom SQLAlchemy Base class
222
+
├── security/
223
+
├── hashing/
224
+
├── hash.py # Hash functions with passlib
225
+
├── password.py # Password generator with hash functions
226
+
├── authorizations/
227
+
├── jwt.py # Generate JWT tokens with python-jose
228
+
├── verifications/
229
+
├── credentials.py # Check for attributes' availability
0 commit comments