SwiftLeeds is a truly unique conference built by the community for the community. Started in 2021, we're now working towards our third year. SwiftLeeds is hosted in the heart of Leeds, a beautiful city in the northern English county of Yorkshire.
The website, which is of course built in Swift using Vapor, is split into three key components:
- The frontend which provides the community with information about the event, as well as the capability to buy tickets.
- The API which powers our open-source iOS application.
- The admin page which enables priviledged users to update the event details.
As a community conference, we welcome contributions from anybody: from veteran developers to those just getting started. We're here to help, so feel free to jump into the #swiftleeds-web channel on our Slack, or raise a GitHub Issue if you need a hand.
Equally, feel free to open a new pull request and we can discuss together how to take your ideas forward.
To get started, follow along with these step by step instructions to get your local development environment setup and ready to run the SwiftLeeds website.
For now, we'll focus on your local environment which is slightly different to how the application is deployed in production but allows us to quickly build and test our changes. For advanced users, you can utilise our Dockerfile.
SwiftLeeds relies on a few tools before we can get started!
- Xcode (Xcode 15.4 using Swift 5.10)
- Postgres - our chosen database, used to persist data.
- Optional: Vapor
Once you have these dependencies installed and setup (following the instructions in each of the links above), you're ready to get continue!
Start by double-clicking the Package.swift
file in the root of the repository. This will open the project in Xcode.
It'll take a few moments for Xcode to download our code dependencies, especially on first open as Xcode is unlikely to have cached versions of these ready to use. You don't need to do anything while it fetches these.
We're going to start by creating a new Postgres database for the SwiftLeeds application. Open Terminal and run the following commands:
$ psql postgres -U postgres
This will enter an interactive shell session which allows us to issue commands directly to Postgres.
postgres=# CREATE DATABASE swiftleeds;
postgres=# CREATE USER dev WITH ENCRYPTED PASSWORD 'root';
postgres=# GRANT ALL PRIVILEGES ON DATABASE swiftleeds TO dev;
postgres=# \q
In order, these commands will create a new database called 'swiftleeds', create a user called 'dev' with the password 'root' and then provide that user will access to the database. The \q
command simply quits the interactive session as we're all done there!
You are welcome to provide your own database name, username and password - modifying the commands above as necessary.
Once those commands have been executed, your database is now setup! 🚀
Vapor, along with many server frameworks, uses 'dot env' files to store environment variables for our application to use at runtime. You'll see that we have a file called .env.development
- these are variables which our local environment is able to use.
By default, you do not need to make any changes to this file! However, if you provided your own database name, username or password in the previous step then you will need to change the DATABASE_URL
variable now.
At this point you will have an empty database! We need to create some tables so SwiftLeeds has somewhere to store data. Thankfully, this is done for us as part of an "auto migrations" step when you first run the project. You don't need to do anything!
For advanced users, you may wish to run vapor run migrate
in Terminal. You'll need to press 'Y' when prompted. You can revert the previous migrations by running vapor run migrate --revert
.
SwiftLeeds uses a framework called Leaf in order to render the HTML frontend of our website. These views are stored within the Resources/Views
folder of the repository.
In order for Xcode to know where the Leaf files are stored, you must set your working directory within the active scheme. Vapor has documented how to do this here.
That should be everything! If you've followed these steps, you should now be able to run the 'swift-leeds' scheme in Xcode. This will output a message reading "Server starting on http://127.0.0.1:8080".
If the application fails to load then we recommend following these steps again to make sure you haven't missed something. Otherwise, feel free to raise a GitHub Issue or contact us on the Slack (links above) and we'll help you to get started.
In order to quickly get started, we've produced some "seed data" which inserts mock information into the database. Assuming you've used the database details documented above, it's as easy as running make seed
from your Terminal window.
You can then navigate to http://127.0.0.1:8080/login and use the email "[email protected]" and password "12345678" to enter the admin area. The admin area is available at http://127.0.0.1:8080/login (once logged in) and will give you the ability to insert your own sessions, speakers and more.