Pre-reviewing student reports with local AI, part 2: the pipeline, and the computer it had to run on
Part 2 of 2. Part 1 built the checker and tuned it on real submissions. This part covers the automated pipeline (phase 3), and why the project stopped before packaging (phase 4).
Where part 1 left off
The checker (revisor) is a Python CLI that pre-reviews a student report and produces a spreadsheet
row and a Markdown report. LanguageTool counts spelling and grammar errors, rules check the course
template and the APA/IEEE references, and a small local model (gemma4:e4b on Ollama) adds advisory
comments on the references. The hard constraint is unchanged: student work does not leave the
machine.
Phase 3 was about making it run without anyone typing commands: the professor drops PDFs in a folder, and the results show up on their own.
The shape of the pipeline
n8n (every 15 min) ──POST /escanear──▶ revisor service ──▶ LanguageTool (container)
│ └─▶ Ollama (native, GPU)
▼
inbox/ → report + spreadsheet row → procesados/
Three decisions shaped it:
- A schedule, not a file watcher. Watchers miss events: a file copied in pieces, a sync client that writes a temp file and renames it, a service that was restarting at the wrong moment. A scan every 15 minutes that looks at what’s actually in the folder can’t miss anything, and the checker already skips files modified in the last few seconds.
- A tiny HTTP service instead of calling the CLI. n8n runs in its own container and can’t run a
Python command in another one. So the checker got a ~100-line wrapper on Python’s standard
ThreadingHTTPServer, with two endpoints:GET /salud(is the config valid, are LanguageTool and Ollama answering) andPOST /escanear. It reloads the config on every request, so editing the assignments file needs no restart. - “Busy” is an answer, not an error. If a scan is still running when the next one fires, the service
answers
200 {"estado": "ocupado"}and does nothing. A long batch just makes the schedule skip a turn.
The n8n workflow is deliberately boring: a schedule trigger, an “Ejecutar ahora” (run now) button, one HTTP request with a 3-hour timeout, and a Split Out node so each processed file appears as its own item. All the logic lives in the checker, where it’s tested. n8n is there so the professor can see the pipeline: when it ran, what it processed, where each file went.
Docker Compose, and keeping it local
Compose runs three services: LanguageTool, the checker and n8n. Ollama stays outside, installed
natively, because that’s how it gets the GPU. The containers reach it through host.docker.internal,
which on Docker Desktop just works. On plain Docker Engine, Ollama has to listen beyond 127.0.0.1
(OLLAMA_HOST=0.0.0.0) and the port has to be firewalled.
Everything else is about not leaking anything:
- Every port is published on
127.0.0.1only. - n8n’s telemetry, version checks, templates and community packages are off.
- n8n is pinned to an exact version. The newest major release had come out that same day, which is not the day to adopt it.
One surprise during n8n’s first-run setup: it offered an AI assistant with a “code sandbox”, and the
form asked for a hosted service URL and an API key. The workflow has no code steps, and that feature
would send workflow data to an external service. Both AI modules are now switched off in the compose
file (N8N_DISABLED_MODULES=instance-ai,workflow-builder), with a comment saying why. If you’re building
a privacy-first pipeline on a tool, read its setup screens as carefully as its docs: features that
phone home now ship on by default.
Bugs that only containers revealed
Like phase 2’s real documents, moving into containers surfaced things no test had:
- The clock. The service container ran on UTC, so every report was stamped six hours in the
future.
TZ=America/Costa_Ricafixed it. - The paths. The file locations the service returned to n8n were paths inside the container, meaningless to anyone looking at the host. They’re now relative to the project, so they read the same everywhere.
- The owner. Reports and moved files came out owned by root. The service now runs as the same user who owns the folder.
- The model’s name. While cleaning up disk space,
gemma4:e4bdisappeared and onlygemma4:latestwas left. Same size, same quantization, same architecture, down to an audio encoder that only the small Gemma 4 variants ship with, so it was the same model. Instead of pointing the config atlatest(which a futureollama pullcould silently change),ollama cpgave it back its explicit name. It uses no extra disk.
Getting files to the tool
The first version had an inbox/ folder on the machine itself, which means the professor has to be at
that machine. So: how should files get in? n8n supports plenty of options:
| Option | Appeal | Why not (for now) |
|---|---|---|
| Email (forward submissions to a mailbox) | Nothing to install; results come back as a reply | A new mailbox, or giving an agent access to an existing one, is the bigger security burden |
| Web form (n8n’s form trigger) | Most private: files go straight to the machine | The machine has to be reachable by the professor: HTTPS, authentication, network exposure |
| Drive / Dropbox nodes in n8n | Bulk-friendly | OAuth access to the professor’s cloud account, from the pipeline |
| The university’s LMS | Students already submit there | Needs an API token from IT, outside this project’s control |
| A chat bot | Quick to try | Student files would pass through a chat platform |
Email looked best on paper, and it was dropped for exactly the reason in the table. The decision instead was to scope the MVP to one professor, one machine, and use a folder in the professor’s own Dropbox, synced to that machine by the normal desktop client. They can drop files from any device, the reports come back to the same folder, the processing still happens locally, and the sync client is the only thing that talks to the cloud. Another professor who wants it installs their own copy.
The setup is one command, python -m revisor carpeta ~/Dropbox/Revisor, which saves the path to a
git-ignored .env and creates each assignment’s inbox/, procesados/, fallidos/ and resultados/.
One small trick keeps a single config file working both on the host and in the container: compose
bind-mounts the folder at the same path inside the container as outside it.
Gotchas, all now in the README:
- Google Drive has no official Linux client (it needs rclone or Insync). Dropbox does.
- Files set to “online only” aren’t really there. The folder has to be available offline.
- If someone edits the spreadsheet on another device while the checker writes to it, the sync client makes a “conflicted copy”. Treat it as read-only.
- Docker Desktop only shares
/homeby default, so the folder has to live there. - Before the config learned to expand
${REVISOR_CARPETA}, a folder named literally${REVISOR_CARPETA}appeared in the project. An undefined variable is now a config error that names the command to run.
The real test: the four real reports from part 1, dropped into the Dropbox inbox. The 10:30 scheduled scan picked them up and finished at 10:41, about two and a half minutes each, almost all of it the local model commenting on references. Four reports, four rows, four files moved, and every later scan found nothing new.
The lock that didn’t lock
Two scans running at once would pick up the same files and append to the same spreadsheet. The checker
prevents that with an fcntl.flock on a lock file, and the HTTP service relies on it to answer “busy”.
Inside the container, it works: I held the lock and called the service, and it answered ocupado. Then
I held the lock on the host, ran a scan through the service, and it scanned anyway.
On Docker Desktop, containers run inside a VM, and the project folder reaches them through a file-sharing
layer. Locks taken on one side aren’t visible on the other. The lock file is shared; the lock isn’t. So
a professor running python -m revisor escanear in a terminal while n8n’s scan was running could have
processed the same files twice.
The fix doesn’t try to make the lock cross the VM boundary. The CLI now checks whether the service is up, and if it is, it asks the service to scan instead of scanning itself. If the service is already busy, the CLI says so and exits. Only when no service answers does it scan locally, and inside the container, where the lock does work, it always does. One place does the scanning, so there’s only one lock that matters.
When LanguageTool is down
The original behaviour: if LanguageTool didn’t answer, the file was still marked reviewed, with blank spelling and grammar columns and a note, and moved out of the inbox. Nothing ever retried it.
Now a file that can’t be language-checked waits: it stays in the inbox as PENDIENTE, with nothing
written and nothing moved, and the next scan picks it up. I tested it the honest way, by stopping the
LanguageTool container mid-test. Ollama being down still doesn’t hold anything back, because the
model’s comments are only suggestions and the rules still decide.
One near miss from the cleanup, worth mentioning because it’s so easy: the folder with the four real
student reports used for testing was not in .gitignore. The first commit would have included them.
It’s ignored now, along with every folder that ever holds student files.
Then the target machine changed
At this point phase 3 was done, and phase 4 was mostly paperwork: bake the current code into the image, pin LanguageTool’s version, write install steps in Spanish.
Then the hosting question got its answer: the professor wanted to run it on their own personal computer. That’s a reasonable choice, and it matches the “one professor, one machine” scope. But it was a different machine from the one everything had been measured on:
| Development machine | Professor’s PC | |
|---|---|---|
| RAM | 32 GB | 16 GB |
| GPU | 6 GB VRAM | none |
We tried the local models there:
| Model | Size on disk | What happened |
|---|---|---|
| gemma4:e4b | 9.6 GB | Loading took too long or the console hung |
| qwen3:8b | 5.2 GB | Same |
| qwen2.5:7b | 4.7 GB | Same |
| llama3.2 (3B) | 2.0 GB | Ran, but the comments weren’t good enough |
In hindsight, the warning was already in part 1: even on the development machine, only about a third of gemma4:e4b fit in VRAM and the rest ran on the CPU, at 2–3 minutes per report. On 16 GB with no GPU, a 9.6 GB model has to share memory with the operating system, Docker, LanguageTool’s Java process and n8n. The models that fit comfortably are the ones part 1 had already ruled out as too weak to follow a detailed style guide.
A look at what a full review could be
To see what we’d be waiting for, we took a few old reports, converted them to Markdown, anonymized them by hand (names, team and anything else identifying edited out), and had two cloud models, Claude and Codex, do a full review: not just references but spelling, grammar and template, the whole job.
The gap wasn’t subtle. Both cloud models caught far more than the local tool, ran faster, and never got stuck. That matches part 1, where the cloud model was the only one with no wrong comments on references, in seconds instead of minutes. Only now it was the whole review, not just the references.
Using old documents and editing them by hand matters here. As part 1 said, removing names isn’t full anonymization, because a report about a unique project can be recognized by its content. That’s fine for an occasional comparison done by hand. It isn’t a pipeline you can run on every new submission.
So: on hold
The project is paused, not abandoned. The “everything runs locally” requirement still stands, and on the machine where it has to run, no local model is good enough yet. The cloud comparison makes the trade-off concrete: the better review already exists, it just doesn’t run locally. It comes back when one of two things happens:
- A better small model: one that follows a detailed APA/IEEE guide and fits in 16 GB of RAM without a GPU. Small models are improving fast, and the checker only needs a config change to try one.
- A better computer: anything with a GPU in the 6 GB range brings back the setup that already works.
Phase 4’s to-do list is written down and waiting: the image with the current code, a pinned LanguageTool, install steps for Docker Engine, starting everything at login, and the Spanish README. The “references only” cloud option is still built and still off.
Lessons from part 2
- Measure on the target machine first. Every timing and model choice in part 1 was measured on the wrong computer. “Runs locally” means nothing until you know whose local. That would have been one conversation at the start.
- Keep the orchestrator thin. n8n triggers, retries and shows. The checker does the work, where the tests are. Swapping the trigger, or dropping n8n entirely, wouldn’t touch the logic.
- “Busy” and “wait” are better answers than errors. A skipped turn and a file left for the next scan recover on their own. A blank row marked “reviewed” doesn’t.
- Containers change the meaning of familiar things. The clock, the paths, file ownership and file locks all changed when the code moved into a container. None of them failed loudly.
- Read the setup screens of your tools. Privacy-first means checking what a tool turns on by default, not just what you configure.
- The simplest secure intake wins for an MVP. A synced folder in the professor’s own account beat email, forms and cloud integrations because it added no new access to anything.