{"id":18857467,"url":"https://github.com/johnnycrazy/battleskell","last_synced_at":"2026-02-07T04:30:17.798Z","repository":{"id":76775363,"uuid":"286803144","full_name":"JohnnyCrazy/battleskell","owner":"JohnnyCrazy","description":"A online real-time battleship game, based on haskell and vuejs","archived":false,"fork":false,"pushed_at":"2020-09-13T20:25:22.000Z","size":151,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-30T19:34:49.288Z","etag":null,"topics":["haskell","vuejs-frontend","websocket","yesod"],"latest_commit_sha":null,"homepage":"https://battleskell.dellinger.dev/","language":"Haskell","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JohnnyCrazy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-11T17:10:49.000Z","updated_at":"2022-06-14T12:15:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"ac25e269-c681-48cd-bc0f-6c973ad161fd","html_url":"https://github.com/JohnnyCrazy/battleskell","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnnyCrazy%2Fbattleskell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnnyCrazy%2Fbattleskell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnnyCrazy%2Fbattleskell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnnyCrazy%2Fbattleskell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JohnnyCrazy","download_url":"https://codeload.github.com/JohnnyCrazy/battleskell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239798956,"owners_count":19698963,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["haskell","vuejs-frontend","websocket","yesod"],"created_at":"2024-11-08T04:06:30.829Z","updated_at":"2026-02-07T04:30:17.738Z","avatar_url":"https://github.com/JohnnyCrazy.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Battleskell\n\n**[DEMO](https://battleskell.dellinger.dev/)**\n\n\u003e An online real-time battleship game written in Haskell, with a bit of VueJS for the dynamic frontend part. It was written for the advanced functional programming module @LMU Munich, in the summer term 2020.\n\n![Ingame](.img/ingame.png)\n\n![Home](.img/home.png)\n\n![Setup](.img/setup.png)\n\n![Finished](.img/finished.png)\n\n## Features\n\n- User System (No E-Mail support)\n- Realtime Game Logic\n- Realtime Lobby Matchmaking\n- Leaderboard based on Elo \u0026 Game Count\n- Persistent via PostgreSQL\n- VueJS Frontend (JS Modules)\n- Mobile friendly via TailwindCSS grid\n\n## Running It\n\n### Requirements\n\n- Stack\n- Docker or local PostgreSQL\n- `libpq-dev` or similar for compiling the postgresql driver\n\n### Build \u0026 Run\n\n```sh\n# run a local postgresql via docker, you can skip this if you have system wide postgresql installation\n# note, on container stop the database is not persisted\ndocker run -d --rm --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres:12-alpine\n# create the database battleskell\ndocker exec postgres createdb -U postgres battleskell\n\nstack build\n# This will also run migrations\nstack run\n```\n\n## Architecture\n\nAt its heart, the project is a yesod application with postgres as backend. Some parts of the application, like the login, registration and home are statically rendered by yesod using the hamlet templating engine. Other highly dynamic parts, like the lobby and ingame parts are rendered on the client using the frontend framework VueJS. These dynamic pages first load their state using XHR requests, to which yesod answers with JSON payloads. Then, a websocket connection takes care of keeping the client up-to-date. E.g in the lobby screen, the websocket connection adds new and removes old lobbies automically from the list. Thus, the user has realtime experience without having to refresh the page.\n\n### Yesod Backend\n\nThe yesod backend uses different libraries to support the user-system, websockets and more complicated SQL queries. To list a few:\n\n- **yesod-auth-hashdb**:\n  \u003e It provides authentication using hashed passwords stored in a database, and works best in situations where an administrator is involved in setting up a user with an initial password.\n- **yesod-websockets**:\n  \u003e Websockets support for yesod, using normal handler functions as entry point. Allows to send and receive in a bidirectional manner with clients.\n- **esqueleto**:\n  \u003e Advanced SQL Library, allowing fully typed JOIN operations.\n- **lens**\n  \u003e This package comes \"Batteries Included\" with many useful lenses for the types commonly used from the Haskell Platform, and with tools for automatically generating lenses and isomorphisms for user-supplied data types.\n  \u003e\n  \u003e Used to filter and updated deeply nested data structures easily\n\nSome of the utilized haskell principles:\n\n- Monads\n- Class and Instances\n- Lenses\n- Parallel \u0026 Concurrent\n- Records\n- Higher-order functions\n- Vectors\n\n### VueJS Frontend\n\nThe VueJS frontend was written via JS modules. This rather modern technique allowed to split frontend logic across seperate files, while not depending on a global `window` namespace. The VueJS templates were written in hamlet files via `text/x-template` scripts, which was quite a nice combiniation due to hamlets concise syntax:\n\n```html\n\u003cscript type=\"text/x-template\"\u003e\n  \u003cdiv .w-full\u003e\n    {{ message }}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnnycrazy%2Fbattleskell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnnycrazy%2Fbattleskell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnnycrazy%2Fbattleskell/lists"}