Skip to content

Commit c395b9e

Browse files
committed
feat: backend initial
1 parent ae076ef commit c395b9e

Some content is hidden

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

57 files changed

+12228
-0
lines changed

.env.example

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Supabase Configuration
2+
NEXT_PUBLIC_SUPABASE_URL=https://xxxxxx.supabase.co
3+
NEXT_PUBLIC_SUPABASE_ANON_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
4+
SUPABASE_SERVICE_ROLE=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
5+
NEXT_PUBLIC_SUPABASE_AUTH_URL=https://localhost:3000
6+
7+
# CSRF Protection (required) and Encryption Key (required for BYOK functionality)
8+
CSRF_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
9+
ENCRYPTION_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
10+
NEXT_PUBLIC_PROJECT_SHOW_ADDITIONAL_INFO=true
11+
ANALYZE=false
12+
13+
# Azure OpenAI
14+
AZURE_OPENAI_ENDPOINT=https://your-services.cognitiveservices.azure.com/
15+
AZURE_OPENAI_DEPLOYMENT=gpt-5-mini
16+
AZURE_OPENAI_API_VERSION=2025-04-01-preview
17+
AZURE_OPENAI_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
18+
19+
# Production Configuration (optional)
20+
NEXT_PUBLIC_VERCEL_URL=http://localhost:3000
21+
22+
# Google Search
23+
GOOGLE_SEARCH_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
24+
GOOGLE_SEARCH_CX=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
25+
26+
# Azure Configuration
27+
AZURE_CONTAINER_INSTANCES_ENABLED=true
28+
AZURE_SUBSCRIPTION_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
29+
AZURE_RESOURCE_GROUP=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
30+
AZURE_LOCATION=East US
31+
AZURE_CONTAINER_REGISTRY_SERVER=your-container-registry
32+
AZURE_CONTAINER_REGISTRY_USERNAME=llmhub1dv1dashboard
33+
AZURE_CONTAINER_REGISTRY_PASSWORD=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
34+
AZURE_TENANT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
35+
AZURE_CLIENT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
36+
AZURE_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
37+
AZURE_CONTAINER_REGISTRY=your-container-registry
38+
AZURE_DESKTOP_IMAGE=your-container-registry/llmhub-search-app-ai-desktop:latest
39+
40+
41+
# -----------------------------------------------------------------------------
42+
# Backend (Python) Please change based on the ports used
43+
# -----------------------------------------------------------------------------
44+
PYTHON_BACKEND_URL=http://0.0.0.0:8001
45+
NEXT_PUBLIC_BACKEND_URL=http://localhost:8001
46+
47+
48+
# -----------------------------------------------------------------------------
49+
# Subscriptions (Stripe)
50+
# -----------------------------------------------------------------------------
51+
STRIPE_API_KEY=sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
52+
STRIPE_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
53+
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
54+
STRIPE_PRICE_STARTER=price_xxxxxxxxxxxxxxxxxxxxxxxxx
55+
STRIPE_PRICE_PROFESSIONAL=price_xxxxxxxxxxxxxxxxxxxxxxxxx
56+
STRIPE_PRICE_ENTERPRISE=price_xxxxxxxxxxxxxxxxxxxxxxxxx

.gitignore

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# local env files
34+
.env.local
35+
.env.development.local
36+
.env.test.local
37+
.env.production.local
38+
39+
40+
# vercel
41+
.vercel
42+
43+
# typescript
44+
*.tsbuildinfo
45+
next-env.d.ts
46+
47+
# env
48+
.env
49+
50+
# bun
51+
bun.lockb
52+
bun.lock
53+
54+
/.cursor
55+
.claude/settings.local.json
56+
57+
58+
# Python
59+
__pycache__/
60+
*.py[cod]
61+
*$py.class
62+
*.so
63+
.Python
64+
build/
65+
develop-eggs/
66+
dist/
67+
downloads/
68+
eggs/
69+
.eggs/
70+
lib64/
71+
parts/
72+
sdist/
73+
var/
74+
wheels/
75+
*.egg-info/
76+
.installed.cfg
77+
*.egg
78+
MANIFEST
79+
80+
# PyInstaller
81+
*.manifest
82+
*.spec
83+
84+
# Installer logs
85+
pip-log.txt
86+
pip-delete-this-directory.txt
87+
88+
# Unit test / coverage reports
89+
htmlcov/
90+
.tox/
91+
.coverage
92+
.coverage.*
93+
.cache
94+
nosetests.xml
95+
coverage.xml
96+
*.cover
97+
.hypothesis/
98+
.pytest_cache/
99+
100+
# Jupyter Notebook
101+
.ipynb_checkpoints
102+
103+
# pyenv
104+
.python-version
105+
106+
# celery beat schedule file
107+
celerybeat-schedule
108+
109+
# SageMath parsed files
110+
*.sage.py
111+
112+
# Environments
113+
.env
114+
.venv
115+
env/
116+
venv/
117+
ENV/
118+
env.bak/
119+
venv.bak/
120+
121+
# Spyder project settings
122+
.spyderproject
123+
.spyproject
124+
125+
# Rope project settings
126+
.ropeproject
127+
128+
# mkdocs documentation
129+
/site
130+
131+
# mypy
132+
.mypy_cache/
133+
.dmypy.json
134+
dmypy.json
135+
pd.env
136+
backend/dev.env
137+
dv.env
138+
backend/prod.env
139+
140+
# claude
141+
142+
.claude\settings.local.json
143+

Dockerfile

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Base Node.js image
2+
FROM node:18-alpine AS base
3+
4+
# Install dependencies only when needed
5+
FROM base AS deps
6+
WORKDIR /app
7+
8+
# Copy package files
9+
COPY package.json package-lock.json* ./
10+
11+
# Install dependencies (including devDependencies for build)
12+
RUN npm ci && npm cache clean --force
13+
14+
# Rebuild the source code only when needed
15+
FROM base AS builder
16+
WORKDIR /app
17+
18+
# Accept build arguments
19+
ARG ENCRYPTION_KEY
20+
ARG CSRF_SECRET
21+
ARG NEXT_PUBLIC_SUPABASE_URL
22+
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
23+
ARG SUPABASE_SERVICE_ROLE
24+
ARG STRIPE_API_KEY
25+
ARG STRIPE_WEBHOOK_SECRET
26+
ARG STRIPE_PRICE_STARTER
27+
ARG STRIPE_PRICE_PROFESSIONAL
28+
ARG STRIPE_PRICE_ENTERPRISE
29+
30+
# Set environment variables for build
31+
ENV ENCRYPTION_KEY=$ENCRYPTION_KEY
32+
ENV CSRF_SECRET=$CSRF_SECRET
33+
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
34+
ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY
35+
ENV SUPABASE_SERVICE_ROLE=$SUPABASE_SERVICE_ROLE
36+
ENV STRIPE_API_KEY=$STRIPE_API_KEY
37+
ENV STRIPE_WEBHOOK_SECRET=$STRIPE_WEBHOOK_SECRET
38+
ENV STRIPE_PRICE_STARTER=$STRIPE_PRICE_STARTER
39+
ENV STRIPE_PRICE_PROFESSIONAL=$STRIPE_PRICE_PROFESSIONAL
40+
ENV STRIPE_PRICE_ENTERPRISE=$STRIPE_PRICE_ENTERPRISE
41+
42+
# Copy node_modules from deps
43+
COPY --from=deps /app/node_modules ./node_modules
44+
45+
# Copy all project files
46+
COPY . .
47+
48+
# Set Next.js telemetry to disabled
49+
ENV NEXT_TELEMETRY_DISABLED=1
50+
51+
# Build the application
52+
RUN npm run build
53+
54+
# Verify standalone build was created
55+
RUN ls -la .next/ && \
56+
if [ ! -d ".next/standalone" ]; then \
57+
echo "ERROR: .next/standalone directory not found. Make sure output: 'standalone' is set in next.config.ts"; \
58+
exit 1; \
59+
fi
60+
61+
# Production image, copy all the files and run next
62+
FROM base AS runner
63+
WORKDIR /app
64+
65+
# Set environment variables
66+
ENV NODE_ENV=production
67+
ENV NEXT_TELEMETRY_DISABLED=1
68+
69+
# Create a non-root user
70+
RUN addgroup --system --gid 1001 nodejs && \
71+
adduser --system --uid 1001 nextjs
72+
73+
# Copy public assets (only if it exists)
74+
COPY --from=builder /app/public ./public
75+
76+
# Copy standalone application
77+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
78+
79+
# Copy static assets
80+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
81+
82+
# Ensure proper permissions for nextjs user
83+
RUN chown -R nextjs:nodejs /app
84+
85+
# Switch to non-root user
86+
USER nextjs
87+
88+
# Expose application port
89+
EXPOSE 3000
90+
91+
# Set environment variable for port
92+
ENV PORT=3000
93+
ENV HOSTNAME=0.0.0.0
94+
95+
# Health check to verify container is running properly
96+
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
97+
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
98+
99+
# Start the application
100+
CMD ["node", "server.js"]

backend/.dockerignore

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
venv/
8+
env/
9+
ENV/
10+
build/
11+
develop-eggs/
12+
dist/
13+
downloads/
14+
eggs/
15+
.eggs/
16+
lib/
17+
lib64/
18+
parts/
19+
sdist/
20+
var/
21+
wheels/
22+
*.egg-info/
23+
.installed.cfg
24+
*.egg
25+
26+
# Testing
27+
.pytest_cache/
28+
.coverage
29+
htmlcov/
30+
.tox/
31+
.hypothesis/
32+
33+
# IDE
34+
.vscode/
35+
.idea/
36+
*.swp
37+
*.swo
38+
*~
39+
40+
# Environment
41+
.env
42+
.env.local
43+
.env.*.local
44+
45+
# Logs
46+
logs/
47+
*.log
48+
49+
# OS
50+
.DS_Store
51+
Thumbs.db
52+
53+
# Git
54+
.git/
55+
.gitignore
56+
57+
# Documentation
58+
README.md
59+
docs/
60+
61+
# Scripts
62+
run_backend.bat
63+
run_backend.sh

0 commit comments

Comments
 (0)