aki-008
commited on
Commit
·
05465db
1
Parent(s):
e0ba152
feat: Docker image created
Browse files- Backend/Dockerfile +35 -0
- Backend/app/api/v1/endpoints/interview.py +16 -17
- Frontend/Dockerfile +23 -0
- Frontend/nginx.conf +15 -0
- Frontend/tsconfig.app.json +1 -1
- RUN.md +1 -0
- docker-compose.yml +74 -0
Backend/Dockerfile
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use official Python runtime
|
| 2 |
+
FROM python:3.12-slim
|
| 3 |
+
|
| 4 |
+
# Set working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Install system dependencies
|
| 8 |
+
RUN apt-get update && apt-get install -y \
|
| 9 |
+
build-essential \
|
| 10 |
+
portaudio19-dev \
|
| 11 |
+
libpq-dev \
|
| 12 |
+
python3-dev \
|
| 13 |
+
git \
|
| 14 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 15 |
+
|
| 16 |
+
# ✅ FIX 1: Upgrade pip to the latest version to avoid hash bugs
|
| 17 |
+
RUN pip install --upgrade pip
|
| 18 |
+
|
| 19 |
+
COPY requirements.txt .
|
| 20 |
+
|
| 21 |
+
# ✅ FIX 2: Install CPU-only PyTorch first
|
| 22 |
+
RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
|
| 23 |
+
|
| 24 |
+
# ✅ FIX 3: Install other requirements pointing to the CPU index
|
| 25 |
+
# This prevents it from trying to re-download the huge GPU version of torch
|
| 26 |
+
RUN pip install --no-cache-dir -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu
|
| 27 |
+
|
| 28 |
+
# Copy the rest of the application code
|
| 29 |
+
COPY . .
|
| 30 |
+
|
| 31 |
+
# Expose the port
|
| 32 |
+
EXPOSE 8000
|
| 33 |
+
|
| 34 |
+
# Command to run the application
|
| 35 |
+
CMD ["python", "run.py"]
|
Backend/app/api/v1/endpoints/interview.py
CHANGED
|
@@ -39,8 +39,7 @@ class ConfigRequest(BaseModel):
|
|
| 39 |
# --- ENDPOINTS ---
|
| 40 |
|
| 41 |
@router.post("/api/get-vapi-config")
|
| 42 |
-
async def get_vapi_config(data: ConfigRequest
|
| 43 |
-
current_user: User = Depends(get_current_user)):
|
| 44 |
"""
|
| 45 |
Endpoint called by the Frontend to get the dynamically generated Assistant configuration.
|
| 46 |
"""
|
|
@@ -60,41 +59,42 @@ async def get_vapi_config(data: ConfigRequest,
|
|
| 60 |
f"The difficulty level is {data.level}. Your style is clear, concise, and professional. Do not lecture. "
|
| 61 |
"All questions must be relevant to the provided job role.\n\n"
|
| 62 |
|
| 63 |
-
"You MUST strictly follow this
|
| 64 |
|
| 65 |
-
"1. **Introduction
|
| 66 |
|
| 67 |
-
"2. **Background Snapshot
|
| 68 |
-
"'Give me a 30–40 second overview of your background and the type of work you've done related to this role.'\n\n"
|
| 69 |
|
| 70 |
-
"3. **Technical Depth
|
| 71 |
-
"Ask: 'Pick one project you're proud of that aligns with this role. In
|
| 72 |
-
"tools
|
| 73 |
|
| 74 |
-
"4. **Core Skills Check
|
| 75 |
"Generate **three crisp, role-specific skill checks** following this logic:\n"
|
| 76 |
" - Question 1: A foundational concept essential to the role.\n"
|
| 77 |
" - Question 2: A practical troubleshooting or decision-making question.\n"
|
| 78 |
-
" - Question 3: A tool
|
| 79 |
"Questions must be specific to the given job role.\n\n"
|
| 80 |
|
| 81 |
-
"5. **Practical Scenario
|
| 82 |
"Ask the candidate to describe their high-level approach to solve it.\n\n"
|
| 83 |
|
| 84 |
-
"6. **Role & Communication Fit
|
| 85 |
"'This role requires cross-team collaboration. Can you give an example where you explained something complex "
|
| 86 |
"to a non-technical or differently-skilled stakeholder?'\n\n"
|
| 87 |
|
| 88 |
-
"7. **Wrap-Up
|
| 89 |
|
| 90 |
"**CRITICAL RULES:**\n"
|
| 91 |
-
"- Do NOT exceed the
|
| 92 |
"- If their answers run long, politely interrupt and move forward.\n"
|
| 93 |
"- Keep your phrasing tight and professional.\n"
|
| 94 |
"- All generated questions MUST be directly relevant to the specified job role."
|
| 95 |
)
|
| 96 |
|
| 97 |
|
|
|
|
| 98 |
webhook_url = f"{SERVER_URL}/api/webhook"
|
| 99 |
|
| 100 |
assistant_overrides = {
|
|
@@ -152,8 +152,7 @@ async def get_vapi_config(data: ConfigRequest,
|
|
| 152 |
|
| 153 |
|
| 154 |
@router.post("/api/webhook")
|
| 155 |
-
async def vapi_webhook_receiver(request: Request
|
| 156 |
-
current_user: User = Depends(get_current_user)):
|
| 157 |
"""
|
| 158 |
Endpoint that receives asynchronous events from Vapi's servers.
|
| 159 |
Saves transcripts to a local file.
|
|
|
|
| 39 |
# --- ENDPOINTS ---
|
| 40 |
|
| 41 |
@router.post("/api/get-vapi-config")
|
| 42 |
+
async def get_vapi_config(data: ConfigRequest):
|
|
|
|
| 43 |
"""
|
| 44 |
Endpoint called by the Frontend to get the dynamically generated Assistant configuration.
|
| 45 |
"""
|
|
|
|
| 59 |
f"The difficulty level is {data.level}. Your style is clear, concise, and professional. Do not lecture. "
|
| 60 |
"All questions must be relevant to the provided job role.\n\n"
|
| 61 |
|
| 62 |
+
"You MUST strictly follow this interview flow:\n\n"
|
| 63 |
|
| 64 |
+
"1. **Introduction**: You have already welcomed them. Wait for their confirmation to begin.\n\n"
|
| 65 |
|
| 66 |
+
"2. **Background Snapshot**: Ask: "
|
| 67 |
+
"'Give me a brief 30–40 second overview of your background and the type of work you've done related to this role.'\n\n"
|
| 68 |
|
| 69 |
+
"3. **Technical Depth**: Ask the candidate to choose one project relevant to the job role. "
|
| 70 |
+
"Ask: 'Pick one project you're proud of that aligns with this role. In under a minute, explain the problem, your approach, "
|
| 71 |
+
"tools or techniques used, and the business impact.'\n\n"
|
| 72 |
|
| 73 |
+
"4. **Core Skills Check**: Inform them you will ask 3 rapid questions tailored to the job. "
|
| 74 |
"Generate **three crisp, role-specific skill checks** following this logic:\n"
|
| 75 |
" - Question 1: A foundational concept essential to the role.\n"
|
| 76 |
" - Question 2: A practical troubleshooting or decision-making question.\n"
|
| 77 |
+
" - Question 3: A tool, framework, or technology familiarity question.\n"
|
| 78 |
"Questions must be specific to the given job role.\n\n"
|
| 79 |
|
| 80 |
+
"5. **Practical Scenario**: Generate **one short applied scenario** relevant to the role. "
|
| 81 |
"Ask the candidate to describe their high-level approach to solve it.\n\n"
|
| 82 |
|
| 83 |
+
"6. **Role & Communication Fit**: Ask a communication-focused question, such as: "
|
| 84 |
"'This role requires cross-team collaboration. Can you give an example where you explained something complex "
|
| 85 |
"to a non-technical or differently-skilled stakeholder?'\n\n"
|
| 86 |
|
| 87 |
+
"7. **Wrap-Up**: Say: 'Thank you. Any questions for me?' Then conclude: 'We’ll get back to you with next steps.'\n\n"
|
| 88 |
|
| 89 |
"**CRITICAL RULES:**\n"
|
| 90 |
+
"- Do NOT exceed the boundaries of each segment.\n"
|
| 91 |
"- If their answers run long, politely interrupt and move forward.\n"
|
| 92 |
"- Keep your phrasing tight and professional.\n"
|
| 93 |
"- All generated questions MUST be directly relevant to the specified job role."
|
| 94 |
)
|
| 95 |
|
| 96 |
|
| 97 |
+
|
| 98 |
webhook_url = f"{SERVER_URL}/api/webhook"
|
| 99 |
|
| 100 |
assistant_overrides = {
|
|
|
|
| 152 |
|
| 153 |
|
| 154 |
@router.post("/api/webhook")
|
| 155 |
+
async def vapi_webhook_receiver(request: Request):
|
|
|
|
| 156 |
"""
|
| 157 |
Endpoint that receives asynchronous events from Vapi's servers.
|
| 158 |
Saves transcripts to a local file.
|
Frontend/Dockerfile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Stage 1: Build the React application
|
| 2 |
+
FROM node:20-alpine as build
|
| 3 |
+
|
| 4 |
+
WORKDIR /app
|
| 5 |
+
|
| 6 |
+
COPY package*.json ./
|
| 7 |
+
RUN npm install
|
| 8 |
+
|
| 9 |
+
COPY . .
|
| 10 |
+
RUN npm run build
|
| 11 |
+
|
| 12 |
+
# Stage 2: Serve with Nginx
|
| 13 |
+
FROM nginx:alpine
|
| 14 |
+
|
| 15 |
+
# Copy built assets from Stage 1
|
| 16 |
+
COPY --from=build /app/dist /usr/share/nginx/html
|
| 17 |
+
|
| 18 |
+
# Copy custom Nginx configuration
|
| 19 |
+
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
| 20 |
+
|
| 21 |
+
EXPOSE 80
|
| 22 |
+
|
| 23 |
+
CMD ["nginx", "-g", "daemon off;"]
|
Frontend/nginx.conf
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
server {
|
| 2 |
+
listen 80;
|
| 3 |
+
|
| 4 |
+
location / {
|
| 5 |
+
root /usr/share/nginx/html;
|
| 6 |
+
index index.html index.htm;
|
| 7 |
+
try_files $uri $uri/ /index.html;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
# Optional: Proxy API requests if you want to avoid CORS issues strictly
|
| 11 |
+
# (Though your backend handles CORS, so this isn't strictly necessary)
|
| 12 |
+
# location /api/ {
|
| 13 |
+
# proxy_pass http://backend:8000;
|
| 14 |
+
# }
|
| 15 |
+
}
|
Frontend/tsconfig.app.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
| 18 |
|
| 19 |
/* Linting */
|
| 20 |
"strict": true,
|
| 21 |
-
"noUnusedLocals":
|
| 22 |
"noUnusedParameters": true,
|
| 23 |
"erasableSyntaxOnly": true,
|
| 24 |
"noFallthroughCasesInSwitch": true,
|
|
|
|
| 18 |
|
| 19 |
/* Linting */
|
| 20 |
"strict": true,
|
| 21 |
+
"noUnusedLocals": false,
|
| 22 |
"noUnusedParameters": true,
|
| 23 |
"erasableSyntaxOnly": true,
|
| 24 |
"noFallthroughCasesInSwitch": true,
|
RUN.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
sudo service postgresql start (POstgresql)
|
|
|
|
| 2 |
|
| 3 |
chroma run --host 0.0.0.0 --port 8080 --path ./chroma_store (chroma_db) (project root folder)
|
| 4 |
|
|
|
|
| 1 |
sudo service postgresql start (POstgresql)
|
| 2 |
+
CREATE DATABASE studentdb;
|
| 3 |
|
| 4 |
chroma run --host 0.0.0.0 --port 8080 --path ./chroma_store (chroma_db) (project root folder)
|
| 5 |
|
docker-compose.yml
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
# 1. PostgreSQL Database
|
| 5 |
+
db:
|
| 6 |
+
image: postgres:15-alpine
|
| 7 |
+
container_name: prepai_db
|
| 8 |
+
restart: always
|
| 9 |
+
environment:
|
| 10 |
+
POSTGRES_USER: ${POSTGRES_USER:-postgres}
|
| 11 |
+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
|
| 12 |
+
POSTGRES_DB: studentdb # Database name used during initialization
|
| 13 |
+
volumes:
|
| 14 |
+
- postgres_data:/var/lib/postgresql/data
|
| 15 |
+
ports:
|
| 16 |
+
- "5432:5432"
|
| 17 |
+
healthcheck:
|
| 18 |
+
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
| 19 |
+
interval: 5s
|
| 20 |
+
timeout: 5s
|
| 21 |
+
retries: 5
|
| 22 |
+
|
| 23 |
+
# 2. ChromaDB Vector Store
|
| 24 |
+
chromadb:
|
| 25 |
+
image: chromadb/chroma
|
| 26 |
+
container_name: prepai_chroma
|
| 27 |
+
restart: always
|
| 28 |
+
volumes:
|
| 29 |
+
- chroma_data:/chroma/chroma
|
| 30 |
+
ports:
|
| 31 |
+
- "8080:8000" # Host 8080 maps to Container 8000 (standard chroma port)
|
| 32 |
+
environment:
|
| 33 |
+
- IS_PERSISTENT=TRUE
|
| 34 |
+
|
| 35 |
+
# 3. Backend (FastAPI)
|
| 36 |
+
backend:
|
| 37 |
+
build: ./Backend
|
| 38 |
+
container_name: prepai_backend
|
| 39 |
+
restart: always
|
| 40 |
+
depends_on:
|
| 41 |
+
db:
|
| 42 |
+
condition: service_healthy
|
| 43 |
+
chromadb:
|
| 44 |
+
condition: service_started
|
| 45 |
+
ports:
|
| 46 |
+
- "8000:8000"
|
| 47 |
+
env_file:
|
| 48 |
+
- .env
|
| 49 |
+
environment:
|
| 50 |
+
# Override config to point to docker service names
|
| 51 |
+
# NOTE: Ensure the DB name 'studentdb' matches POSTGRES_DB above or update accordingly in your .env
|
| 52 |
+
DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-password}@db:5432/studentdb
|
| 53 |
+
chroma_host: chromadb
|
| 54 |
+
chroma_port: 8000
|
| 55 |
+
chroma_collection: prepai_collection
|
| 56 |
+
volumes:
|
| 57 |
+
# Mount code for hot-reloading during development
|
| 58 |
+
- ./Backend:/app
|
| 59 |
+
- ./Backend/uploaded_pdfs:/app/uploaded_pdfs
|
| 60 |
+
- ./Backend/transcripts:/app/transcripts
|
| 61 |
+
|
| 62 |
+
# 4. Frontend (React + Vite served by Nginx)
|
| 63 |
+
frontend:
|
| 64 |
+
build: ./Frontend
|
| 65 |
+
container_name: prepai_frontend
|
| 66 |
+
restart: always
|
| 67 |
+
ports:
|
| 68 |
+
- "5173:80" # Map host port 5173 (browser access) to Nginx port 80
|
| 69 |
+
depends_on:
|
| 70 |
+
- backend
|
| 71 |
+
|
| 72 |
+
volumes:
|
| 73 |
+
postgres_data:
|
| 74 |
+
chroma_data:
|