Skip to content

Repository files navigation

Tiny Tamagotchi ๐Ÿพ

A virtual pet web app built with Spec-Driven Development โ€” where the specification is the primary artifact, and the code follows.

Live Demo Award License: MIT Preact Vite Vitest Tests Deploy

Built for the DeepLearning.AI 7-Day Learner Challenge (Spec-Driven Development with Coding Agents course).

๐Ÿฅ‰ Awarded 3rd place in the DeepLearning.AI 7-Day Spec-Driven Dev Challenge โ€” try the live demo or watch the walkthrough.

๐ŸŽฎ Live Demo

โ–ถ๏ธ Play it in your browser

๐Ÿ‘‰ https://nickkoro21.github.io/Tiny-Tamagotchi/

No install, no clone โ€” just open the link, name your pet, and start caring. State persists in localStorage across reloads.

๐Ÿ† Recognition

This project earned 3rd place in the DeepLearning.AI 7-Day Spec-Driven Development Challenge (May 2026), with a final score of 6.48 / 7.00. The reviewer feedback called the submission "a standout submission โ€” the precision, structural discipline, and edge-case thinking on display here reflect the habits of an experienced spec writer, not a beginner."

๐ŸŽฅ Video Walkthrough

โ–ถ๏ธ Watch the walkthrough on OneDrive

The video covers:

  • Naming a pet (including an easter-egg name reveal)
  • Real-time vitals decay (Hunger / Happiness / Energy at different rates)
  • The care loop โ€” Feed, Play, Rest โ€” and their cooldowns
  • The state machine: Normal โ†’ Sick recovery, then Normal โ†’ Evolved progression
  • Personality messages cycling, including combo reactions and milestone pops
  • The SDD workflow โ€” specs driving every feature, not the other way around

๐Ÿ“ธ At a glance

Tiny Tamagotchi โ€” Normal state

The main game view: Hunger / Happiness / Energy bars with live decay, care action buttons, and a cycling personality message above the blob.

๐Ÿ–ฅ Run it yourself

Local setup in Setup below โ€” npm install && npm run dev โ†’ http://localhost:5173.

โœจ Features โ€” The Four Pillars

1. Living Vitals

Three stats (Hunger, Happiness, Energy) on a 0โ€“100 scale that decay automatically in real time at different rates โ€” Hunger fastest (~30 s), Happiness mid (~35 s), Energy slowest (~45 s). Visual color feedback shifts from healthy โ†’ warning โ†’ low โ†’ critical as stats drop.

Warning state โ€” one stat below 70

Stat bars shift color as values cross thresholds โ€” here one stat has dropped into the warning band.

2. The Care Loop

Three actions โ€” Feed (+30 hunger / +5 happiness), Play (+25 happiness / โˆ’10 energy), Rest (+35 energy / +5 happiness) โ€” each with its own cooldown (3โ€“5 s). Pet naming on first launch. State persists via localStorage with JSON export/import backup.

3. Dynamic States

The pet transitions between three visual states with distinct decay modifiers:

State Trigger Decay Visual
Normal Default healthy state ร—1.0 Cyan glow, smooth idle animation
Sick Any stat drops below 20 ร—1.5 Red glitch effect, distorted shape
Evolved 6+ care actions AND all stats > 70 for 15 s ร—0.7 Purple glow, shimmer particles, bright eyes

Evolved pets can regress to Sick if neglected โ€” there's no direct Evolved โ†’ Normal path. After recovering from Sick, evolution must be re-earned.

Sick state โ€” red glitch, distorted shape

The Sick state โ€” red danger tint, glitch animation, and accelerated decay.

Evolved state โ€” purple glow, shimmer

The Evolved state โ€” purple glow, shimmer particles, and slower decay as the reward for sustained care.

4. Personal Touches

  • Tech-themed personality messages cycling every 5 seconds, priority-ranked (milestones > state > combos > low-stat warnings > rare > ambient)
  • Context-aware reactions for stat combinations (e.g., Hungry + Tired, Full but Sad, All Critical = MAYDAY)
  • 11 easter-egg names across three themes (case-insensitive):
    • Sci-fi (4): HAL, Jarvis, Cortana, R2D2
    • Aviation (4): Maverick, Goose, Iceman, Viper
    • Personal (3): Nick, Koro, Nick Koro
  • Milestone celebrations at 10, 25, 50, and 100 care actions (each shown once)
  • Rare random messages (5% chance when all stats > 50)

Easter-egg reaction for a known name

Name your pet Nick Koro, Maverick, HAL, or any of the 11 recognised names for a themed greeting.

๐Ÿ› ๏ธ Tech Stack

Layer Technology Rationale
UI Framework Preact ^10.x 3 KB runtime, React-compatible API โ€” lightweight for an MVP
Build Tool Vite ^6.x Instant dev server, zero-config HMR, fast builds
Styling Vanilla CSS (custom properties) No framework lock-in, full theme control via CSS variables
Testing Vitest ^3.x Native Vite integration, Jest-compatible API, first-class ESM
Language JavaScript (ES2022+, JSX) No transpile cost beyond Vite; modern syntax without a type-checker in the loop
Persistence localStorage + JSON export/import Client-only โ€” no backend needed for a single-user MVP

Why this stack? Each choice was made to minimize MVP complexity while keeping the door open for later upgrades (e.g., swapping Preact for React, or localStorage for IndexedDB). Nothing here blocks scale; everything here accelerates shipping.

๐Ÿ“‚ Project Structure

TinyTamagotchi/
โ”œโ”€โ”€ specs/                          # SDD Constitution
โ”‚   โ”œโ”€โ”€ mission.md                  #   Vision, audience, scope
โ”‚   โ”œโ”€โ”€ tech-stack.md               #   Architecture decisions
โ”‚   โ””โ”€โ”€ roadmap.md                  #   Development phases
โ”œโ”€โ”€ feature-01-living-vitals/       # Feature specs (per phase) โ€” same 3-file SDD structure
โ”‚   โ”œโ”€โ”€ feature-plan.md             #     Task groups, approach, sequence
โ”‚   โ”œโ”€โ”€ requirements.md             #     Functional + non-functional reqs
โ”‚   โ””โ”€โ”€ validation.md               #     Unit tests + manual checklist
โ”œโ”€โ”€ feature-02-care-loop/
โ”‚   โ”œโ”€โ”€ feature-plan.md
โ”‚   โ”œโ”€โ”€ requirements.md
โ”‚   โ””โ”€โ”€ validation.md
โ”œโ”€โ”€ feature-03-dynamic-states/
โ”‚   โ”œโ”€โ”€ feature-plan.md
โ”‚   โ”œโ”€โ”€ requirements.md
โ”‚   โ””โ”€โ”€ validation.md
โ”œโ”€โ”€ feature-04-personal-touches/
โ”‚   โ”œโ”€โ”€ feature-plan.md
โ”‚   โ”œโ”€โ”€ requirements.md
โ”‚   โ””โ”€โ”€ validation.md
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ engine/                     # Pure game logic (no UI)
โ”‚   โ”‚   โ”œโ”€โ”€ gameState.js            #     State shape + factory
โ”‚   โ”‚   โ”œโ”€โ”€ vitals.js               #     Decay + actions + clamps
โ”‚   โ”‚   โ”œโ”€โ”€ states.js               #     Normal/Sick/Evolved state machine
โ”‚   โ”‚   โ””โ”€โ”€ personality.js          #     Messages, easter eggs, milestones
โ”‚   โ”œโ”€โ”€ components/                 # Preact UI components
โ”‚   โ”œโ”€โ”€ persistence/                # Save/load (localStorage + JSON)
โ”‚   โ””โ”€โ”€ styles/                     # CSS (dark sci-fi theme)
โ”œโ”€โ”€ tests/                          # Vitest unit tests
โ””โ”€โ”€ package.json

๐Ÿš€ Setup

# Clone the repo
git clone https://github.com/Nickkoro21/Tiny-Tamagotchi.git
cd Tiny-Tamagotchi

# Install dependencies
npm install

# Start dev server
npm run dev
# โ†’ Open http://localhost:5173

# Run tests
npm run test

๐Ÿ“ SDD Workflow

This project follows the Spec-Driven Development workflow:

  1. Constitution โ€” Define mission, tech stack, and roadmap
  2. Feature Loop (per feature):
    • Plan โ†’ feature-plan.md
    • Requirements โ†’ requirements.md
    • Validation โ†’ validation.md
    • Implement โ†’ write code following specs
    • Validate โ†’ run tests, manual checks
  3. Replan โ€” review and update between features

The specs are the primary artifact โ€” they capture every decision and drive the implementation.

๐Ÿ“Š Spec Quality

Snapshot of the spec-driven output at submission time:

Metric Value
Constitution docs 3 (mission, tech-stack, roadmap)
Feature specs 12 (4 features ร— plan / requirements / validation)
Total spec files 15
Unit tests 129 (6 suites: vitals, actions, states, personality, persistence, gameState)
Engine modules 4 (gameState, vitals, states, personality)
Testing levels 2 (automated Vitest + manual validation checklists per feature)
Easter-egg names 11 (across sci-fi / aviation / personal themes)
Milestones 4 (10 / 25 / 50 / 100 care actions)
Dynamic states 3 (Normal / Sick / Evolved) with distinct decay multipliers

๐Ÿงช Testing & Quality Evidence

  • Unit tests: 129 tests across 6 suites โ€” covering vitals decay, care actions, state transitions, personality messages, easter eggs, milestones, and persistence
  • Manual validation: Checklists in each feature's validation.md (message variety, state transitions, easter eggs, responsive layout, persistence round-trips)
  • Two levels of difficulty: Automated (Vitest) + manual (visual / interaction checks)
npm run test

npm test โ€” 129/129 passing

All 129 tests green โ€” evidence that the validation strategies in each validation.md are executable and passing.

npm run build โ€” clean production build

Clean production build โ€” no errors, no warnings.

๐Ÿ“‹ Challenge Submission

  • Challenge: DeepLearning.AI 7-Day Learner Challenge
  • Course: Spec-Driven Development with Coding Agents
  • Deadline: April 22, 2026 โ€” 11:59 PM PST

๐Ÿ™ Contributors & Acknowledgments


Author

Nikolaos Koroniadis

LinkedIn GitHub

MSc Candidate โ€” Geography and Applied Geoinformatics
University of the Aegean

๐Ÿ“„ License

MIT โ€” see LICENSE.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages