Inspiration

In Nigerian universities, a lot of learning happens from photocopied handouts, dense textbooks and past questions, often on a mid-range Android phone with a small data bundle. When you're stuck at 11 pm before a test, there's usually no one to ask.

There's a quieter problem too. In every class, a few students really get a topic. They explain it to friends for free, while classmates pay for "lesson" centres. Their knowledge is valuable, but they have no way to earn from it.

We wanted one thing that fixes both: an AI learning agent built on your own course, where helping other students learn is paid work. PayPal made the second half possible.

What it does

Ifiok (an Ibibio word for wisdom) is an AI learning agent for Nigerian university students:

  • Learn. Add your course outline, then your notes, textbook or past questions (PDF, Word or photos). Ifiok builds lessons you can move: plots with sliders, checkpoints, diagrams. Every number in them is checked by a maths engine.
  • Practise. Every answer is re-marked on the server. Weak areas shows the evidence ("1 of 5 right this week"), your most common mistake and what to do next. Exam prep turns past questions into a study plan.
  • Labs. Virtual practicals with a seeded experiment engine and a printable report.
  • Earn, with PayPal. Share notes or record an explainer; you earn points when it helps another student, and the monthly pool is paid out with PayPal Payouts. Tutor topics you know: the learner's payment is authorised at booking, captured after the session, or voided if you don't show.
  • Ifiok's tutoring agent. Tap Find me a tutor. The agent looks at what you keep getting wrong, finds a peer tutor within the spending limit you set, and drafts the booking with its reasons. Only your approval on PayPal moves money.

How we built it

  • Next.js 16 (TypeScript strict) on Vercel, and Supabase for Postgres with row-level security on every table, pgvector, job queues (pgmq) and a Deno worker.
  • AI through our own gateway, with per-student daily allowances, a global cost cap, retries and fallback, and JSON validation. Text runs on Groq (gpt-oss-120b and gpt-oss-20b), images on Gemini 3.5 Flash, voice captions on Whisper.
  • PayPal (sandbox): Orders v2 with intent: AUTHORIZE, capture and void; Payouts; and webhooks verified with verify-webhook-signature on the raw body. AG Grid powers the admin tables.

The model explains; engines compute. The AI never outputs HTML or code. It outputs lesson data, and a verifier recomputes every number with mathjs before anything is published. A lesson on slope that says

$$f(x) = \tfrac{1}{2}x^2 \quad\Rightarrow\quad f'(2) = 2$$

is only published if the engine agrees. A practice question whose stated answer disagrees with its own expression is dropped.

Money that can't move twice. Every money change goes through an idempotent SQL function keyed on the PayPal id, and every PayPal POST carries a PayPal-Request-Id. The monthly pool split runs in SQL. If $P$ is the pool and $p_i$ are student $i$'s usage points:

$$\text{share}_i = \min!\left(\left\lfloor P \cdot \frac{p_i}{\sum_j p_j} \right\rfloor,\ \lfloor 0.2\,P \rfloor\right)$$

so no one takes more than 20%, and whatever the cap holds back stays in the pool. A tutor's payout is the price minus Ifiok's 15% commission:

$$\text{tutor} = c - \operatorname{round}(0.15\,c), \qquad c = 800 \text{ cents} \;\Rightarrow\; \$6.80$$

An agent that proposes, never pays. The tutoring agent gets reference codes (W1, T1), never names or ids. The server first filters tutors to the student's own limit. When the model answers, the server checks every reference, the time, and every number in its reason against the data it was given; if anything fails, simple rules choose instead. A database constraint makes a proposal above the limit impossible to store.

Challenges we ran into

  • PayPal can't pay money into Nigerian accounts. Our first sandbox payout was denied with no error code. The cause was test accounts set to Nigeria, which can send but not receive. For the demo, money runs in US dollars with US sandbox accounts. After the hackathon, real payouts move to a Nigerian provider in naira. We wrote this decision down rather than hide it.
  • Making AI numbers trustworthy. Early lessons had confident, wrong arithmetic. That led to the verify-then-publish pipeline, and to the rule that a payout explanation keeps the AI's wording only if every number in it is one the server provided.
  • Flaky networks. Our development machine intermittently failed to look up PayPal's hostname, which failed bookings. We added retries for network failures, which is only safe because every call is idempotent.
  • Webhooks. PayPal's signature check needs the event byte for byte, so the raw body is passed through untouched. After verifying, we still fetch the real status from PayPal before recording anything.
  • Admins aren't students. The first admin screens lived inside the student app. We split them into their own interface, so admins only see admin work.

Accomplishments that we're proud of

  • A complete loop, not a mock-up. A student learns, gets stuck, the agent finds a tutor, PayPal holds the payment, the session is confirmed and the tutor is paid out. All of it runs live in the PayPal sandbox.
  • Real payouts in the sandbox. A month's pool is split in SQL with the 20% cap, sent as one PayPal Payouts batch, and each line is marked paid exactly once. Our tests replay webhooks three times to prove it.
  • AI students can trust. No number reaches a student unless an engine computed it, and the agent can't propose anything over the student's limit or move money on its own.
  • Built for the real user. It works on a 360 px phone screen, reads PDFs on the device, and accepts photos of handouts.
  • Tested end to end: over 400 unit tests, database tests for every security rule, and browser tests against the live sandbox and real AI.

What we learned

  • AI is most useful when it's boxed in: structured outputs, server-side checks and a deterministic fallback make it dependable enough to sit next to money.
  • Idempotency is the backbone of payments. Once every step can safely run twice, retries, replayed webhooks and timeouts stop being scary.
  • Building for real constraints (small data bundles, mid-range phones, PayPal's country limits) shaped the product more than any feature list.
  • An agent earns trust by showing its working and asking before it acts.

What's next for Ifiok: the AI learning agent

  • A pilot with real students at one or two Nigerian universities.
  • Payouts in naira through a Nigerian payment provider, after legal review.
  • More labs, plus a grounded tutor you can ask about any lesson block or past question.
  • Better tutor matching as ratings and learning-gain scores build up.

The goal stays the same: every student learns from their own course, and every student who helps someone else learn gets paid for it.

Built With

Share this project:

Updates

Submission history