Skip to content

API for managing employees and for use with some frontend framework

License

Notifications You must be signed in to change notification settings

dhomini-rabelo/Employee-Management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

47 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Employee-Management

πŸ”— Topics


πŸ“– About

API for managing employees and for use with some frontend framework.


πŸ› οΈ Tools

  • Django
  • Django Signals
  • Django Rest Framework
  • Simple JWT for authentication system
  • Fast
  • Docker
  • Docker Compose
  • Postgresql as database
  • Redis as cache

πŸ—„οΈ Database


🏷️ User - main fields

  • Id
  • Username
  • Password

🏷️ Department

  • Id
  • Name

🏷️ Employee

  • Id
  • Name
  • Email
  • Department FK
  • Salary
  • Birth date

Department like FK is better than charfield because it has more control


πŸŽ₯ See the project

This project is divided in employee routes, jwt routes and admin routes


πŸ”— Routes for frontend



β€’ /token


β€’ /token/refresh


β€’ /employees


β€’ /employees/ID


β€’ /departments


β€’ /departments/ID


β€’ /reports/employees/age


β€’ /reports/employees/salary


πŸš€ Performance

This project has cache system using Redis, caching views after first access and updating cache when data changes


Local where show load time


View


πŸ›‘οΈ Custom admin system







πŸ“– Project instructions



πŸŽ“ How to start

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


β€’ Create virtual environment and use dependencies

Docker use requirements.txt for install dependencies


python3 -m venv venv
pip install -r requirements.txt
pip freeze > requirements.txt

β€’ Make migrations

docker-compose run web python3 project/manage.py makemigrations
docker-compose run web python3 project/manage.py migrate

β€’ Create admin user

docker-compose run web python3 project/manage.py createsuperuser

β€’ Run project


Use when create or update dependencies

docker-compose up --build

Usually

docker-compose up

Without logs

docker-compose up -d

β€’ Down project

docker-compose down

πŸŽ“ How to use



β€’ Get your tokens in /token/





β€’ Access any frontend router sending your access token in header




β€’ Refresh your access token in /token/refresh/ when access token is expired




πŸ”— Routes

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



πŸ§ͺ Tests


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

❌ End

About

API for managing employees and for use with some frontend framework

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published