GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - tadejow/FlowApp-API: FlowApp PWA - Unique experience of Mandau River

BranchesTags
Open more actions menu

Latest commit

 

History

7 Commits
7 Commits

Folders and files

NameName
Last commit message
Last commit date
.idea
.idea
 
 
.vscode
.vscode
 
 
src
src
 
 
test
test
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.prettierrc
.prettierrc
 
 
README.md
README.md
 
 
important_urls.txt
important_urls.txt
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 
vitest.config.mts
vitest.config.mts
 
 
worker-configuration.d.ts
worker-configuration.d.ts
 
 
wrangler.jsonc
wrangler.jsonc
 
 

Repository files navigation

FlowApp - Backend API

A serverless backend for the FlowApp application, built with Cloudflare Workers and D1 Database.

This repository contains the source code for the API that handles saving game scores and providing data for leaderboards.

🚀 About The Project

This API is the core of the leaderboard system for the FlowApp project. It handles requests from the user interface (GUI), processes them, and communicates with a D1 serverless database (based on SQLite).

Core responsibilities:

  • Accepting game results from players (POST).
  • Returning personalized leaderboards (GET).
  • Handling CORS to allow communication with the frontend, which is hosted on a different domain.

🛠️ Built With

  • Cloudflare Workers: A serverless execution environment.
  • D1 Database: A globally distributed database built on SQLite.
  • Wrangler: The command-line tool for managing Cloudflare developer products.
  • TypeScript: The programming language used for the Worker.

🏁 Getting Started

To manage and develop the API, you need to have the Wrangler CLI installed and configured.

Prerequisites

  • Node.js (v18.x or later)
  • npm
  • Wrangler installed globally:
    npm install -g wrangler
  • A Cloudflare account, logged in via Wrangler:
    wrangler login

Installation

  1. Clone the repository:

    git clone https://github.com/tadejow/FlowApp-API.git
    cd FlowApp-API
  2. Install NPM packages:

    npm install

Local Development

To run a local development server that simulates the Cloudflare environment:

wrangler dev

The Worker will be available at http://localhost:8787.

Note: By default, wrangler dev uses a local, in-memory D1 database. To persist data between sessions, use the --persist flag: wrangler dev --persist.

🚀 Deployment

To deploy the latest version of the Worker to the Cloudflare production environment, run the following command:

wrangler deploy

🗃️ D1 Database Management

All database schema modifications (like adding or removing columns) must be performed using the Wrangler CLI.

Important: Always use the --remote flag to ensure you are modifying the live, production database in the cloud, not the local simulation.

Example: Adding a new column

wrangler d1 execute flowapp-db --remote --command "ALTER TABLE reynolds_challenge ADD COLUMN new_column_name TEXT;"

Example: Deleting a column

wrangler d1 execute flowapp-db --remote --command "ALTER TABLE reynolds_challenge DROP COLUMN old_column_name;"

🌐 API Endpoints

Duck Race

  • GET /api/duck-race: Returns the top 10 scores. Accepts an optional ?playerName=... query parameter to also return the rank of a specific player.
  • POST /api/duck-race: Saves a new score. Expects a JSON body with the following structure: { "player_name": string, "completion_time_ms": number, "language": string }.

Reynolds Challenge

  • GET /api/reynolds-challenge: Returns the top 10 scores (ordered by flow_ratio_avg). Accepts an optional ?playerName=... query parameter.
  • POST /api/reynolds-challenge: Saves a new result. Expects a JSON body with the following structure:
    {
      "player_name": "string",
      "completion_time_ms": "number",
      "peak_velocity": "number",
      "flow_ratio_avg": "number",
      "flow_ratio_3": "number",
      "flow_ratio_4": "number",
      "flow_ratio_5": "number",
      "language": "string"
    }

About

FlowApp PWA - Unique experience of Mandau River

flowapp-forked.pages.dev/

Topics

ecology-modellingeducational-gamefluid-simulationriver-modeling

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

3 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.