Skip to content

Sahith59/ShadowAI

Repository files navigation

๐ŸŒ‘ Shadow AI โ€” Invisible Interview Copilot

Shadow AI is a macOS desktop overlay that listens to your system audio in real time, transcribes it using Groq Whisper, and generates AI-powered responses โ€” all in a window invisible to screen sharing and recording software.

Built for technical interviews, coding challenges, and meetings โ€” your interviewer sees nothing.


โœจ Features

  • ๐ŸŽ™๏ธ Real-time system audio capture โ€” captures everything playing on your Mac (Zoom calls, browser audio, etc.)
  • ๐Ÿคซ Invisible to screen sharing โ€” the overlay is hidden from any screen recording or sharing tool
  • ๐Ÿง  Context-aware AI responses โ€” remembers conversation history and gives structured, interview-quality answers
  • ๐Ÿ’ป 8 specialized session modes โ€” SDE, Data Science, PM, Business, Data Analyst, Meeting, General, and Custom
  • โŒจ๏ธ Manual question input โ€” type questions directly when you don't want to rely on audio
  • ๐Ÿ“ธ Screen capture mode โ€” AI can see and analyze what's on your screen
  • ๐Ÿ’พ Code detail windows โ€” dedicated floating windows for code snippets with syntax highlighting
  • ๐Ÿ“Š Code compare view โ€” side-by-side naive vs optimal solution viewer
  • ๐Ÿ“„ Document upload โ€” upload PDFs and DOCX files as context for the AI
  • ๐Ÿ”„ Auto-fallback โ€” switches to Cerebras when Groq hits rate limits (seamless, no interruption)
  • ๐Ÿ“‰ Token-optimized โ€” smart conversation history compression saves ~40-50% in API costs

๐Ÿ–ฅ๏ธ Requirements

Requirement Version
macOS 12 Monterey or later
Node.js 18+
npm 8+
Groq API Key Free at console.groq.com
Cerebras API Key (optional) Free at cloud.cerebras.ai

Windows/Linux are not supported. The app uses macOS-specific APIs for window invisibility, system audio capture, and screen recording permissions.


๐Ÿš€ Installation & Setup

Step 1 โ€” Clone the repository

git clone https://github.com/YOUR_USERNAME/ShadowChatbot.git
cd ShadowChatbot

Step 2 โ€” Install dependencies

npm install

Step 3 โ€” Add your API keys

Open services/groq.js in any text editor:

nano services/groq.js
# or
code services/groq.js

Find the constructor (around line 6) and replace the placeholder values with your own keys:

class GroqService {
    constructor(apiKey) {
        // โœ… Replace with your Groq API key
        this.apiKey = 'YOUR_GROQ_API_KEY_HERE';
        
        // โœ… Replace with your Cerebras API key (used as fallback when Groq rate-limits)
        this.cerebrasApiKey = 'YOUR_CEREBRAS_API_KEY_HERE';
        
        // ... rest of the constructor
    }
}

Important: Never commit your real API keys to GitHub. See the API Key Security section below.

Step 4 โ€” Grant macOS Screen Recording permission

  1. Open System Settings โ†’ Privacy & Security โ†’ Screen Recording
  2. Enable the toggle for Electron (or your app's name)
  3. If it doesn't appear, run the app once (npm start) and it will prompt for access

Step 5 โ€” Run the app

npm start

๐Ÿ”‘ Getting Your API Keys

Groq API Key (Required)

Groq powers both speech-to-text (Whisper large-v3-turbo) and the LLM (Llama 3.3 70B). Groq's free tier is generous:

  1. Go to console.groq.com
  2. Sign up or log in
  3. Click API Keys in the sidebar โ†’ Create API Key
  4. Copy the key (starts with gsk_...)
  5. Paste it into services/groq.js as shown above

Cerebras API Key (Optional โ€” Fallback)

Cerebras is used as an automatic fallback when Groq hits rate limits. Highly recommended for sustained usage:

  1. Go to cloud.cerebras.ai
  2. Sign up or log in
  3. Click your profile โ†’ API Keys โ†’ Create new API key
  4. Copy the key (starts with csk_...)
  5. Paste it into services/groq.js as this.cerebrasApiKey

If you don't have a Cerebras key, just leave the field blank โ€” the app will only use Groq. Set this.cerebrasApiKey = ''; to disable the fallback.


๐Ÿ” API Key Security

โš ๏ธ NEVER commit your API keys to a public repository.

To keep your keys safe, use a .env file pattern:

Option A โ€” Environment variables (recommended)

Create a .env file in the project root:

GROQ_API_KEY=gsk_your_key_here
CEREBRAS_API_KEY=csk_your_key_here

Add .env to .gitignore:

echo ".env" >> .gitignore

Then in services/groq.js, read from environment:

// In Electron renderer, use ipcMain to pass env vars from main process
// Or use a local config file pattern
this.apiKey = process.env.GROQ_API_KEY || 'fallback';

Option B โ€” Local config file

Create config.local.js (add to .gitignore):

module.exports = {
    groqApiKey: 'gsk_your_key_here',
    cerebrasApiKey: 'csk_your_key_here'
};

Import it in services/groq.js:

const config = require('../config.local.js');
this.apiKey = config.groqApiKey;

๐ŸŽฎ Usage

Starting a Session

  1. Launch the app with npm start
  2. On the home screen, choose your session mode (SDE, DS, PM, etc.)
  3. Optionally add a briefing โ€” paste your resume, job description, or any context you want the AI to know
  4. Click Launch Overlay

Keyboard Shortcuts

Shortcut Action
Cmd + Shift + L Toggle audio listening on/off
Cmd + Shift + H Show/hide the overlay
Cmd + Q Quit the app

During an Interview

  • Press Cmd+Shift+L to start listening โ€” the overlay picks up system audio automatically
  • Talk or let the interviewer talk โ€” transcripts appear in the left pane
  • After 5 seconds of silence, the AI generates a response in the right pane
  • Use the manual input box at the bottom to type questions directly
  • Click any AI response to copy it or view code in a detail window

๐Ÿงฉ Session Modes

Mode Best For
๐Ÿ’ป SDE LeetCode, system design, FAANG-style coding interviews
๐Ÿ“Š Data Scientist ML concepts, SQL, statistics, A/B testing, case studies
๐ŸŽฏ Product Manager Product sense, strategy, metrics, estimation, roadmaps
๐Ÿ“ˆ Business & Marketing Consulting cases, marketing analytics, financial analysis
๐Ÿ” Data Analyst SQL queries, Excel, Tableau/Power BI, dashboards
๐Ÿค Meeting Assistant Live note-taking, action items, Q&A during meetings
โœจ General All-purpose assistant for anything
โš™๏ธ Custom Write your own system prompt for any use case

๐Ÿ—๏ธ Project Architecture

ShadowChatbot/
โ”œโ”€โ”€ main.js                 # Electron main process โ€” windows, IPC, permissions
โ”œโ”€โ”€ preload.js              # Secure bridge between main and renderer
โ”œโ”€โ”€ renderer.js             # Core UI logic, audio pipeline, AI response handling
โ”œโ”€โ”€ index.html              # Overlay window HTML
โ”œโ”€โ”€ home.html               # Setup/briefing screen HTML
โ”œโ”€โ”€ styles.css              # Overlay styles
โ”œโ”€โ”€ home-styles.css         # Home screen styles
โ”œโ”€โ”€ home-renderer.js        # Home screen logic
โ”œโ”€โ”€ code-detail.html        # Floating code window
โ”œโ”€โ”€ code-compare.html       # Side-by-side code compare window
โ”œโ”€โ”€ code-viewer.html        # Code snippet list window
โ””โ”€โ”€ services/
    โ”œโ”€โ”€ groq.js             # Groq + Cerebras API wrapper (STT + LLM)
    โ”œโ”€โ”€ audio.js            # System audio capture + WAV encoding
    โ”œโ”€โ”€ prompts.js          # Session mode system prompts
    โ”œโ”€โ”€ context.js          # Screen capture + context extraction
    โ””โ”€โ”€ code-extractor.js   # Code snippet parser from AI responses

How Audio Capture Works

macOS System Audio
      โ†“
desktopCapturer (Electron)
      โ†“
getUserMedia (audio + video stream)
      โ†“ (video track kept alive to maintain capture session)
MediaStream (audio-only) โ†’ MediaRecorder (timeslice: 3s)
      โ†“
ondataavailable โ†’ WebM chunks
      โ†“
AudioContext.decodeAudioData โ†’ OfflineAudioContext resample to 16kHz
      โ†“
WAV blob โ†’ Groq Whisper API โ†’ Transcript text
      โ†“
Transcript buffer (5s silence timeout) โ†’ Groq Llama 3.3 70B โ†’ AI Response

๐Ÿ› ๏ธ Troubleshooting

Audio capture not working

  1. Check Screen Recording permission โ€” System Settings โ†’ Privacy & Security โ†’ Screen Recording โ†’ Electron โœ…
  2. Fully quit and restart after granting permission (Cmd+Q, not just closing the window)
  3. Make sure audio is actually playing โ€” the app captures system audio, so something must be playing (YouTube, Zoom, etc.)
  4. Check the DevTools console (Cmd+Option+I) for [Audio] log messages

AI not responding

  1. Check your Groq API key is set correctly in services/groq.js
  2. Check the console for API error messages (401 = wrong key, 429 = rate limit)
  3. If you see rate limit errors, add a Cerebras API key as a fallback

"Autofill.enable failed" errors in terminal

These are harmless DevTools protocol warnings from Electron โ€” ignore them. They don't affect functionality.

App not invisible to screen recording

Ensure you are running the app with npm start (not packaged). The setContentProtection(true) flag is set for all windows, which hides them from screen capture on macOS.


๐Ÿค Contributing

Pull requests are welcome! For major changes, open an issue first to discuss what you'd like to change.

  1. Fork the repo
  2. Create your feature branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -m 'Add my feature'
  4. Push to the branch: git push origin feature/my-feature
  5. Open a Pull Request

๐Ÿ“„ License

MIT License โ€” see LICENSE for details.


โš ๏ธ Disclaimer

Shadow AI is intended for personal productivity and learning. Use responsibly and in accordance with the terms of service of any platform you use it with. The authors are not responsible for misuse.

About

Shadow AI is a macOS desktop overlay that listens to your system audio in real time, transcribes it using Groq Whisper, and generates AI-powered responses.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors