|
1 |
| -# This is for backned service |
2 |
| -A template to create all public facing sites |
| 1 | +# TODO Backend |
| 2 | + |
| 3 | +## Local development setup |
| 4 | +1. Install pyenv |
| 5 | + - For Mac/Linux - https://github.com/pyenv/pyenv?tab=readme-ov-file#installation |
| 6 | + - For Windows - https://github.com/pyenv-win/pyenv-win/blob/master/docs/installation.md#chocolatey |
| 7 | +2. Install the configured python version (3.12.7) using pyenv by running the command |
| 8 | + - For Mac/Linux |
| 9 | + ``` |
| 10 | + pyenv install |
| 11 | + ``` |
| 12 | + - For Windows |
| 13 | + ``` |
| 14 | + pyenv install 3.11.5 |
| 15 | + ``` |
| 16 | +3. Create virtual environment by running the command |
| 17 | + - For Mac/Linux |
| 18 | + ``` |
| 19 | + pyenv virtualenv 3.11.5 venv |
| 20 | + ``` |
| 21 | + - For Windows |
| 22 | + ``` |
| 23 | + python -m pip install virtualenv |
| 24 | + python -m virtualenv venv |
| 25 | + ``` |
| 26 | +4. Activate the virtual environment by running the command |
| 27 | + - For Mac/Linux |
| 28 | + ``` |
| 29 | + pyenv activate venv |
| 30 | + ``` |
| 31 | + - For Windows |
| 32 | + ``` |
| 33 | + .\venv\Scripts\activate |
| 34 | + ``` |
| 35 | +5. Install the project dependencies by running the command |
| 36 | + ``` |
| 37 | + python -m pip install -r requirements.txt |
| 38 | + ``` |
| 39 | +6. Create a `.env` file in the root directory, and copy the content from the `.env.example` file to it |
| 40 | +7. Install [docker](https://docs.docker.com/get-docker/) and [docker compose](https://docs.docker.com/compose/install/) |
| 41 | +8. Start MongoDB using docker |
| 42 | + ``` |
| 43 | + docker-compose up -d db |
| 44 | + ``` |
| 45 | +9. Start the development server by running the command |
| 46 | + ``` |
| 47 | + python manage.py runserver |
| 48 | + ``` |
| 49 | +10. Go to http://127.0.0.1:8000/v1/health API to make sure the server it up. You should see this response |
| 50 | + ``` |
| 51 | + { |
| 52 | + "status": "UP", |
| 53 | + "components": { |
| 54 | + "db": { |
| 55 | + "status": "UP" |
| 56 | + } |
| 57 | + } |
| 58 | + } |
| 59 | + ``` |
| 60 | +
|
| 61 | +## To simply try out the app |
| 62 | +1. Install [docker](https://docs.docker.com/get-docker/) and [docker compose](https://docs.docker.com/compose/install/) |
| 63 | +2. Start Django application and MongoDB using docker |
| 64 | + ``` |
| 65 | + docker-compose up -d |
| 66 | + ``` |
| 67 | +3. Go to http://127.0.0.1:8000/v1/health API to make sure the server it up. You should see this response |
| 68 | + ``` |
| 69 | + { |
| 70 | + "status": "UP" |
| 71 | + } |
| 72 | + ``` |
| 73 | +4. On making changes to code and saving, live reload will work in this case as well |
| 74 | +
|
| 75 | +## Command reference |
| 76 | +1. To run the tests, run the following command |
| 77 | + ``` |
| 78 | + python manage.py test |
| 79 | + ``` |
| 80 | +2. To check test coverage, run the following command |
| 81 | + ``` |
| 82 | + coverage run --source='.' manage.py test |
| 83 | + coverage report |
| 84 | + ``` |
| 85 | +3. To run the formatter |
| 86 | + ``` |
| 87 | + ruff format |
| 88 | + ``` |
| 89 | +4. To run lint check |
| 90 | + ``` |
| 91 | + ruff check |
| 92 | + ``` |
| 93 | +5. To fix lint issues |
| 94 | + ``` |
| 95 | + ruff check --fix |
| 96 | + ``` |
0 commit comments