Behavioural Engines
A platform that turns foundational decision science models into interactive, working simulations.
Overview
Behavioural Engines brings together what I have learnt in behavioural science and programming. The idea came from Michael Hallsworth's Behavioural Insights, which argues that behavioural science needs a core framework to move forward. This project takes the frameworks at the heart of the field and turns them into working models you can experiment with.
Demo
Model catalogue
The platform is built around a catalogue of models, with prospect theory and hyperbolic discounting at its core and others, such as rational inattention, added over time. Each model is an independent, versioned unit within a shared structure.
New models slot in cleanly because each one defines its own assumptions, equations, and parameter ranges, so adding one never means restructuring the wider platform.

Catalogue
Mathematical implementation
The core of the project is mathematical. Every model is implemented from first principles in Python, so prospect theory's value functions, probability weighting curves, and discounting functions are all computed live from their underlying equations.
Translating theory into code exposed edge cases that are easy to miss on paper, from numerical stability to how sensitive each model is to its parameters, and deepened my understanding of the models themselves.

Model
Structured outputs
Every simulation produces the same output for the same inputs: clear metrics, a readable summary, and a versioned log that can be revisited later. The aim was a platform genuinely useful for teaching and experimentation.
Runs are stored in PostgreSQL alongside the model version that produced them, so results stay reproducible as the platform evolves.

Results
Visual representation
The graphs are drawn directly from each model's mathematical output, so changing a parameter updates the equations and redraws the curves in real time.

Graphs
Architecture and infrastructure
A Next.js frontend on Vercel talks to a FastAPI backend on Railway, with Clerk handling accounts and PostgreSQL storing the simulation logs.
Building this forced me to properly understand CORS policies, token verification, environment configuration, rate limiting, and production debugging.

Learning
What this project represents
Building Behavioural Engines taught me a great deal, from React state and Python to the design decisions that make a platform easier to use, such as a command-K palette and carefully written support pages. It also demanded real thought about versioning, typed interfaces, and how the platform could scale as new models arrive.
Building the models in code also strengthened my understanding of them. Translating prospect theory and hyperbolic discounting into formal, executable structures made their assumptions and constraints much clearer than studying them in theory alone.

Updates
Where it is going
A changelog page tracks every model addition and update, giving the platform a sense of ongoing development. There are currently six models, each of which took genuine thought to implement correctly, and the intention is to keep adding slowly, making sure each one earns its place in the catalogue. Stripe has since been integrated to support subscriptions.
Built with
- TypeScript
- Next.js
- FastAPI
- PostgreSQL
- Railway
- Vercel
- Clerk
- Redis
- Tailwind CSS
- Framer Motion
- Stripe
More projects