Company review platform
- Submit a review for a company
- List of top 10 recommended companies
- Company rating is calculated based on the AVG of all dimensions.
- "Users who reviewed this company also reviewed": Given a particular company list other companies that other users also reviewed.
- Retrieve the highest and lowest rating review for a particular company.
This solution was built:
- with docker (restapi\docker\docker-compose.yml) -> just run docker compose up inside docker folder
- with symfony 6.0.10
- relational database (MySql)
- PHP 8.0
- database script (mysql) -> restapi\docker\init\01.sql
3 tables:
- company (company_id, name, city, country, industry, avg_rating) (created the avg_rating field in order to get the average rating of a company -> it's done during the iserts of data.json file and whenever a review is submited, the average rating of that company is updated as well. it's easier to get the top 10 list of recommended companies)
- user (user_id, email)
- review (review_id, title, user (foreign key of user_id), company (foreign key of company_id), culture, management, work_live_balance, career_development, pro, contra, suggestions)
(assuming that the user submitting the review and the company being reviewed, are already in the db (company and user) at the moment that the data is being sent, hence using the user_id and company_id)
restapi\docker\init\mysql.env: MYSQL_ROOT_PASSWORD=root MYSQL_USER=admin MYSQL_PASSWORD=admin MYSQL_DATABASE=test
to access database: http://localhost:8080/
in my case the database was named "test"
CompanyController => actions to:
- List of top 10 recommended companies (getTopcompanyAction) -> http://localhost/api/topcompanies
ReviewController => actions to:
- Submit review (postReviewAction) -> http://localhost/api/submitreview
- Highest and lowest rating review from a company (postHighestLowestRatingAction) -> http://localhost/api/ratinghighlow //could have been done with get tbh
- Users who reviewed this company also reviewed (postUserswhoReviewedAction) -> http://localhost/api/userswhoreviewed //could have been done with get tbh
- ReviewController Tests -> restapi\app\tests\CompanyControllerTest.php
- ReviewController Tests -> restapi\app\tests\ReviewControllerTest.php
Running tests: run in console: php bin/phpunit
with collection file "Test API.postman_collection"
It will take a little bit, after starting docker, to be fully connected to start using the api. I would say, 1 minute approx... When message "ready to handle connections" appears, then the api is ready to run