Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ProFire/tribecarexercise

Repository files navigation

Tribe Car exercise

This repository is done for Tribe Car's coding interview. There are 2 methods to install: Cloud Installation and Localhost Installation

Scenario

To develop a simple visitor log system for a condominium manager.

In this system, the manager will be able to manage basic information of tenants/occupants staying in the condominium and track visitors who visit the condominium.

Information of each unit consists of block & unit number, occupant name, contact number. The manager will be able to create units in the condominium, viewing a list of all the units, viewing details of a single unit, updating detail or delete the unit.

The manager will need information of each visitor's name, contact number, unit visiting, last 3 digits of NRIC, and datetime of entry & exit. The manager will be able to view the visitors log for the past 3 months, and edit the exit datetime if necessary, the manager requires to search by the unit number as well in the visitors log.

Visitors will be required to fill in the visit form at the security booth. Visitors will need to fill in the block & unit number which they are visiting, or might just go to the function room for an event. Due to covid-19 measures, the system must be able to prompt the guard to deny entry to visitor(s) if the unit has a maximum up to 5 visitors.

System will be able to determine if it is the same visitor by their unique contact number & last 3 digits of NRIC, the manager can view this visitor when and which units he/she visited.

Cloud installation

Pre-requisites to Cloud installation

  • You must have an AWS User Account with Access Key and Secret
  • Have AWS CLI installed on your machine
  • Have AWS configure done with your ACCESS KEY and SECRET on your machine
  • Have Terraform installed

Installation

Navigate to the ./build/terraform folder and run the following command to set up your AWS infrastructure and CICD pipeline

terraform apply

Go to your AWS console and navigate to your developer tools to setup your code star connection. You need connect your Github Account to your code star in order to run this repository.

Then go to your CodePipeline and do a "release change" on "tribecarexercise-codepipeline" pipeline.

AWS Infrastructure

  • 2 public subnets in 2 Availability Zones for High Availability deployment
  • 2 private subnets in 2 Availability Zones for High Availability deployment
  • RDS is deployed in private subnet for security
  • CakePHP is deployed in Fargate in public subnet, behind a load balancer
  • CICD pipeline is automatically triggered upon git push

Localhost Installation

Pre-requisites to Localhost installation

  • You must install Lando.

Installation

At the application root folder, run the following command:

lando start

Running Unit Test

At the application root folder, run the following command:

lando phpunit

Running Database migrations

At the application root folder, run the following command:

lando cake migrations migrate

Shortcuts

Due to circumstance, time, and cost constraints, the following shortcuts were taken and how in actual production I would have done differently:

  • I would done 3 or more git branches in an actual git for proper deployment cycle
    • release/prod
    • release/uat
    • release/dev
  • I would have done feature branching that corresponds to JIRA or Trello tickets and do Pull Request for code reviews, like:
    • feature/ABC-1
    • hotfix/XYZ-2
  • There is only 1 environment in AWS. Ideally, there should be 3, corresponding to the 3 release branches in git. I didn't do it for cost-savings since the 3 environments are identical.
  • There should be an independent terraform git repo and its own pipeline in AWS to ensure a more secure AWS account. It will also allow multiple DevOps to modify the terraform git repo and deploy with S3 state storage and DynamoDB for state-locking. See: https://learn.hashicorp.com/tutorials/terraform/aws-remote?in=terraform/aws-get-started
  • The password for database should not have been stored in terraform script or in the codes. It should have been stored in AWS Secrets Manager or AWS Parameter Store instead.
  • The ECS cluster should have auto-scaling feature so that it can scale the app with varying traffic loads.
  • The RDS database should have been Aurora Serverless v1 and have CloudWatch schedule a regular ping of about 5 minutes. This way, the database can scale with the ECS cluster without Aurora going through cold start.
  • The CICD deployment should be Blue/Green instead.
  • No VPN and VPN gateway was created. I would have either used OpenVPN or WireGuard so that the private subnet is accessible from corporate network. That also means the RDS is not accessible unless there is a VPN setup or there is an EC2 instance in Public Subnet to SSH/RDP into.
  • No redis cache was created to store PHP sessions. I would have created a ElastiCache Redis Cluster to store sessions, so that the PHP app is stateless.

About

Repository for Tribecar interview

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •