Skip to content

Commit

Permalink
upd: Service Connect updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ironnicko committed Feb 14, 2025
1 parent 47bfc80 commit bf77571
Show file tree
Hide file tree
Showing 13 changed files with 926 additions and 2,661 deletions.
4 changes: 2 additions & 2 deletions App/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- RNGestureHandler (2.22.0):
- RNGestureHandler (2.22.1):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -2024,7 +2024,7 @@ SPEC CHECKSUMS:
ReactCodegen: 0a0eef9c8cd84c932ae1868832086c6441811e84
ReactCommon: 3c1c8c6d777103c0e60e37c6c5f08e828e2a77c9
RNCAsyncStorage: 2edc69cf6db9299363a11477668b7f452f2cb4a6
RNGestureHandler: 7afc0db05cd604c8530dba90d9b453d4d581deab
RNGestureHandler: b9cd1bda1d2a95d390de0a88e1e41140a5a68e82
RNScreens: 4c7d5710e955dcf72c14a546e29744f9e591370b
RNVectorIcons: a24016b773380b1aa37fca501ec6b94a951890a0
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Expand Down
2 changes: 1 addition & 1 deletion App/src/screens/mixAndMatch/MixAndMatchResultScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const MixAndMatchResultScreen = () => {

<View style={styles.recommendationContainer}>
<Icon
name={data.rating > 3 ? "thumb-up" : "thumb-down"}
name={data.rating > 3 ? "thumb-up" : (data.rating == 3 ? "dots-horizontal":"thumb-down")}
size={48}
color="#000"
/>
Expand Down
2 changes: 1 addition & 1 deletion App/src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import axios from 'axios'

export const api = axios.create({

baseURL: ("http://192.168.1.4:8000"),
baseURL: ("http://40.192.2.211:8000"),

});
839 changes: 839 additions & 0 deletions Frontend/bun.lock

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions Frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@
},
"dependencies": {
"@headlessui/react": "^2.2.0",
"axios": "^1.7.8",
"dotenv": "^16.4.5",
"axios": "^1.7.9",
"dotenv": "^16.4.7",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router": "^7.0.1",
"react-router-dom": "^7.0.1",
"vite": "^6.0.1",
"zustand": "^5.0.1"
"react-router": "^7.1.5",
"react-router-dom": "^7.1.5",
"vite": "^6.1.0",
"zustand": "^5.0.3"
},
"devDependencies": {
"@eslint/js": "^9.15.0",
"@types/node": "^22.10.1",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@eslint/js": "^9.20.0",
"@types/node": "^22.13.4",
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"@vitejs/plugin-react": "^4.3.4",
"autoprefixer": "^10.4.20",
"eslint": "^9.15.0",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.14",
"globals": "^15.12.0",
"postcss": "^8.4.49",
"eslint": "^9.20.1",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^15.15.0",
"postcss": "^8.5.2",
"serve": "^14.2.4",
"tailwindcss": "^3.4.15",
"typescript": "~5.6.2",
"typescript-eslint": "^8.15.0"
"tailwindcss": "^3.4.17",
"typescript": "~5.6.3",
"typescript-eslint": "^8.24.0"
}
}
4 changes: 2 additions & 2 deletions Frontend/src/components/ClosetView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ const ClosetView = () => {
className="min-w-[200px] flex-shrink-0 bg-white rounded-lg shadow-md p-4"
>
<img
src={item.url}
src={item.URL}
alt={`Clothing ${item.ID}`}
className="h-32 w-full object-cover rounded-lg mb-2"
/>
<h2 className="font-semibold">{item.type}</h2>
<h2 className="font-semibold">{item.Type}</h2>
<p>Style: {item.Style || "N/A"}</p>
<p>Color: {item.Color || "N/A"}</p>
</div>
Expand Down
2,608 changes: 0 additions & 2,608 deletions Frontend/yarn.lock

This file was deleted.

4 changes: 1 addition & 3 deletions Go-Backend/controllers/clothingController.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ func CreateMultiPartFormBody(strUID uuid.UUID, strCID string, clothingType strin
io.Copy(part, fileBuffer)

writer.WriteField("user_ID", strUID.String())

writer.WriteField("clothing_ID", strCID)

// Close the writer to finalize the multipart form
writer.Close()

return nil
}

Expand Down
4 changes: 1 addition & 3 deletions Go-Backend/middleware/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func JWTProtected() fiber.Handler {
})
}

// Now safely access the parts
// Safely access the parts
scheme := parts[0]
if scheme != "Bearer" {
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
Expand Down Expand Up @@ -61,10 +61,8 @@ func JWTProtected() fiber.Handler {
}
}

// Store user information in the context
c.Locals("client", userClient)
c.Locals("user", *user)
// Proceed to the next handler
return c.Next()
}
}
1 change: 1 addition & 0 deletions Segment/api/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
top, bottom, shoe, hat, others
Don't generate less than 5 Tags and no more than 12.
A dress will be considered a top, but make sure to add the tag 'dress' in the tags.
Tags must be about the clothing rather than the contents in the image.
Make the tags as specific as possible, try not to be generic like eg: men's fashion. The preceeding example is something that shouldn't be a tag.
Expand Down
6 changes: 3 additions & 3 deletions Terraform/EC2/playbook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@

- name: Copy ENV file
copy:
src: ../.env
src: ../../.env
dest: /home/ec2-user

- name: Copy Compose file
copy:
src: ../compose.yaml
src: ../../compose.yml
dest: /home/ec2-user/compose.yaml

- name: Copy Script file
copy:
src: ../ip.sh
src: ../../ip.sh
dest: /home/ec2-user/

- name: Run the Script
Expand Down
67 changes: 52 additions & 15 deletions Terraform/ECS/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ resource "aws_cloudwatch_log_group" "ecs_log_group" {
name = "ecs-log-group"
}

resource "aws_service_discovery_private_dns_namespace" "outfits" {
name = "Outfits"
description = "Namespace for Outfits services"
vpc = aws_vpc.main.id
}

resource "aws_ecs_task_definition" "segment" {
family = "segment-task"
requires_compatibilities = ["FARGATE"]
Expand All @@ -28,18 +34,18 @@ resource "aws_ecs_task_definition" "segment" {
logDriver = "awslogs"
options = {
"awslogs-group" = aws_cloudwatch_log_group.ecs_log_group.name
"awslogs-region" = var.aws_region # Change to your region
"awslogs-region" = var.aws_region
"awslogs-stream-prefix" = "ecs"
}
}
environmentFiles = [
{
value = "arn:aws:s3:::outfits.ai-bucket/test.env"
value = var.s3_env
type = "s3"
}
]
portMappings = [{
name = "segment"
name = "segment"
containerPort = 8001
hostPort = 8001
protocol = "tcp"
Expand Down Expand Up @@ -70,18 +76,18 @@ resource "aws_ecs_task_definition" "backend" {
logDriver = "awslogs"
options = {
"awslogs-group" = aws_cloudwatch_log_group.ecs_log_group.name
"awslogs-region" = var.aws_region # Change to your region
"awslogs-region" = var.aws_region
"awslogs-stream-prefix" = "ecs"
}
}
environmentFiles = [
{
value = "arn:aws:s3:::outfits.ai-bucket/test.env"
value = var.s3_env
type = "s3"
}
]
portMappings = [{
name = "backend"
name = "backend"
containerPort = 8000
hostPort = 8000
protocol = "tcp"
Expand Down Expand Up @@ -112,18 +118,18 @@ resource "aws_ecs_task_definition" "rembg" {
logDriver = "awslogs"
options = {
"awslogs-group" = aws_cloudwatch_log_group.ecs_log_group.name
"awslogs-region" = var.aws_region # Change to your region
"awslogs-region" = var.aws_region
"awslogs-stream-prefix" = "ecs"
}
}
environmentFiles = [
{
value = "arn:aws:s3:::outfits.ai-bucket/test.env"
value = var.s3_env
type = "s3"
}
]
portMappings = [{
name = "rembg"
name = "rembg"
containerPort = 7001
hostPort = 7001
protocol = "tcp"
Expand All @@ -132,10 +138,10 @@ resource "aws_ecs_task_definition" "rembg" {
}


resource "aws_ecs_service" "segment_service" {
name = "segment-service"
resource "aws_ecs_service" "rembg_service" {
name = "rembg-service"
cluster = aws_ecs_cluster.main.id
task_definition = aws_ecs_task_definition.segment.arn
task_definition = aws_ecs_task_definition.rembg.arn
desired_count = 1
launch_type = "FARGATE"

Expand All @@ -145,6 +151,19 @@ resource "aws_ecs_service" "segment_service" {
assign_public_ip = true
}

service_connect_configuration {
enabled = true
namespace = aws_service_discovery_private_dns_namespace.outfits.arn

service {
port_name = "rembg"
discovery_name = "rembg"
client_alias {
port = 7001
dns_name = "rembg"
}
}
}
}

resource "aws_ecs_service" "backend_service" {
Expand All @@ -160,12 +179,16 @@ resource "aws_ecs_service" "backend_service" {
assign_public_ip = true
}

service_connect_configuration {
enabled = true
namespace = aws_service_discovery_private_dns_namespace.outfits.arn
}
}

resource "aws_ecs_service" "rembg_service" {
name = "rembg-service"
resource "aws_ecs_service" "segment_service" {
name = "segment-service"
cluster = aws_ecs_cluster.main.id
task_definition = aws_ecs_task_definition.rembg.arn
task_definition = aws_ecs_task_definition.segment.arn
desired_count = 1
launch_type = "FARGATE"

Expand All @@ -175,4 +198,18 @@ resource "aws_ecs_service" "rembg_service" {
assign_public_ip = true
}


service_connect_configuration {
enabled = true
namespace = aws_service_discovery_private_dns_namespace.outfits.arn

service {
port_name = "segment"
discovery_name = "segment"
client_alias {
port = 8001
dns_name = "segment"
}
}
}
}
10 changes: 5 additions & 5 deletions Terraform/ECS/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ resource "aws_internet_gateway" "main" {

# Create public subnets
resource "aws_subnet" "public_subnet" {
count = length(var.public_subnet_cidrs)
vpc_id = aws_vpc.main.id
cidr_block = element(var.public_subnet_cidrs, count.index)
availability_zone = element(data.aws_availability_zones.available.names, count.index)
count = length(var.public_subnet_cidrs)
vpc_id = aws_vpc.main.id
cidr_block = element(var.public_subnet_cidrs, count.index)
availability_zone = element(data.aws_availability_zones.available.names, count.index)
map_public_ip_on_launch = true
}

Expand All @@ -32,7 +32,7 @@ resource "aws_eip" "nat" {

resource "aws_nat_gateway" "main" {
allocation_id = aws_eip.nat.id
subnet_id = aws_subnet.public_subnet[0].id # Place NAT Gateway in a public subnet
subnet_id = aws_subnet.public_subnet[0].id # Place NAT Gateway in a public subnet
}

# Create route table for public subnets
Expand Down

0 comments on commit bf77571

Please sign in to comment.