# The most basic of POS systems written in ELM

**URL:** <https://discourse.elm-lang.org/t/the-most-basic-of-pos-systems-written-in-elm/3637>\
**Category:** Request Feedback\
**Created:** [May 13, 2019, 9:40am UTC](https://discourse.elm-lang.org/t/the-most-basic-of-pos-systems-written-in-elm/3637 "2019-05-13T09:40:39Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![dnk8n](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dnk8n/32/2131_2.png) [@dnk8n](https://discourse.elm-lang.org/u/dnk8n)\
**Post date:** [May 13, 2019, 9:40am UTC](https://discourse.elm-lang.org/t/the-most-basic-of-pos-systems-written-in-elm/3637/1 "2019-05-13T09:40:39Z")

</div>

I want to learn ELM (not started yet) while simultaneously producing something of value in the form of an open-source project. I plan to read this [korban.net elm book](https://korban.net/elm/book/) in parallel to a simple project.

A local coffee shop has asked for a very basic POS. They literally need their 2-3 waiters/waitresses to tap on ordered items on their phones / ipads and it would generate an order.

This project, [EpPos](https://github.com/Epse/EpPos), is good enough and is what I have installed to start with.

One behavioural attribute I am contemplating changing is, it requires a central API running on the local server to do the calculations. It is a solid approach but requires an always on box in a cupboard and if that goes down, so does the system.

I was thinking about whether it is possible to have the entire system running locally in a web app.

The way I am thinking, 2 or 3 devices with my POS web app installed called interact to manage the current value of the till register. All calculations would be complete on the device (simple additions and subtractions).

I think this kind of distributed system would be nice but would interfere with my learning. For starters I am going to keep to a Django REST API as a centralised backend because I know it (later I would like to learn more about whether GraphQL could solve some problems I might have with REST) and I could inherit from the EpPos project linked to above, except write an Elm frontend for it.

Do you think this is a good tinkering project to do in Elm?

Any feedback and discussion about the potential pitfalls in my idea are very much welcome. I am not married to any ideas.

---

<div class="post-metadata">

**Author:** ![razze](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/razze/32/1650_2.png) [@razze](https://discourse.elm-lang.org/u/razze)\
**Post date:** [May 13, 2019, 1:53pm UTC](https://discourse.elm-lang.org/t/the-most-basic-of-pos-systems-written-in-elm/3637/2 "2019-05-13T13:53:54Z")

</div>

Sounds good to me, maybe also do the frontend with [https://package.elm-lang.org/packages/mdgriffith/elm-ui/latest/](https://package.elm-lang.org/packages/mdgriffith/elm-ui/latest/) to keep everything in the elm world?

---

<div class="post-metadata">

**Author:** ![cttet](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/cttet/32/1757_2.png) [@cttet](https://discourse.elm-lang.org/u/cttet)\
**Post date:** [May 14, 2019, 3:11am UTC](https://discourse.elm-lang.org/t/the-most-basic-of-pos-systems-written-in-elm/3637/3 "2019-05-14T03:11:18Z")

</div>

Are you familiar with Javascript? If yes, then Elm is good for you. If no, prepare to learn both Javascript and Elm at the same time.

---

<div class="post-metadata">

**Author:** ![dnk8n](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dnk8n/32/2131_2.png) [@dnk8n](https://discourse.elm-lang.org/u/dnk8n)\
**Post date:** [May 14, 2019, 3:58am UTC](https://discourse.elm-lang.org/t/the-most-basic-of-pos-systems-written-in-elm/3637/4 "2019-05-14T03:58:05Z")

</div>

No, I am not familiar with Javascript yet. I am happy to learn it though (is there any front-end language that does not require learning Javascript!!?). More of a Python programmer but I also know a bit of Julia and MATLAB/Octave.

---

<div class="post-metadata">

**Author:** ![perty](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/perty/32/4459_2.png) [@perty](https://discourse.elm-lang.org/u/perty)\
**Post date:** [May 14, 2019, 5:56am UTC](https://discourse.elm-lang.org/t/the-most-basic-of-pos-systems-written-in-elm/3637/5 "2019-05-14T05:56:52Z")

</div>

I disagree. You don’t need to learn JavaScript at the same time. I am working in Elm and I do not use JavaScript, neither HTML or CSS, apart for a few small exceptions. I am betting my startup on Elm so it is a full-time job.

Elm is THE language for going into front-end programming when you are leaving server-side rendering behind. To me, the type-safeness and immutable, centralised model, has been the major helpers in writing robust and bug-free code.

Of course you could store the order locally on the device and send it over to the central server when available. I believe that is the idea of a service-worker but this is nothing I know about, although I’d really like to know.

---

<div class="post-metadata">

**Author:** ![jjw](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@jjw](https://discourse.elm-lang.org/u/jjw)\
**Post date:** [May 14, 2019, 12:10pm UTC](https://discourse.elm-lang.org/t/the-most-basic-of-pos-systems-written-in-elm/3637/6 "2019-05-14T12:10:09Z")

</div>

If by “till register” you mean the live finances of the shop you will most definitely have to ensure all transactions are ACID so that outages or race conditions don’t leave the money in an inconsistent state. Elm’s excellent advice to have only “one source of truth” also applies to multiple parallel apps on different devices: another reason to leave the till calculations on the server.  
Alternatively you could explore using something like a blockchain to maintain multiple parallel truths that eventually become the same truth?

---

<div class="post-metadata">

**Author:** ![cttet](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/cttet/32/1757_2.png) [@cttet](https://discourse.elm-lang.org/u/cttet)\
**Post date:** [May 14, 2019, 1:48pm UTC](https://discourse.elm-lang.org/t/the-most-basic-of-pos-systems-written-in-elm/3637/7 "2019-05-14T13:48:58Z")

</div>

I disagree with perty’s view that Javascript is not required for Elm. I came to Elm also from Python background and found Javascript quite necessary for building something practical and the use cases are usually hidden until you need them. You can find some of the examples that require JS here: [What are you using ports for in 0.19?](https://discourse.elm-lang.org/t/what-are-you-using-ports-for-in-0-19/2293/7) . (Note that file uploads are recently made possible without Javascript)

This is a repo of some examples of Elm-JS interop: [https://github.com/MattCheely/elm-port-examples](https://github.com/MattCheely/elm-port-examples) . It may help if you want to see what the code would be like or need some similar functionality.

But I agree with perty that you can get rid of HTML and CSS entirely by using Elm (especially with Elm-UI package [https://package.elm-lang.org/packages/mdgriffith/elm-ui/latest/](https://package.elm-lang.org/packages/mdgriffith/elm-ui/latest/)).

---

<div class="post-metadata">

**Author:** ![dnk8n](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dnk8n/32/2131_2.png) [@dnk8n](https://discourse.elm-lang.org/u/dnk8n)\
**Post date:** [May 14, 2019, 3:08pm UTC](https://discourse.elm-lang.org/t/the-most-basic-of-pos-systems-written-in-elm/3637/8 "2019-05-14T15:08:05Z")

</div>

Yeah, I was thinking along lines of local blockchain. But that is quite ambitious. I will complete a centralised server implemention first before I attempt a decentralized one.

---

<div class="post-metadata">

**Author:** ![Herteby](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/herteby/32/1329_2.png) [@Herteby](https://discourse.elm-lang.org/u/Herteby)\
**Post date:** [May 15, 2019, 9:46am UTC](https://discourse.elm-lang.org/t/the-most-basic-of-pos-systems-written-in-elm/3637/9 "2019-05-15T09:46:17Z")

</div>

> [@dnk8n](#):
>
> The way I am thinking, 2 or 3 devices with my POS web app installed called interact to manage the current value of the till register. All calculations would be complete on the device (simple additions and subtractions).

So you’d do peer-to-peer networking using WebRTC? That’ll definitely require JS, and seems pretty complicated. There’s also no real safe way to store data in a browser (that survives “clearing cookies”).

I think the simplest option when you don’t want to worry about the backend is probably a BaaS like Firebase. With Firebase you can get realtime messaging too, though you’ll have to install the Firebase JS client and connect it to Elm with ports.

---

<div class="post-metadata">

**Author:** ![dnk8n](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dnk8n/32/2131_2.png) [@dnk8n](https://discourse.elm-lang.org/u/dnk8n)\
**Post date:** [May 15, 2019, 9:59am UTC](https://discourse.elm-lang.org/t/the-most-basic-of-pos-systems-written-in-elm/3637/10 "2019-05-15T09:59:28Z")

</div>

I would definitely not want it online though. Internet can be flaky out where I live (rural South Africa, place called Kosi Bay)

Looks like a local backend server is the obvious choice for simplicity!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [May 25, 2019, 9:59am UTC](https://discourse.elm-lang.org/t/the-most-basic-of-pos-systems-written-in-elm/3637/11 "2019-05-25T09:59:28Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
