File size: 3,803 Bytes
948a2cf
c377a9f
 
948a2cf
c377a9f
 
 
948a2cf
1d51d6a
948a2cf
 
c377a9f
948a2cf
2fd90c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
948a2cf
c377a9f
 
495a6a5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2fd90c5
 
 
 
 
 
 
 
c377a9f
2fd90c5
 
 
 
 
 
c377a9f
ba43f4d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2fd90c5
c377a9f
2fd90c5
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---
title: STARS Report Redactor
emoji: 🛡️
colorFrom: red
colorTo: gray
sdk: streamlit
app_file: app.py
pinned: false
license: agpl-3.0
---

# STARS Report Redactor

Web tool for the **BUAI Builder Hub (BBH) / BBHCourseReg** project. A student
uploads their USC STARS Degree Progress Report PDF; it removes personal
information (name, ID, address, sport) and grades (each grade replaced with a
pass/fail marker, GPA figures blanked) **entirely in memory** and returns a
redacted copy. The uploaded file is never written to disk or stored.

**This repository is the single home for the redaction tool** — the web app,
the redaction engine, and the command-line tool all live here together. Pushing
to this repo automatically rebuilds and redeploys the live Space.

## What to edit where

| File / folder | What it is | Edit it for |
|---|---|---|
| `app.py` | the Streamlit web UI | look & wording of the web app |
| `redactors/` | the redaction engine | redaction logic / behavior |
| `redact_stars.py` | the command-line tool (batch/single) | CLI features |
| `requirements.txt` | Python dependencies | adding a package |
| `README.md` | this file (the top YAML configures the Space) | docs / Space config |

Deploying is automatic: commit and `git push` to this repo, and the Space
rebuilds. There are no copies to keep in sync.

## Configuration

**Space secrets** (Space → Settings → Variables and secrets):

| Secret | Purpose |
|---|---|
| `APP_PASSPHRASE` | access phrase; the app refuses to run without it |
| `HF_TOKEN` | Write token to the submissions dataset; enables the Submit button |
| `SUBMISSIONS_REPO` | *(optional)* override the default dataset repo id |

**Editable constants** (top of `app.py` — temporary values, update in one place
if they change):

| Constant | Current value | Used for |
|---|---|---|
| `CONTACT_EMAIL` | `buaibuilderhub@gmail.com` | general questions shown in the app |
| `DELETE_FORM_URL` | a Google Form link | students' "delete my report" requests |
| `SUBMISSIONS_REPO` | `buai-builder-hub/redacted-stars-submissions` | where submissions are stored |

## Run locally

```bash
pip install -r requirements.txt

# web app:
streamlit run app.py                 # set APP_PASSPHRASE in your env first

# command line (single file, folder batch, or preview):
python redact_stars.py report.pdf                      # PII + grades
python redact_stars.py a_folder/ -o out/               # batch
python redact_stars.py report.pdf --redact pii         # PII only
python redact_stars.py report.pdf --dry-run            # show, write nothing
```

## Submissions

On "Submit," the app saves the **redacted** file to a private HF Dataset
(`buai-builder-hub/redacted-stars-submissions`) as `<ID>.pdf` and shows the
student that ID. Enabled by Space secrets `HF_TOKEN` (a Write token) and,
optionally, `SUBMISSIONS_REPO`.

## Maintenance TODO

- **Admin "delete + purge by ID" script.** Students can request deletion by
  their report ID. Removing `<ID>.pdf` from the dataset takes it out of the
  current tree, but the blob remains in git history until purged. Build a small
  admin script that deletes the file **and** rewrites/purges history (or uses
  `super_squash_history`) so a deletion request is fully honored.
- **Replace the contact placeholder** (`CONTACT` in `app.py`) with the real BBH
  inbox once it exists — the deletion ID needs somewhere to go.

## Notes

- Redaction is not perfect anonymization: major, terms, and the course list
  remain, which can be identifying in a small program. This is disclosed to
  students in the app before they consent.
- Scanned/image-only PDFs have no text layer and are skipped (they can't be
  redacted here); use the PDF saved from experience.usc.edu.
- Licensed AGPL-3.0 because it uses MuPDF/PyMuPDF.