Yes, the URL above is the URL of this website, and it is one of my web development portfolios.
Using this website, you can send me messages, and you can see my reply on the same screen.
The messaging system is built on top of these technologies:
- WebSocket. It serves as WebRTC signaling. It also allows replies to be pushed to your web browser without needing any polling on the Web Browser JS side.
- WebRTC. It communicates directly with my web browser if I happen to open the chat app on my web browser
- Push Notification. It allows you to see my replies even though you have closed the web app tab/window.
- IndexedDB. It stores some messages on your browser to improve message loading UX.
The whole website uses a service worker cache to allow offline access to the website.
The backend is developed using Django Rest Framework. It stores data in PostgreSQL database. The cache, session, and message broker is set up to use Redis.
The frontend is developed using React/Redux framework.
The operation is using AWS infrastructure: CloudFront, Application Load Balancer, Autoscaling, EC2 spot instances, RDS PostgreSQL, ElastiCache Redis, and S3.
The AWS resources are defined using Terraform.
RDS resource
resource "aws_db_instance" "*****" {
allocated_storage = "*****"
auto_minor_version_upgrade = "true"
availability_zone = "*****"
backup_retention_period = "0"
backup_window = "*****"
ca_cert_identifier = "*****"
copy_tags_to_snapshot = "true"
customer_owned_ip_enabled = "false"
db_name = "*****"
db_subnet_group_name = "${aws_db_subnet_group.tfer--default-vpc-*****.name}"
deletion_protection = "true"
engine = "postgres"
engine_version = "10.18"
iam_database_authentication_enabled = "false"
identifier = "*****"
instance_class = "*****"
iops = "0"
license_model = "postgresql-license"
maintenance_window = "*****"
max_allocated_storage = "0"
monitoring_interval = "0"
multi_az = "false"
name = "*****"
option_group_name = "default:postgres-10"
parameter_group_name = "default.postgres10"
performance_insights_enabled = "false"
performance_insights_retention_period = "0"
port = "5432"
publicly_accessible = "true"
storage_encrypted = "false"
storage_type = "gp2"
tags = {
workload-type = "production"
}
tags_all = {
workload-type = "production"
}
username = "*****"
vpc_security_group_ids = ["sg-*****"]
}
ElastiCache Resources
resource "aws_elasticache_cluster" "*****" {
auto_minor_version_upgrade = "true"
availability_zone = "*****"
az_mode = "*****"
cluster_id = "*****"
engine = "redis"
engine_version = "*****"
maintenance_window = "*****"
node_type = "*****"
num_cache_nodes = "*****"
parameter_group_name = "*****"
port = "6379"
security_group_ids = ["sg-*****"]
snapshot_retention_limit = "0"
snapshot_window = "*****"
subnet_group_name = "${aws_elasticache_subnet_group.*****.name}"
}
resource "aws_elasticache_subnet_group" "*****" {
description = " "
name = "*****"
subnet_ids = ["${data.terraform_remote_state.subnet.outputs.aws_subnet_*****}"]
}
S3 Resource
resource "aws_s3_bucket" "*****" {
arn = "arn:aws:s3:::aldian-blog"
bucket = "aldian-blog"
force_destroy = "false"
grant {
id = "*****"
permissions = ["FULL_CONTROL"]
type = "CanonicalUser"
}
hosted_zone_id = "*****"
object_lock_enabled = "false"
request_payer = "BucketOwner"
versioning {
enabled = "false"
mfa_delete = "false"
}
}
EC2 Instance Resource
resource "aws_instance" "*****" {
ami = "ami-*****"
associate_public_ip_address = "true"
availability_zone = "*****"
capacity_reservation_specification {
capacity_reservation_preference = "open"
}
cpu_core_count = "*****"
cpu_threads_per_core = "*****"
credit_specification {
cpu_credits = "standard"
}
disable_api_termination = "false"
ebs_optimized = "false"
enclave_options {
enabled = "false"
}
get_password_data = "false"
hibernation = "false"
instance_initiated_shutdown_behavior = "terminate"
instance_type = "*****"
ipv6_address_count = "0"
key_name = "*****"
metadata_options {
http_endpoint = "enabled"
http_put_response_hop_limit = "1"
http_tokens = "optional"
instance_metadata_tags = "disabled"
}
monitoring = "false"
root_block_device {
delete_on_termination = "true"
encrypted = "false"
volume_size = "*****"
volume_type = "*****"
}
source_dest_check = "true"
subnet_id = "${data.terraform_remote_state.subnet.outputs.aws_subnet_*****}"
tenancy = "default"
vpc_security_group_ids = ["sg-*****"]
}
Autoscaling Resources
resource "aws_launch_configuration" "*****" {
associate_public_ip_address = "false"
ebs_optimized = "false"
enable_monitoring = "false"
image_id = "ami-*****"
instance_type = "*****"
key_name = "*****"
name = "*****"
root_block_device {
delete_on_termination = "true"
encrypted = "false"
iops = "0"
throughput = "0"
volume_size = "10"
volume_type = "gp2"
}
security_groups = ["sg-*****"]
spot_price = "*****"
}
resource "aws_autoscaling_group" "*****" {
availability_zones = ["*****", ..., "*****"]
capacity_rebalance = "false"
default_cooldown = "300"
desired_capacity = "1"
force_delete = "false"
health_check_grace_period = "300"
health_check_type = "EC2"
launch_configuration = "${*****}"
max_instance_lifetime = "0"
max_size = "2"
metrics_granularity = "1Minute"
min_size = "1"
name = "*****"
protect_from_scale_in = "false"
service_linked_role_arn = "arn:aws:iam::*****:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling"
target_group_arns = ["arn:aws:elasticloadbalancing:*****:*****:targetgroup/*****/*****", "arn:aws:elasticloadbalancing:*****:*****:targetgroup/*****/*****", "arn:aws:elasticloadbalancing:*****:*****:*****/*****/*****"]
vpc_zone_identifier = ["${*****}", ....., "${*****}"]
wait_for_capacity_timeout = "10m"
}
Load Balancer Resources
resource "aws_lb" "*****" {
desync_mitigation_mode = "defensive"
drop_invalid_header_fields = "false"
enable_deletion_protection = "false"
enable_http2 = "true"
enable_waf_fail_open = "false"
idle_timeout = "60"
internal = "false"
ip_address_type = "ipv4"
load_balancer_type = "application"
name = "AFCOM-0"
security_groups = ["sg-*****"]
subnet_mapping {
subnet_id = "subnet-44d8986b"
}
subnet_mapping {
subnet_id = "subnet-b84984b7"
}
subnet_mapping {
subnet_id = "subnet-cfd1e7ab"
}
subnet_mapping {
subnet_id = "subnet-d88ac7e7"
}
subnet_mapping {
subnet_id = "subnet-ee3830a5"
}
subnet_mapping {
subnet_id = "subnet-f6eca8ab"
}
subnets = ["${data.terraform_remote_state.subnet.outputs.aws_subnet_44d8986b_id}", "${data.terraform_remote_state.subnet.outputs.aws_subnet_b84984b7_id}", "${data.terraform_remote_state.subnet.outputs.aws_subnet_cfd1e7ab_id}", "${data.terraform_remote_state.subnet.outputs.aws_subnet_d88ac7e7_id}", "${data.terraform_remote_state.subnet.outputs.aws_subnet_ee3830a5_id}", "${data.terraform_remote_state.subnet.outputs.aws_subnet_f6eca8ab_id}"]
}
resource "aws_lb_target_group" "AFCOM-LB-*****" {
deregistration_delay = "300"
health_check {
enabled = "true"
healthy_threshold = "5"
interval = "30"
matcher = "200"
path = "/en-us/"
port = "*****"
protocol = "HTTP"
timeout = "5"
unhealthy_threshold = "2"
}
load_balancing_algorithm_type = "round_robin"
name = "AFCOM-LB-*****"
port = "*****"
protocol = "HTTP"
protocol_version = "HTTP1"
slow_start = "0"
stickiness {
cookie_duration = "86400"
enabled = "false"
type = "lb_cookie"
}
target_type = "instance"
vpc_id = "vpc-*****"
}
resource "aws_lb_target_group_attachment" "*****" {
target_group_arn = "arn:aws:elasticloadbalancing:*****:*****targetgroup/AFCOM-LB-*****"
target_id = "i-*****"
}
resource "aws_lb_listener" "*****" {
default_action {
order = "1"
redirect {
host = "#{host}"
path = "/#{path}"
port = "443"
protocol = "HTTPS"
query = "#{query}"
status_code = "HTTP_301"
}
type = "redirect"
}
load_balancer_arn = "${*****}"
port = "80"
protocol = "HTTP"
}
resource "aws_lb_listener" "*****" {
certificate_arn = "arn:aws:iam::*****:server-certificate/cloudfront/*****/*****"
default_action {
order = "1"
target_group_arn = "arn:aws:elasticloadbalancing:*****:*****:targetgroup/AFCOM-LB-*****/*****"
type = "forward"
}
load_balancer_arn = "${*****}"
port = "443"
protocol = "HTTPS"
ssl_policy = "ELBSecurityPolicy-*****"
}
resource "aws_lb_listener_rule" "*****" {
action {
order = "1"
redirect {
host = "www.#{host}"
path = "/#{path}"
port = "#{port}"
protocol = "HTTPS"
query = "#{query}"
status_code = "HTTP_301"
}
type = "redirect"
}
condition {
host_header {
values = ["aldianfazrihady.com"]
}
}
listener_arn = "${*****}"
priority = "3"
}
CloudFront Resource
resource "aws_cloudfront_distribution" "tfer--E3O53LTWPR2TYI" {
aliases = ["102-flowers.aldianfazrihady.com", "payflow-hosted-page.aldianfazrihady.com", "sentiment-rnn.aldianfazrihady.com", "text-generator.aldianfazrihady.com", "www.aldianfazrihady.com"]
default_cache_behavior {
allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
cached_methods = ["GET", "HEAD"]
compress = "false"
default_ttl = "86400"
forwarded_values {
cookies {
forward = "whitelist"
whitelisted_names = ["csrftoken", "sessionid"]
}
headers = ["Accept", "Accept-Charset", "Accept-Datetime", "Accept-Encoding", "Accept-Language", "Authorization", "Host", "Origin", "Referer"]
query_string = "true"
}
max_ttl = "31536000"
min_ttl = "0"
smooth_streaming = "false"
target_origin_id = "ELB-AFCOM-*****"
viewer_protocol_policy = "redirect-to-https"
}
enabled = "true"
http_version = "http2"
is_ipv6_enabled = "true"
origin {
connection_attempts = "3"
connection_timeout = "10"
custom_origin_config {
http_port = "80"
https_port = "443"
origin_keepalive_timeout = "5"
origin_protocol_policy = "match-viewer"
origin_read_timeout = "30"
origin_ssl_protocols = ["TLSv1", "TLSv1.1", "TLSv1.2"]
}
domain_name = "*****.*****.elb.amazonaws.com"
origin_id = "ELB-AFCOM-*****"
}
price_class = "PriceClass_All"
restrictions {
geo_restriction {
restriction_type = "none"
}
}
retain_on_delete = "false"
viewer_certificate {
cloudfront_default_certificate = "false"
iam_certificate_id = "*****"
minimum_protocol_version = "*****"
ssl_support_method = "*****"
}
}
resource "aws_s3_bucket" "*****" {
arn = "arn:aws:s3:::aldian-blog"
bucket = "aldian-blog"
force_destroy = "false"
grant {
id = "*****"
permissions = ["FULL_CONTROL"]
type = "CanonicalUser"
}
hosted_zone_id = "*****"
object_lock_enabled = "false"
request_payer = "BucketOwner"
versioning {
enabled = "false"
mfa_delete = "false"
}
}
resource "aws_instance" "*****" {
ami = "ami-*****"
associate_public_ip_address = "true"
availability_zone = "*****"
capacity_reservation_specification {
capacity_reservation_preference = "open"
}
cpu_core_count = "*****"
cpu_threads_per_core = "*****"
credit_specification {
cpu_credits = "standard"
}
disable_api_termination = "false"
ebs_optimized = "false"
enclave_options {
enabled = "false"
}
get_password_data = "false"
hibernation = "false"
instance_initiated_shutdown_behavior = "terminate"
instance_type = "*****"
ipv6_address_count = "0"
key_name = "*****"
metadata_options {
http_endpoint = "enabled"
http_put_response_hop_limit = "1"
http_tokens = "optional"
instance_metadata_tags = "disabled"
}
monitoring = "false"
root_block_device {
delete_on_termination = "true"
encrypted = "false"
volume_size = "*****"
volume_type = "*****"
}
source_dest_check = "true"
subnet_id = "${data.terraform_remote_state.subnet.outputs.aws_subnet_*****}"
tenancy = "default"
vpc_security_group_ids = ["sg-*****"]
}
resource "aws_launch_configuration" "*****" {
associate_public_ip_address = "false"
ebs_optimized = "false"
enable_monitoring = "false"
image_id = "ami-*****"
instance_type = "*****"
key_name = "*****"
name = "*****"
root_block_device {
delete_on_termination = "true"
encrypted = "false"
iops = "0"
throughput = "0"
volume_size = "10"
volume_type = "gp2"
}
security_groups = ["sg-*****"]
spot_price = "*****"
}
resource "aws_autoscaling_group" "*****" {
availability_zones = ["*****", ..., "*****"]
capacity_rebalance = "false"
default_cooldown = "300"
desired_capacity = "1"
force_delete = "false"
health_check_grace_period = "300"
health_check_type = "EC2"
launch_configuration = "${*****}"
max_instance_lifetime = "0"
max_size = "2"
metrics_granularity = "1Minute"
min_size = "1"
name = "*****"
protect_from_scale_in = "false"
service_linked_role_arn = "arn:aws:iam::*****:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling"
target_group_arns = ["arn:aws:elasticloadbalancing:*****:*****:targetgroup/*****/*****", "arn:aws:elasticloadbalancing:*****:*****:targetgroup/*****/*****", "arn:aws:elasticloadbalancing:*****:*****:*****/*****/*****"]
vpc_zone_identifier = ["${*****}", ....., "${*****}"]
wait_for_capacity_timeout = "10m"
}
resource "aws_lb" "*****" {
desync_mitigation_mode = "defensive"
drop_invalid_header_fields = "false"
enable_deletion_protection = "false"
enable_http2 = "true"
enable_waf_fail_open = "false"
idle_timeout = "60"
internal = "false"
ip_address_type = "ipv4"
load_balancer_type = "application"
name = "AFCOM-0"
security_groups = ["sg-*****"]
subnet_mapping {
subnet_id = "subnet-44d8986b"
}
subnet_mapping {
subnet_id = "subnet-b84984b7"
}
subnet_mapping {
subnet_id = "subnet-cfd1e7ab"
}
subnet_mapping {
subnet_id = "subnet-d88ac7e7"
}
subnet_mapping {
subnet_id = "subnet-ee3830a5"
}
subnet_mapping {
subnet_id = "subnet-f6eca8ab"
}
subnets = ["${data.terraform_remote_state.subnet.outputs.aws_subnet_44d8986b_id}", "${data.terraform_remote_state.subnet.outputs.aws_subnet_b84984b7_id}", "${data.terraform_remote_state.subnet.outputs.aws_subnet_cfd1e7ab_id}", "${data.terraform_remote_state.subnet.outputs.aws_subnet_d88ac7e7_id}", "${data.terraform_remote_state.subnet.outputs.aws_subnet_ee3830a5_id}", "${data.terraform_remote_state.subnet.outputs.aws_subnet_f6eca8ab_id}"]
}
resource "aws_lb_target_group" "AFCOM-LB-*****" {
deregistration_delay = "300"
health_check {
enabled = "true"
healthy_threshold = "5"
interval = "30"
matcher = "200"
path = "/en-us/"
port = "*****"
protocol = "HTTP"
timeout = "5"
unhealthy_threshold = "2"
}
load_balancing_algorithm_type = "round_robin"
name = "AFCOM-LB-*****"
port = "*****"
protocol = "HTTP"
protocol_version = "HTTP1"
slow_start = "0"
stickiness {
cookie_duration = "86400"
enabled = "false"
type = "lb_cookie"
}
target_type = "instance"
vpc_id = "vpc-*****"
}
resource "aws_lb_target_group_attachment" "*****" {
target_group_arn = "arn:aws:elasticloadbalancing:*****:*****targetgroup/AFCOM-LB-*****"
target_id = "i-*****"
}
resource "aws_lb_listener" "*****" {
default_action {
order = "1"
redirect {
host = "#{host}"
path = "/#{path}"
port = "443"
protocol = "HTTPS"
query = "#{query}"
status_code = "HTTP_301"
}
type = "redirect"
}
load_balancer_arn = "${*****}"
port = "80"
protocol = "HTTP"
}
resource "aws_lb_listener" "*****" {
certificate_arn = "arn:aws:iam::*****:server-certificate/cloudfront/*****/*****"
default_action {
order = "1"
target_group_arn = "arn:aws:elasticloadbalancing:*****:*****:targetgroup/AFCOM-LB-*****/*****"
type = "forward"
}
load_balancer_arn = "${*****}"
port = "443"
protocol = "HTTPS"
ssl_policy = "ELBSecurityPolicy-*****"
}
resource "aws_lb_listener_rule" "*****" {
action {
order = "1"
redirect {
host = "www.#{host}"
path = "/#{path}"
port = "#{port}"
protocol = "HTTPS"
query = "#{query}"
status_code = "HTTP_301"
}
type = "redirect"
}
condition {
host_header {
values = ["aldianfazrihady.com"]
}
}
listener_arn = "${*****}"
priority = "3"
}
resource "aws_cloudfront_distribution" "tfer--E3O53LTWPR2TYI" {
aliases = ["102-flowers.aldianfazrihady.com", "payflow-hosted-page.aldianfazrihady.com", "sentiment-rnn.aldianfazrihady.com", "text-generator.aldianfazrihady.com", "www.aldianfazrihady.com"]
default_cache_behavior {
allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
cached_methods = ["GET", "HEAD"]
compress = "false"
default_ttl = "86400"
forwarded_values {
cookies {
forward = "whitelist"
whitelisted_names = ["csrftoken", "sessionid"]
}
headers = ["Accept", "Accept-Charset", "Accept-Datetime", "Accept-Encoding", "Accept-Language", "Authorization", "Host", "Origin", "Referer"]
query_string = "true"
}
max_ttl = "31536000"
min_ttl = "0"
smooth_streaming = "false"
target_origin_id = "ELB-AFCOM-*****"
viewer_protocol_policy = "redirect-to-https"
}
enabled = "true"
http_version = "http2"
is_ipv6_enabled = "true"
origin {
connection_attempts = "3"
connection_timeout = "10"
custom_origin_config {
http_port = "80"
https_port = "443"
origin_keepalive_timeout = "5"
origin_protocol_policy = "match-viewer"
origin_read_timeout = "30"
origin_ssl_protocols = ["TLSv1", "TLSv1.1", "TLSv1.2"]
}
domain_name = "*****.*****.elb.amazonaws.com"
origin_id = "ELB-AFCOM-*****"
}
price_class = "PriceClass_All"
restrictions {
geo_restriction {
restriction_type = "none"
}
}
retain_on_delete = "false"
viewer_certificate {
cloudfront_default_certificate = "false"
iam_certificate_id = "*****"
minimum_protocol_version = "*****"
ssl_support_method = "*****"
}
}