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.
The first part outlines architecture and technology stack and the second part reveal the process and technical info.
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.
simply run "docker-compose up --build". Because the sqlite3 db is pushed into git repo, we don't need any migrations.
- A console emulator (cmder was used during development)
- Python Set up Python 3.7.4 was used In your command line type 'python -m pip install -U pip'
- Virtual environment (virtualenv 20.0.4 was used during development) Please create a new environment for this project.
- Git clone the project from git hub repository and navigate to that repository
- workon <your_env> to enter your environment
- 'pip install -r requirements.txt' to install all the required packages into your environment
- DB (sqlite) will also come into the project with git pull. No migrations are needed.
- Please set and ensure that LOG_PATH from settings.py exist in your machine.
- 'python manage.py runserver' to start server
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.
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.
This model depicts report entries and has a foreign key relationship with usermodel
This model describes department entries of the company. Each department has an autoincrement id and a description.
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.
Start by typing the url 'http//localhost:8000/' on your browser
Use admin/ man123qwe credentials. Admin user is already set up and member of the Admin Group.
This is the first page of the admin console. Navigate to this page from anywhere by clicking the Logo or the home menu option
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
By clicking this action, you will navigate to an interface where you can test each api separately
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)
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.
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
Page for viewing/ modifying employee records.
Page for viewing/ modifying department records.
Page for viewing/ modifying report records.
Page for viewing full application log
Full stack trace of the web services and business admin console apps listed by month.
Test file is located in test.py under 'rootapp' app. You can run the test with the following command
'python manage.py test'
We can change payload to make the test fail or write more complicated tests.