Skip to content

freetsi/employee_portal

Repository files navigation

Employee Report Technical Specifications

Description

This project acts as a reporting system of a company and provides simple REST APIs for handling simple information storage and retrieval requests for employees' reports. In parallel, a back-office module is provided for handling employees, reports, employees' departments, and log/ audit management.

Document Structure

The first part outlines architecture and technology stack and the second part reveal the process and technical info.

Architecture

alt text

Requirements

Docker : If you want to deploy the app via Docker then you have to install docker on your pc

Sqlite : Since I had to implement only 3 simple endpoints no access to real database was needed. Additionally, sqlite has the power of a relation DB without the overhead of having a separate DB server.

Python + Django Rest Framework : Django is an open source web framework that helps you create a web app quickly as it takes care of additional web-development needs. Django Rest Framework's modular, flexible, and customizable architecture makes the development of both simple, turnkey API endpoints and complicated REST constructs possible.

Requirements and how to run the application via docker

simply run "docker-compose up --build". Because the sqlite3 db is pushed into git repo, we don't need any migrations.

Requirements and how to run the application locally

  1. A console emulator (cmder was used during development)
  2. Python Set up Python 3.7.4 was used In your command line type 'python -m pip install -U pip'
  3. Virtual environment (virtualenv 20.0.4 was used during development) Please create a new environment for this project.
  4. Git clone the project from git hub repository and navigate to that repository
  5. workon <your_env> to enter your environment
  6. 'pip install -r requirements.txt' to install all the required packages into your environment
  7. DB (sqlite) will also come into the project with git pull. No migrations are needed.
  8. Please set and ensure that LOG_PATH from settings.py exist in your machine.
  9. 'python manage.py runserver' to start server

Testing + API Documentation

drf-yasg is a Swagger generation tool implemented without using the schema generation provided by Django Rest Framework. It aims to implement as much of the OpenAPI specification as possible - nested schemas, named models, response bodies, enum/pattern/min/max validators, form parameters, etc. - and to generate documents. This also translates into a very useful interactive documentation viewer in the form of swagger-ui.

Core Functionality

Data Modelling

Employees

Django's default user model was used to depict each employee. Profiles model acts as a one to one relationship model which provides additional employees info such as mobile, address, department, gender etc. alt text

Reports

This model depicts report entries and has a foreign key relationship with usermodel alt text

Departments

This model describes department entries of the company. Each department has an autoincrement id and a description. alt text

Back Office

Business Admin Console Interface is an interface available to users that belong to the admin group. Through this interface one has access to data models entries and modification rights. This interface also supports logs presentation and audit.

Logging in

Start by typing the url 'http//localhost:8000/' on your browser

alt text

Use admin/ man123qwe credentials. Admin user is already set up and member of the Admin Group.

Home Page

This is the first page of the admin console. Navigate to this page from anywhere by clicking the Logo or the home menu option

alt text

Header (1)

Header part is always visible from anywhere in the app. 'Data Modelling' menu option consists of 'employees', 'departments', 'reports' sub menus and 'system admin' menu consist of 'logs', 'audit' sub menus.

If you click on the "log out" action then you will be logged out from this app

Api Tester

By clicking this action, you will navigate to an interface where you can test each api separately

alt text

You may need to perform an authorization with the admin/ man123qwe (Basic authentication) to test the APIs. "Fetch" section contains the api for retrieving reports query (GET request). "Post" section contains the apis for initiating or updating employees and report records (POST requests)

alt text

You can try out each of these apis with the "try it out button". The request and response payload are all set up and ready to use with your desired values. Form Validations are also active so you can test anything you wish.

alt text

Api Documentation

By clicking this action, you will navigate to an interface where you can see the full documentation as well as request and response payloads for each api separately

Employees (2)

Page for viewing/ modifying employee records.

alt text

Departments (3)

Page for viewing/ modifying department records.

alt text

Reports (4)

Page for viewing/ modifying report records.

alt text

Logs (5)

Page for viewing full application log

alt text

Audit(6)

Full stack trace of the web services and business admin console apps listed by month.

!alt text

Python Testing

Test file is located in test.py under 'rootapp' app. You can run the test with the following command

'python manage.py test'

alt text

We can change payload to make the test fail or write more complicated tests.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published