{"id":18319262,"url":"https://github.com/holmusk/three-layer","last_synced_at":"2025-04-07T17:08:43.953Z","repository":{"id":53113664,"uuid":"131030241","full_name":"Holmusk/three-layer","owner":"Holmusk","description":":three: :cake: Architecture of the Haskell web applications","archived":false,"fork":false,"pushed_at":"2021-04-06T05:52:01.000Z","size":333,"stargazers_count":310,"open_issues_count":9,"forks_count":26,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-03-31T14:13:50.557Z","etag":null,"topics":["backend","haskell","servant","three-layer-architecture","web","web-application"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Holmusk.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-25T15:53:38.000Z","updated_at":"2024-12-13T06:22:34.000Z","dependencies_parsed_at":"2022-09-13T16:51:34.724Z","dependency_job_id":null,"html_url":"https://github.com/Holmusk/three-layer","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/Holmusk%2Fthree-layer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Holmusk%2Fthree-layer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Holmusk%2Fthree-layer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Holmusk%2Fthree-layer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Holmusk","download_url":"https://codeload.github.com/Holmusk/three-layer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247694876,"owners_count":20980733,"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":["backend","haskell","servant","three-layer-architecture","web","web-application"],"created_at":"2024-11-05T18:12:52.611Z","updated_at":"2025-04-07T17:08:43.902Z","avatar_url":"https://github.com/Holmusk.png","language":"Haskell","readme":"![Logo](https://holmusk.dev/images/projects/three_layer.png)\n[![CircleCI](https://circleci.com/gh/Holmusk/three-layer.svg?style=svg)](https://circleci.com/gh/Holmusk/three-layer)\n\n# three-layer\n\nThis package is aimed at being a modern, production-level, batteries-included starting template for\nwriting web servers with Haskell on backend and Elm on frontend. It follows the\n[Three Layer Cake](http://www.parsonsmatt.org/2018/03/22/three_layer_haskell_cake.html).\narchitecture pattern.\n\nHaskell libraries used in here:\n* [`relude`](https://github.com/kowainik/relude): alternative prelude; here\n  `base-noprelude` trick is used.\n* [`co-log`](https://github.com/kowainik/co-log):\n  [composable contravariant comonadic logging library](https://kowainik.github.io/posts/2018-09-25-co-log).\n* [`postgresql-simple`](http://hackage.haskell.org/package/postgresql-simple):\n  mid-level PostgreSQL client library for database interaction.\n* [`servant`](http://hackage.haskell.org/package/servant): family of libraries\n  for defining webservices Rest API on type-level.\n* [`elm-street`](https://github.com/Holmusk/elm-street): bridge between Elm and\n  Haskell - generating Elm data types, JSON encoders and decoders automatically\n  from Haskell types.\n* [`proto-lens`](http://hackage.haskell.org/package/proto-lens): Protobuf\n  messages for integration with the mobile application.\n* [`ekg`](http://hackage.haskell.org/package/ekg): application performance monitoring.\n* [`bcrypt`](http://hackage.haskell.org/package/bcrypt): password hashing functions.\n* [`jwt`](http://hackage.haskell.org/package/jwt): user authentication via JWT.\n* [`hspec`](http://hackage.haskell.org/package/hspec) and [`hedgehog`](http://hackage.haskell.org/package/hedgehog): testing libraries.\n\n## Detailed approach description\n\nThis section contains more detailed description of the chosen architecture and\nour particular implementation of it.\n\n### Application environment\n\nData type for the runtime environment for the whole application is defined in\nthe [`Lib/App/Env.hs`](src/Lib/App/Env.hs) module. It contains various fields\nrequired for the application processing, like database pool, JWT secret, logger,\netc. It also has instance of custom `Has` typeclass which tells how to extract\ndifferent parts of the application. This is done to achieve the following purposes:\n\n1. Specify in the constraints what parts of the environment you need.\n2. Introduce more modularity when multiple different environments are implemented.\n\nEnvironment initialisation is happening in the [`Lib.hs`](src/Lib.hs) module.\n\n### Application errors\n\nModule [`Lib/App/Error.hs`](src/Lib/App/Error.hs) contains exhaustive list of\nall errors that application can throw. This module provides convenient layer\nbetween human-readable error names and HTTP error codes. It also contains useful\nutilities for throwing errors and for formatting `CallStack` of errors.\n\n### Application monad\n\nMain application monad can be found in the\n[`Lib/App/Monad.hs`](src/Lib/App/Monad.hs) module.\n\n### Database\n\nThis template uses PostgreSQL database and contains helper wrappers around\nfunctions from the `postgresql-simple` library to integrate smoother with our\nown monad. See [`Lib/Db/Functions.hs`](src/Lib/Db/Functions.hs) for more details.\n\n### Effects\n\nAll new effects (like sending an email. storing the file, etc.) should be added\nto the [`Lib/Effects/`](src/Lib/Effects) directory.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fholmusk%2Fthree-layer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fholmusk%2Fthree-layer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fholmusk%2Fthree-layer/lists"}