Skip to content
/ fakeworld Public

RealWorld implementation with a twist (work in progress)

Notifications You must be signed in to change notification settings

adql/fakeworld

Repository files navigation

FakeWorld

FakeWorld is a wip full-stack implementation of the RealWorld demo Medium.com clone, but with a twist: the "front-end" is instead a TUI mock-up!

Here it is running on RealWorld's demo API:

FakeWorld animated screenshot

It shows the main page and an article (the problem with newlines showing as \n is on the demo API's side). See below for development status information.

Why?

  • Because I can
  • Because Haskell is fun
  • Because it's a great learning opportunity

How?

The project utilizes the following technologies and libraries:

  • brick for creating the TUI and managing everything on the front-end
  • Servant for generating, serving (via wai) and requesting the API
  • PostgreSQL as database, using Hasql on the Haskell side
  • Aeson for all JSON heavy-lifting
  • optparse-applicative for command line parsing

Status

In the first stage only content that doesn't require authentication is implemented. The following list is thus limited.

  • "Front-end"

    • Basic layout with header, footer, banner
    • Home page with article list and popular tags
    • Article page (almost complete; needs some small refinements)
      • Comment section
    • Profile page
    • Sign up / log in pages
  • Back-end

    • API endpoints and responses
    • Database
      • Articles table
      • Profiles table
      • Comments table
    • Database queries
      • Get a list of articles
      • Get an article / its comments by slug
      • Get a profile by username
      • Get all tags

Running

Haskell development environment needs to be installed. The common and simple way is using GHCup (installation instructions). FakeWorld uses Cabal.

After having installed GHCup install the necessary toolchain:

ghcup install ghc
ghcup install cabal latest

Just the TUI frontend

Use cabal and pass the -e (i.e. --external) argument to run the TUI frontend on the demo backend, set by default to https://api.realworld.io:443:

cabal run fakeworld -- -e

Make sure you're on a normal terminal! Running from within e.g. Emacs will not work.

Full-Stack

These instructions are for Linux. Most of the code in the Makefile is trivial and should be easily adaptable to MacOS and (maybe not quite easily) to Windows.

The PostgreSQL database is run on a Docker container, so make sure you have Docker installed in your path.

Important: You must provide a password to the Postgres database with the DB_PASSWORD environment variable using a .env file. Otherwise the scripts in the Makefile fail.

initiate the database with some dummy data:

make populate-db

This will start a Docker container for the database (with a persistent volume named fakeworld-postgres), create tables and populate them with some Lorem Ipsums. You can then run the app full-stack from a terminal with

make run

About

RealWorld implementation with a twist (work in progress)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published