API for managing employees and for use with some frontend framework.
- Django
- Django Signals
- Django Rest Framework
- Simple JWT for authentication system
- Fast
- Docker
- Docker Compose
- Postgresql as database
- Redis as cache
- Id
- Username
- Password
- Id
- Name
- Id
- Name
- Department FK
- Salary
- Birth date
Department like FK is better than charfield because it has more control
This project is divided in employee routes, jwt routes and admin routes
This project has cache system using Redis, caching views after first access and updating cache when data changes
This project use docker for simulate production environment. You can use project without docker, deleting setting.CACHES and replacing postgresql for sqlite in settings.DATABASES
Docker use requirements.txt for install dependencies
python3 -m venv venv
pip install -r requirements.txt
pip freeze > requirements.txt
docker-compose run web python3 project/manage.py makemigrations
docker-compose run web python3 project/manage.py migrate
docker-compose run web python3 project/manage.py createsuperuser
Use when create or update dependencies
docker-compose up --build
Usually
docker-compose up
Without logs
docker-compose up -d
docker-compose down
All routes and your main http methods
POST
/token/
Get refresh and access token
POST
/token/refresh/
Refresh your access token
GET | POST
/employees/
GET: List employees
POST: Create employee
GET | PUT | PATCH | DELETE
/employees/[ID]/
GET: See the employee data corresponding to the id parameter
PUT: Update employee data sending all fields
PATCH: Update employee data sending your selected fields
DELETE: delete employee
GET | POST
/departments/
GET: List departments
POST: Create department
GET | PUT | PATCH | DELETE
/departments/[ID]/
GET: See the department data corresponding to the id parameter
PUT: Update department data sending all fields
PATCH: Update department data sending your selected fields
DELETE: delete department
GET
/reports/employees/age/
See age report
GET
/reports/employees/salary/
See salary report
Usually
docker-compose run web python3.10 project/manage.py test backend --pattern="*_t.py"
When many changes or one change with a big impact
docker-compose run web python3.10 project/manage.py test backend --pattern="*_t.py" --failfast