This repo contains the source code for the website https://isitweeka.com/, a centre of information for students of King Edward VI Camp Hill School for Boys and King Edward VI Camp Hill School for Girls.
It is primarily concerned with telling students what timetable week it is (A or B), but also provides information on school events (including house event results) and an alert banner for important news (ranging from green and blue for low level alerts, to red for breaking news).
It also has a widely followed social media account covering school news, events and house events. See @isitweeka on Instagram for this.
Our frontend in frontend/
is based on Create React App. A CI script builds this into a bundle every push and deploys it to GitHub Pages to host our website.
Here's how everything in this repo works:
At a higher level (for a deeper level, and the modules involved, read the code) we find the week like this:
.ical
fileweekMarkerDate
(a number, where 0 is Sunday, where an event saying what week it is should be found).
KECHB (but not KECHG) changed how they define the week this year (moving from a separate event each week defining the week to a recurring event), and so an algorithm change was needed:
.ical
fileCode also exists to do this detection on a server, with the site then just requesting an API that says what week it is. However this requires running a server which costws money, so instead this client side detection is used instead.
IsItWeekA makes use of a monorepo structure to hold the various modules that make it up:
@isitweeka/core
packages/@isitweeka/core
WEEK_MARKER_DATE_
: the day (where 0 is Sunday) of the event (or recurrence of the root event), each week, in the school calendar that marks if the Week is A or B.LogFactory
, where you provide a location for log file and a winston
Logger is returned)libisitweeka
packages/libisitweeka
IsItWeekA
, that has the actual logic to find what week it is (see doc comments for it's specific usage)frontend
frontend/
isitweeka-server
server/
@isitweeka/service-___
isitweeka-server
Below, find how things are structured in this repo:
.github/
- CI config files, such as the CI that buids and deploys the website, and the CI that regularly updates our copy of the school calendars stored in frontend/public/cal
assets/
- Core assets of IsItWeekA, namely copies of our Logo in various sizesconfig/
tsconfig.json
in the root of the repo references all the modules, allowing TS Incemental Builds and TS Projects to be used - one command builds everythingscripts/
- misc. scripts Whilst this is currently not deployed, sometimes a server-side API is required. This is normally for when the site needs to fetch data from external APIs such as Eventbrite - this requires an API key, which we can't put in public client-side code.
Therefore, an API was created. I wanted something modular, so this is what we did:
packages/@isitweeka/service-kech/
- using libisitweeka
figure out the current week for KECHB and KECHG once every 30 secondspackages/@isitweeka/service-eventbrite
packages/@isitweea/core/src/constants.ts
server/
receives requests from clients at specific routes, fetches the appropriate key from redis and sends it back to the clientThe API runs using docker containers:
Since the API is setup lik this, to add a new sevice:
docker-compose.yml
filesserver/
that returns the data from Redis.prod.yml
one) to deploy the updated images to production so they can be used as the APIyarn
package manager
yarn
yarn run build
yarn
yarn run build
cd frontend
yarn start
yarn
yarn run build
cd frontend
yarn build
The contents of frontend/build
may then be served as a static site.
.env.template
as .env
. Here, fill in the environment variables as apprioraite:@isitweeka/service-eventbrite
):
IIWA_EVENTBRITE_ORG_ID
: the ID of the organisation holding the event you want to track total net revenue (i.e. amount raised) ofIIWA_EVENTBRITE_EVENT_ID
: the ID of the event you want to track total net revenue (i.e. amount raised) ofIIWA_EVENTBRITE_ACCESS_TOKEN
: Access Token of an account with appropriate permissions to access said event in the Eventbrite Organiser (get one at https://www.eventbrite.com/platform/)docker compose build
docker compose -f docker-compose.prod.yml up
(make sure secrets file (.env
) has been copied to prod)