From 688eb2a5c8e47120281beeac5cf291d23803b674 Mon Sep 17 00:00:00 2001 From: greeneu Date: Sat, 15 Mar 2025 19:28:26 +0530 Subject: [PATCH] removed supabase placeholder dependency completely for smooth startup and added macos scripts too. updated README.md for more info --- CHANGES.md | 18 +++++ README.md | 87 +++++++++--------------- cleanup-for-github.sh | 26 ++++++++ electron/main.ts | 7 +- package.json | 1 - src/lib/supabase.ts | 150 ++++++++++-------------------------------- stealth-run.bat | 16 ++++- stealth-run.sh | 49 ++++++++++++++ 8 files changed, 173 insertions(+), 181 deletions(-) create mode 100644 cleanup-for-github.sh create mode 100644 stealth-run.sh diff --git a/CHANGES.md b/CHANGES.md index d844b57..dff60e4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,23 @@ # Interview Coder - Unlocked Edition - Changes +## Major Architectural Changes + +### Removal of Supabase Authentication System +1. **Complete Removal of Supabase Dependencies**: + - Removed all Supabase code, imports, and API calls + - Eliminated the authentication system completely + - Removed all subscription and payment-related code + +2. **Replaced with Local Configuration**: + - Added `ConfigHelper.ts` for local storage of settings + - Implemented direct OpenAI API integration + - Created a simplified settings system with model selection + +3. **User Interface Simplification**: + - Removed login/signup screens + - Added a welcome screen for new users + - Added comprehensive settings dialog for API key and model management + ## Fixes and Improvements ### UI Improvements diff --git a/README.md b/README.md index 2e66e60..45d7822 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ The best coding interview tools are often behind expensive paywalls, making them The codebase is designed to be adaptable: -- **AI Models**: Though currently using OpenAI's models, you can modify the code to integrate with other providers like Claude, Deepseek, Llama, or any model with an API +- **AI Models**: Though currently using OpenAI's models, you can modify the code to integrate with other providers like Claude, Deepseek, Llama, or any model with an API. All integration code is in `electron/ProcessingHelper.ts` and UI settings are in `src/components/Settings/SettingsDialog.tsx`. - **Languages**: Add support for additional programming languages - **Features**: Extend the functionality with new capabilities - **UI**: Customize the interface to your preferences @@ -84,7 +84,7 @@ Note: The application is **NOT** invisible to: ## Running the Application -### Initial Setup +### Quick Start 1. Clone the repository: @@ -99,59 +99,51 @@ cd interview-coder-unlocked npm install ``` -This will install all required npm packages including Electron, React, TypeScript, and other dependencies needed for the application. - -### Running in Stealth Mode - -For the best experience, follow these steps to run the application: - -1. First, clean any previous builds: +3. **RECOMMENDED**: Clean any previous builds: ```bash npm run clean ``` -This command removes the `dist` and `dist-electron` directories to ensure a fresh build without any cached files or outdated components. - -2. Then run the stealth-run batch file: +4. Run the appropriate script for your platform: +**For Windows:** ```bash stealth-run.bat ``` -**What the stealth-run.bat does:** -- Creates necessary directories in your AppData folder for storing screenshots and cache -- Builds the application in production mode -- Launches the application in stealth mode (invisible by default) -- Provides a reminder of key shortcuts +**For macOS/Linux:** +```bash +# Make the script executable first +chmod +x stealth-run.sh +./stealth-run.sh +``` -**IMPORTANT**: When using stealth-run.bat, the application window will be invisible by default! Use Ctrl+B (or Cmd+B on Mac) to toggle visibility. +**IMPORTANT**: The application window will be invisible by default! Use Ctrl+B (or Cmd+B on Mac) to toggle visibility. -### Troubleshooting +**What the scripts do:** +- Create necessary directories for the application +- Clean previous builds to ensure a fresh start +- Build the application in production mode +- Launch the application in invisible mode -If you encounter any issues with the application: +### Notes & Troubleshooting -1. Always start with a clean build: +- **Window Manager Compatibility**: Some window management tools (like Rectangle Pro on macOS) may interfere with the app's window movement. Consider disabling them temporarily. -```bash -npm run clean -``` +- **API Usage**: Be mindful of your OpenAI API key's rate limits and credit usage. Vision API calls are more expensive than text-only calls. -2. Make sure you have the latest dependencies: +- **LLM Customization**: You can easily customize the app to include LLMs like Claude, Deepseek, or Grok by modifying the API calls in `ProcessingHelper.ts` and related UI components. -```bash -npm install -``` - -3. If the window is invisible and keyboard shortcuts don't seem to work, try: - - Pressing Ctrl+B (or Cmd+B on Mac) multiple times - - Checking Task Manager/Activity Monitor to verify the application is running - - Restarting the application +- **Common Issues**: + - Run `npm run clean` before starting the app for a fresh build + - Use Ctrl+B/Cmd+B multiple times if the window doesn't appear + - Adjust window opacity with Ctrl+[/]/Cmd+[/] if needed + - For macOS: ensure script has execute permissions (`chmod +x stealth-run.sh`) ## Comparison with Paid Version of Interview Coder | Feature | Interview Coder (Paid) | Interview Coder Unlocked (This Project) | -|---------|------------------------|----------------------------------------| | Price | $60/month subscription | Free (only pay for your API usage) | | Solution Generation | ✅ | ✅ | | Debugging Assistance | ✅ | ✅ | @@ -206,30 +198,15 @@ npm install - Window remains invisible to specified screen sharing applications - Reset view using [Control or Cmd + R] -## Using Custom AI Models - -This application currently uses OpenAI's GPT models, but you can adapt it to work with other AI providers: - -### Integration Points - -The main integration point is in `electron/ProcessingHelper.ts`, which handles: - -1. **Problem Extraction**: Converting screenshots to text and understanding the problem -2. **Solution Generation**: Creating optimized solutions with explanations -3. **Debugging**: Analyzing code errors and providing improvement suggestions +## Adding More AI Models -### Steps to Integrate Different Models +This application is built with extensibility in mind. You can easily add support for additional LLMs alongside the existing OpenAI integration: -1. Replace the OpenAI client initialization with your preferred AI provider's SDK -2. Modify the API calls in `processScreenshotsHelper`, `generateSolutionsHelper`, and `processExtraScreenshotsHelper` methods -3. Adjust prompt formats based on your chosen model's capabilities -4. Update the UI components in `src/components/Settings/SettingsDialog.tsx` to reflect your model options +- You can add Claude, Deepseek, Grok, or any other AI model as alternative options +- The application architecture allows for multiple LLM backends to coexist +- Users can have the freedom to choose their preferred AI provider -Common alternative AI providers to consider: -- Anthropic's Claude (good vision capabilities) -- Deepseek (strong coding performance) -- Self-hosted open-source models (Llama, Mixtral) -- Azure OpenAI Service (same API but with Azure integration) +To add new models, simply extend the API integration in `electron/ProcessingHelper.ts` and add the corresponding UI options in `src/components/Settings/SettingsDialog.tsx`. The modular design makes this straightforward without disrupting existing functionality. ## Configuration diff --git a/cleanup-for-github.sh b/cleanup-for-github.sh new file mode 100644 index 0000000..9bfff1d --- /dev/null +++ b/cleanup-for-github.sh @@ -0,0 +1,26 @@ +#!/bin/bash +echo "Cleaning up project for GitHub..." + +echo "Removing node_modules directory..." +rm -rf node_modules + +echo "Removing dist directory..." +rm -rf dist + +echo "Removing dist-electron directory..." +rm -rf dist-electron + +echo "Removing release directory..." +rm -rf release + +echo "Removing package-lock.json..." +rm -f package-lock.json + +echo "Removing any .env files..." +rm -f .env .env.local .env.development .env.production + +echo "Cleanup complete!" +echo "Ready to commit to GitHub." +echo "Run 'npm install' after cloning to install dependencies." +echo "Press Enter to continue..." +read diff --git a/electron/main.ts b/electron/main.ts index 38603f2..937a7a1 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -492,12 +492,7 @@ function loadEnvVariables() { ) dotenv.config({ path: path.join(process.resourcesPath, ".env") }) } - console.log("Loaded environment variables:", { - VITE_SUPABASE_URL: process.env.VITE_SUPABASE_URL ? "exists" : "missing", - VITE_SUPABASE_ANON_KEY: process.env.VITE_SUPABASE_ANON_KEY - ? "exists" - : "missing" - }) + console.log("Environment variables loaded for open-source version") } // Initialize application diff --git a/package.json b/package.json index 6036c2b..f580033 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,6 @@ "@radix-ui/react-label": "^2.1.0", "@radix-ui/react-slot": "^1.1.0", "@radix-ui/react-toast": "^1.2.2", - "@supabase/supabase-js": "^2.39.0", "@tanstack/react-query": "^5.64.0", "axios": "^1.7.7", "class-variance-authority": "^0.7.1", diff --git a/src/lib/supabase.ts b/src/lib/supabase.ts index 32d5adb..1283b16 100644 --- a/src/lib/supabase.ts +++ b/src/lib/supabase.ts @@ -1,122 +1,40 @@ -import { createClient } from "@supabase/supabase-js" +// This file has been emptied to remove Supabase dependencies. +// The open-source version uses local configuration instead. -console.log("Supabase URL:", import.meta.env.VITE_SUPABASE_URL) -console.log( - "Supabase Anon Key:", - import.meta.env.VITE_SUPABASE_ANON_KEY?.slice(0, 10) + "..." -) - -const supabaseUrl = import.meta.env.VITE_SUPABASE_URL -const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY - -if (!supabaseUrl || !supabaseAnonKey) { - throw new Error("Missing Supabase environment variables") -} - -export const supabase = createClient(supabaseUrl, supabaseAnonKey, { +// Export empty objects to prevent import errors in case any components still reference this file +export const supabase = { auth: { - flowType: "pkce", - detectSessionInUrl: true, - persistSession: true, - autoRefreshToken: true, - debug: true, - storage: { - getItem: (key) => { - const item = localStorage.getItem(key) - console.log("Auth storage - Getting key:", key, "Value exists:", !!item) - return item - }, - setItem: (key, value) => { - console.log("Auth storage - Setting key:", key) - localStorage.setItem(key, value) - }, - removeItem: (key) => { - console.log("Auth storage - Removing key:", key) - localStorage.removeItem(key) - } - } + getUser: async () => ({ data: { user: null } }), + onAuthStateChange: () => ({ data: { subscription: { unsubscribe: () => {} } } }), + signOut: async () => ({ error: null }), + exchangeCodeForSession: async () => ({ error: null }), + signInWithOAuth: async () => ({ data: null, error: null }) }, - realtime: { - params: { - eventsPerSecond: 10 - }, - headers: { - apikey: supabaseAnonKey - } - } -}) - -export const signInWithGoogle = async () => { - try { - console.log("Initiating Google sign in...") - const { data, error } = await supabase.auth.signInWithOAuth({ - provider: "google", - options: { - redirectTo: window.location.origin - } - }) - - if (error) { - console.error("Google sign in error:", error) - throw error - } - - console.log("Google sign in response:", data) - return data - } catch (error) { - console.error("Unexpected error during Google sign in:", error) - throw error - } -} - -let channel: ReturnType | null = null - -// Monitor auth state changes and manage realtime connection -supabase.auth.onAuthStateChange((event, session) => { - console.log("Auth state changed:", event, session?.user?.id) - console.log("Full session data:", session) - - if (event === "SIGNED_IN" && session) { - // Only establish realtime connection after successful sign in - console.log("Establishing realtime connection...") - - // Clean up existing channel if any - if (channel) { - channel.unsubscribe() - } - - channel = supabase.channel("system", { - config: { - presence: { - key: session.user.id - } - } - }) - - channel - .on("system", { event: "*" }, (payload) => { - console.log("System event:", payload) + from: () => ({ + select: () => ({ + eq: () => ({ + single: async () => null, + maybeSingle: async () => null }) - .subscribe((status) => { - console.log("Realtime subscription status:", status) - if (status === "SUBSCRIBED") { - console.log("Successfully connected to realtime system") - } - if (status === "CHANNEL_ERROR") { - console.error("Realtime connection error - will retry in 5s") - setTimeout(() => { - channel?.subscribe() - }, 5000) - } + }), + update: () => ({ + eq: () => ({ + select: () => ({ + single: async () => null + }) }) - } + }) + }), + channel: () => ({ + on: () => ({ + subscribe: () => ({ + unsubscribe: () => {} + }) + }) + }) +}; - if (event === "SIGNED_OUT") { - // Clean up realtime connection on sign out - if (channel) { - console.log("Cleaning up realtime connection") - channel.unsubscribe() - channel = null - } - } -}) +export const signInWithGoogle = async () => { + console.log("Sign in with Google not available in open-source version"); + return { data: null }; +}; diff --git a/stealth-run.bat b/stealth-run.bat index b1bfa6b..927a980 100644 --- a/stealth-run.bat +++ b/stealth-run.bat @@ -18,16 +18,22 @@ echo. cd /D "%~dp0" -echo 1. Creating required directories... +echo === Step 1: Creating required directories... === mkdir "%APPDATA%\interview-coder-v1\temp" 2>nul mkdir "%APPDATA%\interview-coder-v1\cache" 2>nul mkdir "%APPDATA%\interview-coder-v1\screenshots" 2>nul mkdir "%APPDATA%\interview-coder-v1\extra_screenshots" 2>nul -echo 2. Building application... +echo === Step 2: Cleaning previous builds... === +echo Removing old build files to ensure a fresh start... +rmdir /s /q dist dist-electron 2>nul +del /q .env 2>nul + +echo === Step 3: Building application... === +echo This may take a moment... call npm run build -echo 3. Launching in stealth mode... +echo === Step 4: Launching in stealth mode... === echo Remember: Press Ctrl+B to make it visible, Ctrl+[ and Ctrl+] to adjust opacity! echo. set NODE_ENV=production @@ -35,3 +41,7 @@ start /B cmd /c "npx electron ./dist-electron/main.js" echo App is now running invisibly! Press Ctrl+B to make it visible. echo. +echo If you encounter any issues: +echo 1. Make sure you've installed dependencies with 'npm install' +echo 2. Press Ctrl+B multiple times to toggle visibility +echo 3. Check Task Manager to verify the app is running diff --git a/stealth-run.sh b/stealth-run.sh new file mode 100644 index 0000000..3e5a04a --- /dev/null +++ b/stealth-run.sh @@ -0,0 +1,49 @@ +#!/bin/bash +echo "=== Interview Coder - Invisible Edition (No Paywall) ===" +echo +echo "IMPORTANT: This app is designed to be INVISIBLE by default!" +echo "Use the keyboard shortcuts to control it:" +echo +echo "- Toggle Visibility: Cmd+B" +echo "- Take Screenshot: Cmd+H" +echo "- Process Screenshots: Cmd+Enter" +echo "- Move Window: Cmd+Arrows (Left/Right/Up/Down)" +echo "- Adjust Opacity: Cmd+[ (decrease) / Cmd+] (increase)" +echo "- Reset View: Cmd+R" +echo "- Quit App: Cmd+Q" +echo +echo "When you press Cmd+B, the window will toggle between visible and invisible." +echo "If movement shortcuts aren't working, try making the window visible first with Cmd+B." +echo + +# Navigate to script directory +cd "$(dirname "$0")" + +echo "=== Step 1: Creating required directories... ===" +mkdir -p ~/Library/Application\ Support/interview-coder-v1/temp +mkdir -p ~/Library/Application\ Support/interview-coder-v1/cache +mkdir -p ~/Library/Application\ Support/interview-coder-v1/screenshots +mkdir -p ~/Library/Application\ Support/interview-coder-v1/extra_screenshots + +echo "=== Step 2: Cleaning previous builds... ===" +echo "Removing old build files to ensure a fresh start..." +rm -rf dist dist-electron +rm -f .env + +echo "=== Step 3: Building application... ===" +echo "This may take a moment..." +npm run build + +echo "=== Step 4: Launching in stealth mode... ===" +echo "Remember: Cmd+B to make it visible, Cmd+[ and Cmd+] to adjust opacity!" +echo +export NODE_ENV=production +npx electron ./dist-electron/main.js & + +echo "App is now running invisibly! Press Cmd+B to make it visible." +echo +echo "If you encounter any issues:" +echo "1. Make sure you've installed dependencies with 'npm install'" +echo "2. Make sure this script has execute permissions (chmod +x stealth-run.sh)" +echo "3. Press Cmd+B multiple times to toggle visibility" +echo "4. Check Activity Monitor to verify the app is running"