TrojanMind — Project Story
## Inspiration
It started with a conversation in the library at 2 AM. A friend had three
deadlines in 48 hours, a midterm on Thursday, and hadn't slept properly in
days. He wasn't struggling because he was unprepared — he was struggling
because no tool he had could look at his calendar and say "this week is
going to break you, here's how to survive it."
Google Calendar showed him the events. Canvas showed him the grades.
Neither of them thought for him.
We realized that the gap wasn't in productivity tools — it was in
intelligent, emotionally-aware coordination. USC has world-class
counseling resources, but with average wait times exceeding 16 days and
over 60% of distressed students never seeking help at all (NAMI, 2022),
the system couldn't scale to every student who needed it. We wanted to
build something that could.
## What We Learned
Building TrojanMind taught us that AI in wellness is a design problem
as much as a technical one. The hardest part wasn't getting Claude to
generate a study plan — it was making sure the system never led with
advice when a student needed empathy first.
We learned to think in terms of a risk function. Given a student's
calendar events $E = {e_1, e_2, \ldots, e_n}$, each with an urgency
score $u_i \in [1, 5]$ and cognitive load $c_i \in {1, 2, 3}$, we
modeled stress as:
$$S = \frac{\sum_{i=1}^{n} u_i \cdot c_i}{\sqrt{n}} + \lambda \cdot D$$
where $D$ is the number of deadline clusters (events within 36 hours of
each other) and $\lambda$ is a weighting constant tuned to map $S$ onto
a $[1, 10]$ scale. This informed our burnout risk tiers:
| Stress Score $S$ | Burnout Risk |
|-----------------|--------------|
| $S \leq 3$ | Low |
| $4 \leq S \leq 6$ | Medium |
| $7 \leq S \leq 8$ | High |
| $S \geq 9$ | Critical |
We also learned a lot about agentic pipeline design — specifically
that chaining smaller, focused prompts produces far more reliable JSON
than one giant prompt trying to do everything at once.
## How We Built It
TrojanMind is a full-stack application with a React frontend and a
Node.js/Express backend powered by the Anthropic Claude API.
### The AI Pipeline
The core is a 3-stage agentic pipeline that runs on every calendar
submission:
Stage 1 — Event Classifier
Each calendar event is scored for urgency $(u_i)$, tagged with a
cognitive load level, and checked for deadline clustering. This runs as
a single structured Claude call returning a JSON array.
Stage 2 — Risk Assessor
The enriched events feed into a risk model that computes the stress
score, burnout risk tier, key stressors, and alerts. It also sets a
crisisMode flag if $S \geq 9$.
Stage 3 — Plan Engine (or Crisis Brief)
If crisisMode is false, Claude generates a balanced 7-day plan
merging real calendar events with study blocks and wellness tasks.
If crisisMode is true, it generates an immediate crisis brief with
USC-specific resources instead.
A parallel crisis classifier runs independently on every chat
message, scoring distress on a $[0, 3]$ scale and prepending a
[CRISIS-SUPPORT] token if the score crosses a threshold — regardless
of the main pipeline.
### Calendar Integration
We built an iCal parser that fetches .ics feeds directly from
Brightspace and Google Calendar, classifies events using keyword
matching, and filters to a 14-day rolling window. Students who don't
have a calendar link can describe their week in plain English — a
single-pass freetext prompt extracts structured events and runs the
full analysis.
### Streaming Narrative
The dashboard opens with a live-typed personal narrative about the
student's week using Server-Sent Events (SSE). This was important
for perceived responsiveness — users feel heard immediately rather than
staring at a loading spinner.
## Challenges
Getting the AI to say less, not more.
Early versions of the chat system were verbose and advice-heavy.
Students in distress don't want a 5-point action plan — they want to
feel understood. We rewrote the system prompt multiple times, adding
explicit rules like "never lead with a study plan when the student
expresses overwhelm" and "always acknowledge emotional state before
academic advice."
JSON reliability at scale.
Claude occasionally returns trailing commas, truncated objects, or
markdown-wrapped JSON when the output is long. We added a parseJSON
sanitizer and increased max_tokens to 4096 for the plan stage after
realizing that a 7-day plan with 4–6 tasks per day routinely exceeded
the default budget.
Merging real events with AI tasks.
Our first attempt at the 7-day plan let Claude invent all the tasks.
The output was generic — "90-minute study session," "attend scheduled
classes." We rebuilt it to seed each day with the student's actual
calendar events first, then fill gaps with AI-generated study and
wellness tasks, sorted chronologically. The result felt personal
because it was personal.
Walking the line on crisis support.
This was the most sensitive design challenge. We are not mental health
professionals, and TrojanMind is not a clinical tool. We had to be
careful that the crisis mode surfaced real USC resources (the 24/7
Crisis Line, TimelyCare) prominently and immediately — and that the AI
never implied it could substitute for them. Every crisis response ends
with a direct link and phone number.
Log in or sign up for Devpost to join the conversation.