Skip to content

Latest commit

 

History

History
190 lines (141 loc) · 4.35 KB

README.md

File metadata and controls

190 lines (141 loc) · 4.35 KB
saleor-app-template

Saleor Example Anonymization App

This app helps anonymize customer data securely and efficiently.


Overview

This application anonymizes customer data, focusing on the following:

  • Scrambles user details (e.g., names, emails, and phone numbers).
  • Updates user orders with anonymized data.
  • Deletes the customer profile after anonymization (optional).
  • Integrated with Saleor via GraphQL API.

Table of Contents


Features

  • Fetches user and order data using GraphQL APIs.
  • Updates orders with anonymized details:
    • First Name, Last Name → Replaced with placeholders.
    • Email → Converted to a UUID-based format.
    • Phone → Replaced with a non-functional number.
  • Deletes customer data post-anonymization.

Requirements

Ensure the following are installed before starting:


Setup Instructions

Environment Variables

Set the environment variable in a .env.local file:

NEXT_PUBLIC_CUSTOMER_SCRAMBLE_DOMAIN=yourdomain.com

Variable Explanation:

  • NEXT_PUBLIC_CUSTOMER_SCRAMBLE_DOMAIN: Specifies the domain for anonymized email addresses. Defaults to example.com.

Installation

  1. Clone the repository:

    git clone https://github.com/your-repo/anonymization-app.git
    cd anonymization-app
  2. Install dependencies:

    pnpm install

Running the Application

Development

  1. Start the application in development mode:

    pnpm dev
  2. Expose your local server: Use a tunneling tool like ngrok to expose your local server for Saleor.

  3. Install the application via Saleor Dashboard:

    [YOUR_SALEOR_DASHBOARD_URL]/apps/install?manifestUrl=[YOUR_APP_TUNNEL_MANIFEST_URL]/api/manifest
    

Production

  1. Build the application:

    pnpm build
  2. Start the production server:

    pnpm start

Testing

Unit Tests

Run unit tests:

pnpm test

Environment for Testing

Ensure .env.test is set up for testing:

NEXT_PUBLIC_CUSTOMER_SCRAMBLE_DOMAIN=testdomain.com

Docker Setup

Development Docker

  1. Build the development image:

    docker build -t anonymization-app-dev -f Dockerfile.dev .
  2. Run the development container:

    docker run -p 3000:3000 -v $(pwd):/app anonymization-app-dev

Production Docker

  1. Build the production image:

    docker build -t anonymization-app-prod -f Dockerfile.prod .
  2. Run the production container:

    docker run -p 3000:3000 anonymization-app-prod

Project Structure

.
├── src
│   ├── ScrambleAllOrdersByEmail.tsx   # Main Component
├── tests
│   ├── unit
│   │   └── scramble-all-orders-by-email.test.ts   # Unit Tests
├── Dockerfile.dev                          # Development Dockerfile
├── Dockerfile.prod                         # Production Dockerfile
├── .env.local                              # Environment Variables
├── .env.test                               # Test Environment Variables
├── vitest.config.ts                        # Vitest Configuration