This repo contains the full source code for the Point-Free website, a video series exploring Swift and functional programming. The codebase is split into 3 pieces:
PointFree: This is the core application, and is responsible for routing requests, loading data and rendering HTML and CSS.
Styleguide: This library contains functions and data types for creating a consistent style across the entire website.
Server: This is the actual executable server. It uses Kitura to handle the low level server responsibilities, and hands everything else over to the
The repo contains an extensive test suite and some playgrounds to explore. To get things running:
Make sure Xcode is installed!
cmarkis installed. You can install it with Homebrew:
brew install cmark # or your preferred installation method
Make sure Postgres is installed and running. It's our database of choice. You can install it with Homebrew:
brew install postgres # or your preferred installation method
Open up a terminal window and grab the code:
git clone https://github.com/pointfreeco/pointfreeco.git cd pointfreeco
Bootstrap! If you want us to take care of the details for you, we need to install a few module maps in your SDK path to make CommonCrypto, WebKit's WKSnapshotConfiguration, and Postgres headers available to our libraries, playgrounds, and tests. We also need to set up a
pointfreecouser and database in Postgres. You can read our Makefile for more info, and run:
With everything bootstrapped and the project open in Xcode, you can:
- Build: Command+B
- Run the site locally:
- Run Command+R
- Run tests: Command+U
- Open a playground! Requires building
Some fun things to explore
There're a lot of fun things to explore in this repo. For example:
We develop web pages in playgrounds for a continuous feedback loop. This is made possible by the fact that the entire server stack is composed of pure functions with side-effects pushed to the boundaries of the application. It allows us to load up any request in isolation, including
POSTrequests, all without ever worrying about doing a side-effect.
We use snapshot testing to capture full data structures in order to verify their correctness. Not only do we do this in the traditional way of taking screenshots of web pages at various break points (e.g. on iPhone and desktop), but we can also snapshot any entire request-to-response lifecycle (e.g. the
POSTto a signup page does the correct redirect).
▿ Step ResponseEnded ▿ Request POST http://localhost:8080/launch-signup email@example.com ▿ Response Status 302 FOUND Location: /?success=true
Xcode Color Theme
Like the color theme we use in our episodes? Run
make colortheme to install locally!
Point-Free uses a bunch of interesting open-source software:
- swift-web: A collection of types and functions for dealing with common web server concerns, such as HTML render, CSS preprocessing, middleware and more.
- swift-prelude: Offers a standard library for experimental functional programming in Swift.
- swift-snapshot-testing: Powers our testing infrastructure by taking snapshots of various data structures to guarantee the correctness of their output. We use this on everything from middleware to ensure requests are correctly transformed into responses, and even entire web pages to make sure the site looks correct at a variety of sizes (e.g. on iPhone and desktop).
Explore more of our open-source on the Point-Free organization.
Brandon gave a talk about most of the core ideas that went into this project at Swift Summit 2017.
Find this interesting?
Then check out Point-Free!