Skip to content

Commit cc4bf06

Browse files
committed
feat(readme): Readme updated
1 parent a4a6d3b commit cc4bf06

File tree

1 file changed

+110
-1
lines changed

1 file changed

+110
-1
lines changed

README.md

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,112 @@
11
# Simple FastAPI Server Application
22

3-
add description here
3+
This project is FastAPI server application that simple performs two different tasks.
4+
5+
## Dependencies to install
6+
7+
- [Python 3.9](https://www.python.org/downloads/)
8+
- [Pip](https://pypi.org/project/pip/)
9+
- [Docker](https://www.docker.com/products/docker-desktop)
10+
- [Docker Compose](https://docs.docker.com/compose/install/)
11+
12+
13+
## Repo Config
14+
15+
To prevent syntax errors and keep high code quality, pre-commit hooks are used. They automatically check the code and clean it.
16+
17+
When the code is pushed to `origin/main` branch, the Github Action is triggered. It runs basic format checking, code linting, and functionality testing using pytest. All the config is in the `./setup.cfg` file.
18+
19+
20+
## Setup
21+
22+
In order to run the server application locally, you need to fill in the secrets (they are not published to github due to security reasons).
23+
24+
The secrets to fill in are located in these files:
25+
26+
- `appsettings.yaml`
27+
- `docker-compose.yaml`
28+
29+
To run the application in docker, run the following command:
30+
31+
```bash
32+
docker-compose up
33+
```
34+
35+
In order to run the application locally (for development purposes), you need to set `localhost` value to `db_connection.postgres_server` in `appsettings.yaml` file. Then you can run the following command.
36+
37+
```bash
38+
docker run -d -p 5432:5432 -e POSTGRES_USER=xxx -e POSTGRES_PASSWORD=xxx -e POSTGRES_SERVER=xxx -e POSTGRES_DB=xxx postgres:14.2
39+
python src/main.py
40+
```
41+
42+
## XML/JSON Conversion
43+
44+
The first task aims to convert XML/JSON files.
45+
46+
The requests accept the multipart/form-data as an input with key `file` . The following endpoints are exposed:
47+
48+
* `[POST] /json2xml`: converts JSON to XML.
49+
* If `Accept` header is set to `text/xml`, the response will be in XML format, JSON otherwise.
50+
* if file's content-type is not `application/json`, the request will be rejected.
51+
52+
* `[POST] /xml2json`: converts XML to JSON
53+
* if file's content-type is not `text/xml`, the request will be rejected.
54+
55+
Additionally, the functionality can be tested via browser by using index template page that contains two forms.
56+
57+
The template page is accessible on root path `/`.
58+
59+
60+
## Databases
61+
62+
The second task aims to demonstrate database operations.
63+
64+
* `[GET] /user?email=<email_address>`: returns user's value
65+
* `[POST] /user?email=<email_address>`: creates new user with given value. If the user already exists, it updates the value.
66+
* `[DELETE] /user?email=<email_address>`: deletes user and the value
67+
* `[GET] /users`: returns all users and their values. The users are alphabetically sorted.
68+
* it accepts optional arguments `limit` and `offset` to limit the number of users and offset the users.
69+
70+
71+
**Note:** More details about exposed endpoints can be found in the `/docs` REST API swagger.
72+
73+
74+
## Testing
75+
76+
For testing purposes, [Pytest](https://docs.pytest.org/en/latest/getting-started.html) is used. All the tests are located in `./tests` folder
77+
It is advised to run the firsts before commit to verify the application functionality (tests are not included in pre-commit hooks).
78+
79+
## Requirements
80+
The project uses Python 3.9 (the latest version). This is a list of required libraries:
81+
```python
82+
fastapi==0.75.2
83+
uvicorn==0.17.6
84+
psycopg2-binary==2.9.3
85+
python-dotenv==0.20.0
86+
python-multipart==0.0.5
87+
lxml==4.8.0
88+
PyYAML==6.0
89+
aiofiles==0.8.0
90+
jinja2==3.1.2
91+
email-validator==1.2.1
92+
# dev requirements
93+
mypy==0.950
94+
flake8==4.0.1
95+
autoflake==1.4
96+
pre-commit==2.18.1
97+
isort==5.10.1
98+
pytest==7.1.2
99+
pytest-cov==3.0.0
100+
pytest-postgresql==4.1.1
101+
pytest-asyncio==0.18.3
102+
types-psycopg2==2.9.13
103+
types-lxml==2022.4.10
104+
types-PyYaml==6.0.7
105+
black==22.3.0
106+
psycopg==3.0.12
107+
```
108+
109+
## License
110+
111+
This project is licensed under the terms of the MIT license.
112+

0 commit comments

Comments
 (0)