Skip to content

abeltheo/jar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Jar — realtime coin jar

This repository contains a minimal WebSocket server and a SwiftUI iOS app that lets users add coins to a jar. When a user taps the jar, the global coin count is updated on the server and broadcast to all connected clients in real-time.

Contents

  • server/ — Node.js WebSocket server and a static test client (index.html).
  • ios/JarApp/ — SwiftUI app source files (drop into Xcode project).

Quick start (server)

  1. Open a terminal and navigate to server/.
cd server
npm install
npm start
  1. Open http://localhost:8080 in multiple browser tabs to test live sync.

Topic support

  • When adding a coin you can optionally include a short topic description. The server records topics and counts how many times each was added.
  • As you type a topic in the browser test client it will request suggestions from the server based on past recorded topics (fuzzy matching). You can pick a suggested topic to reuse it.
  • The server persists topics to server/state.json so counts survive restarts.

Testing on iOS device or simulator

  • The SwiftUI app connects to ws://localhost:8080 by default. If running on a device, replace localhost with your machine's LAN IP. You can do this by setting the environment variable JAR_SERVER_URL in the scheme's Run > Environment Variables, e.g. ws://192.168.1.5:8080.
  • Open the ios/JarApp folder in Xcode and create a new SwiftUI app project, then add JarApp.swift, ContentView.swift, and NetworkManager.swift into the project.

Notes & next steps

  • Add an image asset named jar and replace the placeholder with Image("jar") in ContentView for a nicer UI.
  • Consider adding persistent storage on the server (file or database) if you want state to survive restarts.
  • For production, secure WebSocket (wss://) and authentication will be required.

How to test the topic flow

  1. Start the server (npm start) and open http://localhost:8080 in two browser tabs.
  2. In one tab, type a topic (for example "budget", "vacation plan") and click Add 1 — that topic will be recorded.
  3. In other tabs, try typing a similar topic and you'll see server-suggested matches; selecting one will reuse the recorded topic and increment its count.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published