Skip to content

eternitybro/mathler

Repository files navigation

Mathler

Mathler is a mathematical puzzle game inspired by Wordle built in NextJS. Players attempt to guess a hidden mathematical equation that equals a given target number within a limited number of tries.

Features

  • Daily unique mathematical puzzles (can forceRefresh if needed)
  • Server-side puzzle generation and validation
  • Client-side game logic with React
  • Prisma ORM with SQLite database for puzzle storage
  • Zod for runtime type checking and validation

Getting Started

Prerequisites

  • Node.js (v14 or later)
  • npm / pnpm / yarn / bun (pick your poison)

Installation

  1. Clone the repository:

    git clone https://github.com/eternitybro/mathler.git
    cd mathler
    
  2. Install dependencies:

    npm install
    
  3. Set up the database:

    npx prisma generate
    npx prisma db push
    
  4. Start the development server:

    npm run dev
    
  5. To run tests:

    npm run test
    
  6. Open http://localhost:3001 in your browser to play the game.

  7. Use the api for validation or your own game generation http://localhost:3001/api/daily?forceRefresh=true ... using forceRefresh will clear the daily problem.

Project Structure

  • /app: Next.js app router files
  • /components: React components
  • /integrations: Integration logic (e.g., puzzle generation, API routes)
  • /prisma: Prisma schema and migrations
  • /types: TypeScript type definitions
  • /utils: Utility functions (e.g., validation)

API

The game uses a simple API to fetch daily puzzles:

  • GET /api/daily: Retrieves the daily puzzle

Technologies Used

  • Next.js - React framework for server-side rendering and static site generation
  • React - JavaScript library for building user interfaces
  • Prisma - Next-generation ORM for Node.js and TypeScript
  • Zod - TypeScript-first schema declaration and validation library
  • Shadcn UI - Re-usable components built with Radix UI and Tailwind CSS
  • Tailwind CSS - Utility-first CSS framework
  • TypeScript - Typed superset of JavaScript

Acknowledgments

License

This project is licensed under the MIT License.