mirror of
https://github.com/FutureOfMedTech-FITM-hack/backend.git
synced 2024-11-21 22:16:33 +03:00
updated readme
This commit is contained in:
parent
d95e557ad9
commit
31e1bfb126
76
README.md
76
README.md
|
@ -1,7 +1,4 @@
|
|||
# med_backend
|
||||
|
||||
This project was generated using fastapi_template.
|
||||
|
||||
## Poetry
|
||||
|
||||
This project uses poetry. It's a modern dependency management
|
||||
|
@ -11,15 +8,9 @@ To run the project use this set of commands:
|
|||
|
||||
```bash
|
||||
poetry install
|
||||
poetry run python -m med_backend
|
||||
poetry shell
|
||||
```
|
||||
|
||||
This will start the server on the configured host.
|
||||
|
||||
You can find swagger documentation at `/api/docs`.
|
||||
|
||||
You can read more about poetry here: https://python-poetry.org/
|
||||
|
||||
## Docker
|
||||
|
||||
You can start the project with docker using this command:
|
||||
|
@ -28,42 +19,6 @@ You can start the project with docker using this command:
|
|||
docker-compose -f deploy/docker-compose.yml --project-directory . up --build
|
||||
```
|
||||
|
||||
If you want to develop in docker with autoreload add `-f deploy/docker-compose.dev.yml` to your docker command.
|
||||
Like this:
|
||||
|
||||
```bash
|
||||
docker-compose -f deploy/docker-compose.yml -f deploy/docker-compose.dev.yml --project-directory . up
|
||||
```
|
||||
|
||||
This command exposes the web application on port 8000, mounts current directory and enables autoreload.
|
||||
|
||||
But you have to rebuild image every time you modify `poetry.lock` or `pyproject.toml` with this command:
|
||||
|
||||
```bash
|
||||
docker-compose -f deploy/docker-compose.yml --project-directory . build
|
||||
```
|
||||
|
||||
## Project structure
|
||||
|
||||
```bash
|
||||
$ tree "med_backend"
|
||||
med_backend
|
||||
├── conftest.py # Fixtures for all tests.
|
||||
├── db # module contains db configurations
|
||||
│ ├── dao # Data Access Objects. Contains different classes to inteact with database.
|
||||
│ └── models # Package contains different models for ORMs.
|
||||
├── __main__.py # Startup script. Starts uvicorn.
|
||||
├── services # Package for different external services such as rabbit or redis etc.
|
||||
├── settings.py # Main configuration settings for project.
|
||||
├── static # Static content.
|
||||
├── tests # Tests for project.
|
||||
└── web # Package contains web server. Handlers, startup config.
|
||||
├── api # Package with all handlers.
|
||||
│ └── router.py # Main router.
|
||||
├── application.py # FastAPI application configuration.
|
||||
└── lifetime.py # Contains actions to perform on startup and shutdown.
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
This application can be configured with environment variables.
|
||||
|
@ -85,8 +40,6 @@ MED_BACKEND_PORT="8000"
|
|||
MED_BACKEND_ENVIRONMENT="dev"
|
||||
```
|
||||
|
||||
You can read more about BaseSettings class here: https://pydantic-docs.helpmanual.io/usage/settings/
|
||||
|
||||
## Pre-commit
|
||||
|
||||
To install pre-commit simply run inside the shell:
|
||||
|
@ -103,30 +56,3 @@ By default it runs:
|
|||
* isort (sorts imports in all files);
|
||||
* flake8 (spots possibe bugs);
|
||||
* yesqa (removes useless `# noqa` comments).
|
||||
|
||||
|
||||
You can read more about pre-commit here: https://pre-commit.com/
|
||||
|
||||
|
||||
## Running tests
|
||||
|
||||
If you want to run it in docker, simply run:
|
||||
|
||||
```bash
|
||||
docker-compose -f deploy/docker-compose.yml --project-directory . run --rm api pytest -vv .
|
||||
docker-compose -f deploy/docker-compose.yml --project-directory . down
|
||||
```
|
||||
|
||||
For running tests on your local machine.
|
||||
1. you need to start a database.
|
||||
|
||||
I prefer doing it with docker:
|
||||
```
|
||||
docker run -p "5432:5432" -e "POSTGRES_PASSWORD=med_backend" -e "POSTGRES_USER=med_backend" -e "POSTGRES_DB=med_backend" postgres:13.8-bullseye
|
||||
```
|
||||
|
||||
|
||||
2. Run the pytest.
|
||||
```bash
|
||||
pytest -vv .
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue
Block a user