crusell.
← All transmissions

From an ICS feed to a school timetable: a small app with a clear job

Martins schema turns an iCalendar feed into a Swedish school timetable, with day and week views, offline access, and a small Cloudflare Worker behind it.

An iCalendar feed is a useful starting point. It gives you the events, times, and descriptions in a format that plenty of software understands. But having the data and having a useful view of the school day are two different things.

I built Martins schema, a small app that takes an ICS feed and presents it as a school timetable. The questions it needs to answer are straightforward: What’s happening now? What’s next? What does the rest of the week look like?

The source is on GitHub.

A timetable, rather than another calendar

The app has two main views: a daily timeline and a weekly grid. The day view highlights the current and next lesson, while the week view makes it easier to see how the days fit together. Overlapping lessons appear side by side, and subject colours stay consistent because they are derived from the subject name.

The week view in Martins schema, showing a school timetable with coloured lessons. All schedule information in this screenshot is made-up demo data.

The repository’s demo week view. The screenshot uses made-up fixture data.

The interface is in Swedish, with Monday-first weeks, ISO week numbers, and 24-hour times. Hand-ins and tests are picked up from entries prefixed with Inlämning: and Prov: and displayed separately from ordinary lessons. Where a course is provided, those entries use the course’s subject colour too.

On a phone, you can swipe between days or weeks. On desktop, there are keyboard shortcuts. Light and dark themes follow the system, with a manual override available.

Small details, but they all serve the same purpose: making the schedule easy to check at a glance.

The UI is small. Calendar logic is less so.

The frontend uses Vite and TypeScript, without a UI framework. For a focused app with two main views, that keeps the structure fairly direct: fetch the feed, parse it into lesson occurrences, and render the selected view.

Parsing the feed deserves more care than that short description suggests. A recurring event is more than a start time repeated every week. There can be excluded dates, moved occurrences, and changes to an individual lesson.

The app uses ical.js for parsing and recurrence expansion, with additional handling for timezones and the timetable’s lesson model. The parser accounts for recurrence exceptions and overrides, then produces a sorted list of occurrences for the requested window.

All displayed times use Europe/Stockholm, regardless of the device’s timezone. The tests cover timezone and daylight-saving behaviour as well as recurrence, week calculations, and overlapping lessons. Those are the details that can make an otherwise tidy calendar interface quietly show the wrong thing.

One small Worker behind the app

The deployment consists of a single Cloudflare Worker serving the built app and one proxy endpoint:

Browser → /api/schedule.ics → Cloudflare Worker → upstream ICS feed

The proxy solves two practical problems. The upstream feed does not provide the CORS headers the browser needs, and its URL contains a secret token. Keeping that URL in a Worker secret lets the browser request a same-origin endpoint without receiving the upstream credential.

The Worker validates its configuration, applies a timeout to the upstream request, and checks that the response looks like calendar data before returning it.

Access to the deployed timetable is handled by Cloudflare Access, rather than a login system inside the app. That is a separate responsibility from keeping the feed URL secret: hiding the upstream token does not, by itself, make the timetable private.

Offline means the last known schedule

Martins schema is a PWA that can be installed on iOS and Android. The service worker precaches the app shell, while the last successfully fetched feed is stored separately in localStorage.

That gives the app an offline fallback, with an “Uppdaterat …” indicator showing when the data was fetched. It is the last known schedule, so it may not include a recent change.

The service worker deliberately avoids caching API and Cloudflare Access routes. The app also recognises a non-calendar response, such as an Access login page, and offers a reload state instead of trying to parse HTML as ICS.

A useful scope for a small project

What I like about this project is its narrow focus. The feed remains the source of truth. The app’s job is to make it readable and accessible throughout the day.

There is still interesting engineering inside that scope: recurring events, timezone handling, offline state, and a clear boundary between public source code and private schedule data. A small interface can have plenty going on underneath it.

If you want to explore the implementation, the repository includes the source, test fixtures, and setup instructions. The fixtures let you run the interface locally without connecting a real school calendar.

End of transmission