Skip to content
Merged

Ai #4

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.git
.env
31 changes: 31 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Deploy to EC2

on:
push:
branches:
- ai

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.EC2_SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H ${{ secrets.EC2_HOST }} >> ~/.ssh/known_hosts

- name: Deploy to EC2
run: |
ssh ${{ secrets.EC2_HOST }} << 'EOF'
set -e
echo "Pulling latest container..."
podman stop bun-backend || true
podman rm bun-backend || true
podman pull http://docker.io/abhishek194/resume-xpert-backend:latest
podman run -d --name bun-backend -p 3000:3000 --env-file /home/ubuntu/.env docker.io/<username>/<image>:latest
EOF
2 changes: 1 addition & 1 deletion .github/workflows/gitlab-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ jobs:
git remote add gitlab https://oauth2:${{ secrets.GITLAB_TOKEN }}@gitlab.com/abhishek_nitdelhi/cvexpert-backend.git

# Push only the master branch and tags
git push gitlab master
git push gitlab main
git push gitlab --tags
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Use official Node.js image as base
FROM oven/bun:1.1.13-alpine

# Set working directory
WORKDIR /app

# Copy package files and install dependencies
COPY package.json bun.lockb ./
RUN bun install --production

# Copy source code
COPY . .

# Expose port (change if your app uses a different port)
EXPOSE 3000

# Start the backend server in production mode
CMD ["bun", "start"]
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"module": "index.ts",
"type": "module",
"scripts": {
"dev": "bun --watch src/server.ts"
"dev": "bun --watch src/server.ts",
"run": "bun run src/server.ts"
},
"devDependencies": {
"@elysiajs/swagger": "^1.2.0",
Expand Down
24 changes: 20 additions & 4 deletions src/routes/analyzeRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,37 @@ const analyzeRoute = new Elysia({ prefix: '/analyze' })
async ({ body, error }: any) => {
console.log('Analyze Route called');
const { fileID, file, userID } = body;
let progress = 0;
try {
// Step 1: File Upload
progress = 1;
const access = await checkFileAccess(fileID, userID);
if (!access) {
return error(403, 'You do not have access to this file');
return { error: 'You do not have access to this file', progress };
}
console.log('File access granted');
// Step 2: Detecting Word Length
progress = 2;
// Simulate word length detection (replace with actual logic if needed)
// Step 3: Parsing
progress = 3;
// Simulate parsing (replace with actual logic if needed)
// Step 4: Scanning Fields
progress = 4;
// Simulate scanning fields (replace with actual logic if needed)
// Step 5: Analyzing Content
progress = 5;
const response = await analyzeFileUsingAI(file, fileID);
// Step 6: Generating Report
progress = 6;
if (response) {
return response;
return { ...response, progress };
} else {
return error(500, 'Failed to analyze the file');
return { error: 'Failed to analyze the file', progress };
}
} catch (err) {
console.error(err);
return error(500, 'An internal error occurred while processing the file.');
return { error: 'An internal error occurred while processing the file.', progress };
}
},
{
Expand Down
Loading