Privacy Shield is a web-based platform designed to help users protect sensitive information by redacting Personally Identifiable Information (PII) from their documents. It leverages Google's Gemini for intelligent, AI-powered redaction and provides a fallback to traditional regex-based methods for maximum flexibility.
- AI-Powered Redaction: Utilizes Google Gemini to intelligently find and remove PII from various document types.
- Multiple Redaction Methods: Choose between Masking (replacing PII with ████████) or Replacing (swapping PII with realistic fake data).
- Broad File Support: Process a wide range of document formats, including TXT, CSV, PDF, DOCX, and RTF.
- Image Redaction: Advanced capabilities to redact text and faces from images.
- Customizable Rules: Fine-tune redaction by specifying custom values to redact or ignore.
- Secure User Authentication: Full authentication system powered by Firebase Auth (Email/Password and Google OAuth).
- File Management Dashboard: A user-friendly dashboard to upload files, view processing history, and download redacted documents.
- Secure Cloud Storage: All original and redacted files are securely stored using Firebase Storage, with access controlled by strict rules.
- Framework: Next.js (with App Router)
- Backend & Database: Firebase (Auth, Firestore, Storage, Functions)
- Language: TypeScript
- Styling: Tailwind CSS with shadcn/ui
- AI: Google Gemini
- State Management: React Query (@tanstack/react-query)
- File Processing: pdfjs-dist, mammoth.js, jszip, papaparse
- Icons: Lucide React
Follow these instructions to get a copy of the project up and running on your local machine for development and testing purposes.
Make sure you have the following software installed on your machine:
- Node.js (v22.x or later recommended)
- pnpm (or npm/yarn)
- Firebase CLI: npm install -g firebase-tools
git clone https://github.com/your-username/privacy-shield.git
cd privacy-shieldpnpm installThe project can be run in two modes: using the Firebase Emulator Suite (recommended for local development) or connecting to a live Firebase project.
First, create an environment file by copying the example:
cp .env.example .env.localNow, follow the instructions for your chosen mode.
This is the easiest way to run the project locally without needing a live Firebase project. The emulators simulate the entire Firebase backend on your machine.
Step 1: Configure Environment for Emulator
In your .env.local file, make sure the emulator flag is set to true:
# .env.local
NEXT_PUBLIC_USE_EMULATOR=true
# You can leave the other Firebase variables empty or as they are
# The Gemini API Key is still needed for AI features
GEMINI_API_KEY="your_google_gemini_api_key"Note: You still need a GEMINI_API_KEY from Google AI Studio for the AI redaction features to work.
Step 2: Login to Firebase
If you haven't already, log in to your Google account via the Firebase CLI:
firebase loginStep 3: Start the Emulators
In your terminal, start the Firebase Emulator Suite. This will spin up local instances of Auth, Firestore, Storage, and Functions.
firebase emulators:startOnce running, you should see a table of running emulators and their ports. You can access the Emulator UI at http://localhost:4000 to view your local database, users, and stored files.
Step 4: Run the Next.js Application
In a new terminal window, start the Next.js development server:
pnpm devYour application will be running at http://localhost:3000 and will automatically connect to the local Firebase emulators.
Use this mode if you want to test against a real Firebase backend.
Step 1: Create a Firebase Project
- Go to the Firebase Console and create a new project.
- Enable Firestore: Go to the Firestore Database section and create a database in production mode.
- Enable Storage: Go to the Storage section and set it up.
- Enable Authentication:
- Go to the Authentication section.
- Click on "Get Started".
- Enable the Email/Password and Google sign-in providers.
Step 2: Register a Web App
- In your project's settings, click "Add app" and select the "Web" icon (</>).
- Register the app. You don't need to add the SDKs.
- Firebase will provide you with a firebaseConfig object. Copy these keys.
Step 3: Get Gemini API Key
- Go to Google AI Studio.
- Create a new API key.
Step 4: Configure Environment for Live Project
Now, populate your .env.local file with the keys you just obtained.
# .env.local
# Set to false to connect to your live Firebase project
NEXT_PUBLIC_USE_EMULATOR=false
# Paste your Web App config from the Firebase Console here
NEXT_PUBLIC_FIREBASE_API_KEY="your_api_key"
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN="your_project_id.firebaseapp.com"
NEXT_PUBLIC_FIREBASE_PROJECT_ID="your_project_id"
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET="your_project_id.appspot.com"
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID="your_sender_id"
NEXT_PUBLIC_FIREBASE_APP_ID="your_app_id"
# Paste your Gemini API key here
GEMINI_API_KEY="your_google_gemini_api_key"
# This is used for the Firebase Admin SDK on the server-side
FIREBASE_ADMIN_DATABASE_URL="https://your_project_id.firebaseio.com"Step 5: Set up Service Account Credentials
The backend needs admin privileges to communicate with Firebase securely.
-
In the Firebase Console, go to Project Settings > Service accounts.
-
Click "Generate new private key" and save the downloaded JSON file.
-
Important: Do not commit this file to Git. The .gitignore file is already configured to ignore it.
-
Set an environment variable that points to the location of this file. On Linux/macOS:
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/service-account-file.json"
On Windows (Command Prompt):
set GOOGLE_APPLICATION_CREDENTIALS="C:\path\to\your\service-account-file.json"
Step 6: Run the Next.js Application
Start the Next.js development server:
pnpm devThe application will now be connected to your live Firebase project.
Here's a high-level overview of the key directories in the project:
.
├── functions/ # Firebase Cloud Functions (if any are added)
├── public/ # Static assets (images, svgs, etc.)
├── src/
│ ├── app/ # Next.js App Router: pages and API routes
│ │ ├── api/ # Backend API routes
│ │ ├── dashboard/ # Main application dashboard
│ │ └── (auth)/ # Route group for signin/signup pages
│ ├── components/ # React components
│ │ ├── composites/ # Application-specific components
│ │ └── ui/ # Reusable UI components from shadcn/ui
│ ├── contexts/ # React Context providers (Auth, etc.)
│ ├── lib/ # Core logic and utilities
│ │ ├── serverUtils/ # Server-side only utilities (e.g., AI redaction)
│ │ └── utils/ # Shared utilities (Firebase client, file handling)
│ ├── services/ # Functions for interacting with external services
│ └── types/ # TypeScript type definitions
├── .firebaserc # Firebase project configuration
├── firebase.json # Firebase services and emulator configuration
├── firestore.rules # Firestore security rules
└── storage.rules # Cloud Storage security rules
In the project directory, you can run:
pnpm dev: Runs the app in development mode with Turbopack.pnpm build: Builds the app for production.pnpm start: Starts a production server.pnpm lint: Lints the codebase for errors and style issues.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
