Skip to content

Commit b42271e

Browse files
committed
first commit
0 parents  commit b42271e

File tree

317 files changed

+31035
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

317 files changed

+31035
-0
lines changed

.cursor/rules/main-rule.mdc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: true
5+
---
6+
7+
8+
No Comments by Default: Only add comments when explicitly requested in the prompt.
9+
Adhere to DRY Principle: Avoid repetition in code.
10+
Prevent Premature Optimization: Focus on functionality and clarity before optimizing.
11+
Single Responsibility: Keep files and modules focused on a single purpose.
12+
Clear Boundaries: Maintain well-defined interfaces and responsibilities between modules.
13+
Concise Code: Strive for brevity; prefer one-liners when they don't compromise readability or exceed reasonable line length.

.dockerignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.git
2+
.gitignore
3+
.elixir_ls
4+
.terraform
5+
.github
6+
_build
7+
deps
8+
test
9+
tmp
10+
erl_crash.dump
11+
*.ez
12+
priv/static
13+
node_modules
14+
docker-compose.yml
15+
Dockerfile
16+
.dockerignore
17+
terraform
18+
deploy.sh
19+
README.md

.env.example

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Application configuration
2+
FRONTEND_URL=
3+
4+
# AWS Configuration
5+
AWS_ACCESS_KEY_ID=
6+
AWS_SECRET_ACCESS_KEY=
7+
AWS_REGION=
8+
9+
# AWS SQS Configuration
10+
SQS_QUEUE_URL=
11+
12+
# AWS SES Configuration
13+
SES_FROM_EMAIL=
14+
15+
# Logflare Configuration
16+
LOGFLARE_URL=
17+
LOGFLARE_API_KEY=
18+
LOGFLARE_SOURCE_ID=
19+
20+
# New Relic Configuration
21+
NEW_RELIC_LICENSE_KEY=
22+
NEW_RELIC_API_KEY=
23+
NEW_RELIC_ACCOUNT_ID=
24+
25+
# API Config
26+
API_SECRET_KEY=
27+
28+
SECRET_KEY_BASE=
29+
RAILS_MASTER_KEY=
30+

.formatter.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
import_deps: [:ecto, :ecto_sql, :phoenix],
3+
subdirectories: ["priv/*/migrations"],
4+
plugins: [Phoenix.LiveView.HTMLFormatter],
5+
inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"]
6+
]
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Audit Service CI
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'audit-service/**'
7+
push:
8+
branches: [ main, develop ]
9+
paths:
10+
- 'audit-service/**'
11+
12+
defaults:
13+
run:
14+
working-directory: audit-service
15+
16+
jobs:
17+
test:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Install packages
25+
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y build-essential git libyaml-dev pkg-config bc
26+
27+
- name: Set up Ruby
28+
uses: ruby/setup-ruby@v1
29+
with:
30+
ruby-version-file: audit-service/.ruby-version
31+
bundler-cache: true
32+
working-directory: audit-service
33+
34+
- name: Run tests with coverage
35+
env:
36+
RAILS_ENV: test
37+
run: |
38+
bin/rails db:test:prepare
39+
bin/rails test
40+
41+
- name: Log coverage results
42+
run: |
43+
if [ -f coverage/.last_run.json ]; then
44+
COVERAGE=$(cat coverage/.last_run.json | grep -o '"covered_percent":[0-9.]*' | cut -d':' -f2)
45+
echo "📊 Coverage Report:"
46+
echo "Coverage: $COVERAGE%"
47+
echo "Target: 100% (informational only)"
48+
49+
if [ $(echo "$COVERAGE >= 100" | bc -l) -eq 1 ]; then
50+
echo "🎉 Excellent! 100% coverage achieved!"
51+
elif [ $(echo "$COVERAGE >= 95" | bc -l) -eq 1 ]; then
52+
echo "✅ Great coverage! Close to 100%"
53+
elif [ $(echo "$COVERAGE >= 90" | bc -l) -eq 1 ]; then
54+
echo "👍 Good coverage! Consider improving to reach 100%"
55+
else
56+
echo "⚠️ Coverage could be improved. Target is 100%"
57+
fi
58+
else
59+
echo "⚠️ Coverage report not found"
60+
fi
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Auth Service CI
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'auth-service/**'
7+
push:
8+
branches: [ main, develop ]
9+
paths:
10+
- 'auth-service/**'
11+
12+
defaults:
13+
run:
14+
working-directory: auth-service
15+
16+
jobs:
17+
test:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '18'
28+
cache: 'npm'
29+
cache-dependency-path: auth-service/package-lock.json
30+
31+
- name: Install dependencies
32+
run: npm install
33+
34+
- name: Run tests
35+
run: npm run test
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Deploy API Gateway
2+
3+
on:
4+
push:
5+
tags:
6+
- 'api-gateway-*'
7+
8+
env:
9+
AWS_REGION: us-east-1
10+
ECR_REPOSITORY: expense-pilot/api-gateway
11+
ECS_CLUSTER: expense-pilot-cluster
12+
ECS_SERVICE: api-gateway
13+
14+
jobs:
15+
deploy:
16+
name: Deploy API Gateway
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Configure AWS credentials
24+
uses: aws-actions/configure-aws-credentials@v4
25+
with:
26+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
27+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
28+
aws-region: ${{ env.AWS_REGION }}
29+
30+
- name: Login to Amazon ECR
31+
id: login-ecr
32+
uses: aws-actions/amazon-ecr-login@v2
33+
34+
- name: Build, tag, and push image to Amazon ECR
35+
id: build-image
36+
env:
37+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
38+
IMAGE_TAG: ${{ github.sha }}
39+
run: |
40+
cd api-gateway
41+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
42+
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
43+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
44+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
45+
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
46+
47+
- name: Create task definition
48+
run: |
49+
cat > task-definition.json << EOF
50+
{
51+
"family": "${{ env.ECS_SERVICE }}",
52+
"networkMode": "awsvpc",
53+
"requiresCompatibilities": ["FARGATE"],
54+
"cpu": "256",
55+
"memory": "512",
56+
"executionRoleArn": "arn:aws:iam::170107269579:role/ecsTaskExecutionRole",
57+
"containerDefinitions": [
58+
{
59+
"name": "${{ env.ECS_SERVICE }}",
60+
"image": "${{ steps.build-image.outputs.image }}",
61+
"portMappings": [
62+
{
63+
"containerPort": 8080,
64+
"protocol": "tcp"
65+
}
66+
],
67+
"environment": [
68+
{
69+
"name": "PORT",
70+
"value": "8080"
71+
},
72+
{
73+
"name": "AUTH_SERVICE_URL",
74+
"value": "http://auth-service.expense-pilot.local:5439"
75+
},
76+
{
77+
"name": "EXPENSES_SERVICE_URL",
78+
"value": "http://expenses-service.expense-pilot.local:4001"
79+
},
80+
{
81+
"name": "AUDIT_SERVICE_URL",
82+
"value": "http://audit-service.expense-pilot.local:3000"
83+
},
84+
{
85+
"name": "API_SECRET_KEY",
86+
"value": "${{ secrets.API_SECRET_KEY }}"
87+
}
88+
],
89+
"logConfiguration": {
90+
"logDriver": "awslogs",
91+
"options": {
92+
"awslogs-group": "/ecs/${{ env.ECS_SERVICE }}",
93+
"awslogs-region": "${{ env.AWS_REGION }}",
94+
"awslogs-stream-prefix": "ecs"
95+
}
96+
}
97+
}
98+
]
99+
}
100+
EOF
101+
102+
- name: Deploy to Amazon ECS
103+
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
104+
with:
105+
task-definition: task-definition.json
106+
service: ${{ env.ECS_SERVICE }}
107+
cluster: ${{ env.ECS_CLUSTER }}
108+
desired-count: 1
109+
wait-for-service-stability: true
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Deploy Audit Service
2+
3+
on:
4+
push:
5+
tags:
6+
- 'audit-service-*'
7+
8+
env:
9+
AWS_REGION: us-east-1
10+
ECR_REPOSITORY: expense-pilot/audit-service
11+
ECS_CLUSTER: expense-pilot-cluster
12+
ECS_SERVICE: audit-service
13+
14+
jobs:
15+
deploy:
16+
name: Deploy Audit Service
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Configure AWS credentials
24+
uses: aws-actions/configure-aws-credentials@v4
25+
with:
26+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
27+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
28+
aws-region: ${{ env.AWS_REGION }}
29+
30+
- name: Login to Amazon ECR
31+
id: login-ecr
32+
uses: aws-actions/amazon-ecr-login@v2
33+
34+
- name: Build, tag, and push image to Amazon ECR
35+
id: build-image
36+
env:
37+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
38+
IMAGE_TAG: ${{ github.sha }}
39+
run: |
40+
cd audit-service
41+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
42+
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
43+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
44+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
45+
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
46+
47+
- name: Create task definition
48+
run: |
49+
cat > task-definition.json << EOF
50+
{
51+
"family": "${{ env.ECS_SERVICE }}",
52+
"networkMode": "awsvpc",
53+
"requiresCompatibilities": ["FARGATE"],
54+
"cpu": "256",
55+
"memory": "512",
56+
"executionRoleArn": "arn:aws:iam::170107269579:role/ecsTaskExecutionRole",
57+
"containerDefinitions": [
58+
{
59+
"name": "${{ env.ECS_SERVICE }}",
60+
"image": "${{ steps.build-image.outputs.image }}",
61+
"portMappings": [
62+
{
63+
"containerPort": 3000,
64+
"protocol": "tcp"
65+
}
66+
],
67+
"environment": [
68+
{
69+
"name": "RAILS_ENV",
70+
"value": "production"
71+
},
72+
{
73+
"name": "RAILS_MASTER_KEY",
74+
"value": "${{ secrets.RAILS_MASTER_KEY }}"
75+
},
76+
{
77+
"name": "API_SECRET_KEY",
78+
"value": "${{ secrets.API_SECRET_KEY }}"
79+
},
80+
{
81+
"name": "NEW_RELIC_API_KEY",
82+
"value": "${{ secrets.NEW_RELIC_API_KEY }}"
83+
},
84+
{
85+
"name": "NEW_RELIC_APP_NAME",
86+
"value": "audit-service"
87+
},
88+
{
89+
"name": "NEW_RELIC_ACCOUNT_ID",
90+
"value": "${{ secrets.NEW_RELIC_ACCOUNT_ID }}"
91+
}
92+
],
93+
"logConfiguration": {
94+
"logDriver": "awslogs",
95+
"options": {
96+
"awslogs-group": "/ecs/${{ env.ECS_SERVICE }}",
97+
"awslogs-region": "${{ env.AWS_REGION }}",
98+
"awslogs-stream-prefix": "ecs"
99+
}
100+
}
101+
}
102+
]
103+
}
104+
EOF
105+
106+
- name: Deploy to Amazon ECS
107+
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
108+
with:
109+
task-definition: task-definition.json
110+
service: ${{ env.ECS_SERVICE }}
111+
cluster: ${{ env.ECS_CLUSTER }}
112+
wait-for-service-stability: true

0 commit comments

Comments
 (0)