Skip to content

Commit a3ba6f2

Browse files
committed
Refactor and Merge to GitHub
0 parents  commit a3ba6f2

File tree

113 files changed

+23940
-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.

113 files changed

+23940
-0
lines changed

.dockerignore

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Node modules
2+
node_modules/
3+
frontend/website/node_modules/
4+
frontend/extension/node_modules/
5+
backend/node_modules/
6+
backend/website/node_modules/
7+
backend/extension/node_modules/
8+
9+
# Extension frontend - exclude from Docker builds
10+
frontend/extension/
11+
12+
# Logs
13+
logs/
14+
*.log
15+
npm-debug.log*
16+
yarn-debug.log*
17+
yarn-error.log*
18+
lerna-debug.log*
19+
20+
# System files
21+
.DS_Store
22+
Thumbs.db
23+
24+
# Git and IDE
25+
.git/
26+
.gitignore
27+
.vscode/
28+
.idea/
29+
*.swp
30+
*.swo
31+
32+
# Environment files
33+
.env
34+
.env.*
35+
!.env.example
36+
*.env
37+
!*.env.example
38+
39+
# Build output
40+
frontend/website/dist/
41+
frontend/website/build/
42+
dist/
43+
build/
44+
45+
# Development
46+
docker-compose.yml
47+
Dockerfile.dev
48+
49+
# Documentation
50+
README.md
51+
*.md
52+
53+
# Batch scripts (Windows)
54+
*.bat

.env.example

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Application Environment
2+
NODE_ENV=development
3+
PORT=10000
4+
5+
# Website Backend
6+
CHROME_EXTENSION_ORIGIN=chrome-extension://your-extension-id
7+
8+
# Extension Backend
9+
GEMINI_API_KEY=your-gemini-api-key
10+
MODEL=gemini-2.5-flash
11+
INSTRUCTIONS="You are a helpful coding assistant for LeetCode problems."
12+
13+
# Backend Ports (internal to container)
14+
WEBSITE_PORT=3001
15+
EXTENSION_PORT=3002
16+
17+
# Redis Configuration (for extension chat sessions)
18+
REDIS_URL=your-redis-url
19+
20+
# Frontend Environment Variables
21+
VITE_SITE_URL=https://leetbuddy.app
22+
VITE_VIDEO_URL=https://example.com/demo-video.mp4
23+
VITE_CHROME_STORE_URL=https://chromewebstore.google.com/detail/abcd
24+
25+
# Development NGINX Port
26+
NGINX_PORT=80

.gitignore

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Environment files
2+
.env
3+
.env.*
4+
!.env.example
5+
*.env
6+
!*.env.example
7+
8+
# Dependencies
9+
node_modules/
10+
frontend/website/node_modules/
11+
frontend/extension/node_modules/
12+
backend/node_modules/
13+
backend/website/node_modules/
14+
backend/extension/node_modules/
15+
16+
# Build outputs
17+
dist/
18+
build/
19+
frontend/website/dist/
20+
frontend/website/build/
21+
frontend/extension/dist/
22+
frontend/extension/build/
23+
*.tsbuildinfo
24+
25+
# Logs
26+
logs/
27+
*.log
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
lerna-debug.log*
32+
.pnpm-debug.log*
33+
34+
# OS files
35+
.DS_Store
36+
.DS_Store?
37+
._*
38+
.Spotlight-V100
39+
.Trashes
40+
ehthumbs.db
41+
Thumbs.db
42+
43+
# IDE files
44+
.vscode/
45+
.idea/
46+
*.swp
47+
*.swo
48+
*~
49+
.project
50+
.classpath
51+
.c9/
52+
*.launch
53+
.settings/
54+
*.sublime-workspace
55+
56+
# Testing
57+
coverage/
58+
.nyc_output/
59+
60+
# Temporary files
61+
.temp/
62+
.tmp/
63+
.cache/
64+
65+
# Optional npm cache directory
66+
.npm
67+
68+
# Optional eslint cache
69+
.eslintcache
70+
71+
# Optional stylelint cache
72+
.stylelintcache
73+
74+
# Optional REPL history
75+
.node_repl_history
76+
77+
# Output of 'npm pack'
78+
*.tgz
79+
80+
# Yarn files
81+
.yarn-integrity
82+
.pnp.*
83+
.yarn/*
84+
!.yarn/patches
85+
!.yarn/plugins
86+
!.yarn/releases
87+
!.yarn/sdks
88+
!.yarn/versions
89+
90+
# Lock files (keep only one)
91+
# Keep package-lock.json, ignore others
92+
yarn.lock
93+
pnpm-lock.yaml
94+
95+
# Batch scripts (Windows)
96+
*.bat

Dockerfile

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Stage 1 — Build React app
2+
FROM node:22-alpine AS builder
3+
WORKDIR /app
4+
5+
# Copy website frontend package files only
6+
COPY frontend/website/package*.json ./frontend/website/
7+
RUN cd frontend/website && npm install
8+
9+
# Copy website frontend source
10+
COPY frontend/website/ ./frontend/website/
11+
12+
# Build website frontend with environment variables
13+
ARG VITE_SITE_URL=https://leetbuddy.app
14+
ARG VITE_VIDEO_URL
15+
ARG VITE_CHROME_STORE_URL
16+
ENV VITE_SITE_URL=$VITE_SITE_URL
17+
ENV VITE_VIDEO_URL=$VITE_VIDEO_URL
18+
ENV VITE_CHROME_STORE_URL=$VITE_CHROME_STORE_URL
19+
ENV NODE_ENV=production
20+
RUN cd frontend/website && npm run build
21+
22+
# Stage 2 — Backend dependencies
23+
FROM node:22-alpine AS backend-deps
24+
WORKDIR /app
25+
26+
# Copy backend package files
27+
COPY backend/package*.json ./backend/
28+
29+
# Install production dependencies
30+
RUN cd backend && npm install --omit=dev
31+
32+
# Stage 3 — Final image: NGINX + Node
33+
FROM nginx:stable-alpine
34+
35+
# Install Node.js and dumb-init for proper signal handling
36+
RUN apk add --no-cache nodejs npm dumb-init
37+
38+
# Create app directory
39+
WORKDIR /app
40+
41+
# Copy backend source and dependencies
42+
COPY backend/ ./backend/
43+
COPY --from=backend-deps /app/backend/node_modules ./backend/node_modules
44+
45+
# Copy built website frontend to nginx directory
46+
COPY --from=builder /app/frontend/website/dist /usr/share/nginx/html
47+
48+
# Copy NGINX config as template
49+
COPY nginx/default.conf /etc/nginx/templates/default.conf.template
50+
51+
# Build args for internal ports (with defaults)
52+
ARG WEBSITE_PORT=3001
53+
ARG EXTENSION_PORT=3002
54+
55+
# Set environment variables from build args
56+
ENV WEBSITE_PORT=$WEBSITE_PORT
57+
ENV EXTENSION_PORT=$EXTENSION_PORT
58+
ENV NODE_ENV=production
59+
60+
# Create an entrypoint that starts backend then delegates to nginx
61+
RUN echo '#!/bin/sh' > /entrypoint.sh && \
62+
echo 'set -e' >> /entrypoint.sh && \
63+
echo '' >> /entrypoint.sh && \
64+
echo '# Start backend in background' >> /entrypoint.sh && \
65+
echo 'cd /app/backend && node index.js &' >> /entrypoint.sh && \
66+
echo 'BACKEND_PID=$!' >> /entrypoint.sh && \
67+
echo '' >> /entrypoint.sh && \
68+
echo '# Handle shutdown gracefully - forward SIGQUIT to backend' >> /entrypoint.sh && \
69+
echo 'trap "kill -QUIT $BACKEND_PID 2>/dev/null || true; wait $BACKEND_PID 2>/dev/null || true; exit" SIGQUIT SIGTERM SIGINT' >> /entrypoint.sh && \
70+
echo '' >> /entrypoint.sh && \
71+
echo '# Run nginx entrypoint (handles templates + starts nginx)' >> /entrypoint.sh && \
72+
echo 'exec /docker-entrypoint.sh "$@"' >> /entrypoint.sh && \
73+
chmod +x /entrypoint.sh
74+
75+
# Health check using PORT from environment
76+
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
77+
CMD wget -q --spider http://localhost:${PORT:-10000}/health || exit 1
78+
79+
# Use dumb-init with our wrapper entrypoint
80+
ENTRYPOINT ["dumb-init", "--", "/entrypoint.sh"]
81+
CMD ["nginx", "-g", "daemon off;"]

Dockerfile.dev

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM node:22-alpine
2+
3+
RUN apk add --no-cache wget
4+
5+
WORKDIR /app
6+
7+
# Install dependencies for website frontend only
8+
COPY backend/package*.json ./backend/
9+
COPY frontend/website/package*.json ./frontend/website/
10+
11+
# Install all dependencies (including dev)
12+
RUN cd backend && npm install
13+
RUN cd frontend/website && npm install
14+
15+
# Copy source code
16+
COPY backend/ ./backend/
17+
COPY frontend/website/ ./frontend/website/
18+
19+
# Build website frontend with environment variables
20+
ARG VITE_SITE_URL=http://localhost
21+
ARG VITE_VIDEO_URL
22+
ARG VITE_CHROME_STORE_URL
23+
ENV VITE_SITE_URL=$VITE_SITE_URL
24+
ENV VITE_VIDEO_URL=$VITE_VIDEO_URL
25+
ENV VITE_CHROME_STORE_URL=$VITE_CHROME_STORE_URL
26+
RUN cd frontend/website && npm run build
27+
28+
WORKDIR /app/backend
29+
30+
# Build args for ports (with defaults)
31+
ARG WEBSITE_PORT=3001
32+
ARG EXTENSION_PORT=3002
33+
34+
# Set environment variables
35+
ENV WEBSITE_PORT=$WEBSITE_PORT
36+
ENV EXTENSION_PORT=$EXTENSION_PORT
37+
ENV NODE_ENV=${NODE_ENV:-development}
38+
39+
# Expose both backend ports
40+
EXPOSE $WEBSITE_PORT $EXTENSION_PORT
41+
42+
CMD ["node", "index.js"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Nicholas Jano
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)