# Project Blueprint: Secure Patent File History Fetcher ### Project Objective Create a lightweight, local web application where a user inputs an 8-digit USPTO application number and instantly views the official, public Image File Wrapper (IFW) transaction history and direct PDF download links. --- ### The Architecture: Why We Need a Backend The programmer must understand that this cannot be built entirely in the browser using frontend JavaScript. * **The Security Rule:** The USPTO requires a secret **API Key** to access their servers. If we put this key in the frontend HTML/JavaScript, anyone can right-click the page, click "Inspect Element," and steal it. * **The Solution:** Use a **Client-Server model**. The frontend browser collects the application number and sends it to our local Python server. The Python server securely attaches the API key, talks to the USPTO, receives the data, and passes it back to the browser safely. --- ### Step-by-Stepç•… Implementation Guide for the Programmer #### 1. Environment & Tools * **Language:** Python 3 * **Libraries to Install:** `requests` (for handling HTTP communication) and `flask` (a lightweight web framework to host the app). * **Prerequisites:** Register a free developer account at `data.uspto.gov` and generate an API key for the **Patent File Wrapper API**. #### 2. Building the Backend (`app.py`) The programmer needs to write a Flask script that sets up two distinct "routes" (URLs): * **Route 1 (`/`):** Serves a basic HTML webpage to the browser when the user opens the app. * **Route 2 (`/get-history`):** An API endpoint that waits for an application number from the frontend. When Route 2 receives an application number, it must execute a `GET` request using the `requests` library to the official USPTO production endpoint: ```text https://api.uspto.gov/api/v1/patent/applications/{APP_NUMBER}/documents ``` The script must securely inject the developer's API key into the HTTP request headers using the custom key designation required by the USPTO (`X-API-KEY`). #### 3. Handling the Data Payload The USPTO server returns a status code of `200 OK` and a structured data format called a **JSON object**. The programmer will need to parse this object: * Look for a main data key called `documentBag` which holds an array (list) of dictionaries. * Each dictionary in that list represents a file history document and contains key-value pairs the programmer needs to display: `officialDate`, `documentCodeDescriptionText`, and `downloadUrl` (the direct link to the USPTO PDF file). #### 4. Building the Frontend (HTML/JavaScript) Inside the Flask application, the programmer will design a clean, simple user interface using standard HTML and CSS: * An **Input Box** with a placeholder text asking for an 8-digit application number. * A **"Search" Button** that triggers a JavaScript function when clicked. * A **Results Display Box** (like a `
` or `
` tag) to show the incoming file log.
* **The JavaScript Logic:** Use the modern `fetch()` API to asynchronously send the input box value to the Python server's `/get-history` route, listen for the JSON response, and dynamically update the webpage text without requiring a full page refresh.

---

### Expected Outcome & Extension Challenge

When the programmer runs `python app.py`, it will host a local server at `http://127.0.0.1:5000`. Typing a published application number (like `14412875`) will display a clean, chronological list of every Office Action and response issued during prosecution.