FEATURED PROJECT
Playlists
A full-stack web application for organising and managing video playlists from different platforms across the internet.

Overview
Playlists is an application that allows users to save videos from multiple platforms into playlists and to group playlists into collections. This allows users to manage content from different websites in one place.
The project involved building the frontend, backend API, database structure, authentication, validation, testing, and managing the deployment.
Features
Create and manage video playlists
Load video link previews
Add videos from YouTube and TikTok
Collections for organising playlists into groups
Search playlists, videos and playlist collections.
Customise videos within playlists
Re-order videos in playlists
Choose playlist cover images
Tech Stack
Playlists is a full-stack TypeScript application. The backend uses Node.js, Express, PostgreSQL, and Redis. The frontend uses Next.js and Tailwind CSS.
Architecture
The frontend is built with Next.js and communicates with a separate Express REST API. TanStack Query is used to manage server state, including fetching, caching, mutations, and loading and error states.
The backend separates routing, business logic and data access into routes/controllers, services and repositories. The repositories use Prisma to interact with PostgreSQL. The database models relationships between users, playlists, videos, and collections while using database constraints to enforce relationships and uniqueness.
Redis is used for short-lived data such as user access codes used during authentication. Docker is used during development and testing to run the project's supporting services locally.
Development and testing
For integration and end-to-end testing, isolated PostgreSQL and Redis containers are used to prevent test data from leaking between tests. Dockerised dependencies are used during development. This allows features involving external services such as email to be developed and tested locally without relying on production services.
Responsive Design
I designed the application to adapt across different screen sizes, with pages adjusting between mobile devices and large desktop monitors.


API and type safety
I use Zod to define and validate API schemas in the backend. These schemas are also used to generate the project's OpenAPI documentation, keeping the API specification close to the validation rules used by the application.
The OpenAPI specification is then used to generate TypeScript types and a typed client for the frontend. This approach helps keep the frontend and backend aligned as the API changes, while also providing validation at the API boundary and useful documentation for the available endpoints.
Security
Authentication uses short-lived access tokens and refresh tokens stored in secure HTTP-only cookies. Refresh tokens are rotated when they are used, with reuse detection to invalidate compromised sessions. Email verification, password reset and user login require two factor authenticated via a code sent to the users email.
API requests also verify that resources belong to the authenticated user before allowing them to be accessed or modified. Input is validated with Zod before it reaches the application logic.
Database design
PostgreSQL is used as the primary database because the application has several connected resources. Users can have multiple playlists, playlists contain videos, and playlists can belong to multiple collections. Prisma is used to model these relationships and provide typed database access from the TypeScript backend.
For example, when adding a video to a playlist a user submits the url of the video. The app will then attempt to fetch data to generate a link preview of the video. However, one video can have many url representations. To avoid redundant data and duplicate fetches the app models video data using `VideoSource`, `Video` and `PlaylistVideo`.
`Video` stores the original URL entered by the user, along with a `sourceId` if that URL can be fetched. When possible, the URL is processed to identify its canonical URL and its source data is fetched and stored in `VideoSource`. If the same user entered URL is encountered again, the existing `Video` and source data can be reused instead of performing another lookup. URLs that cannot be processed are still stored as `Video` records, so they can be returned without repeatedly attempting to fetch their source data. This separates three concerns: `Video` retains the user's URL, `VideoSource` deduplicates shared source data, and `PlaylistVideo` manages playlist membership and playlist-specific information, such as custom titles and descriptions. The url processing isn't completely foolproof, particularly with URL formats that are difficult to process, but the model avoids unnecessary lookups and duplicate source data where it can.
Video modelling
PostgreSQL and Prisma are used to model the relationships between video sources, videos and playlists.
VideoSource
id
string
platform
string
platformId
string
canonicalUrl
string
VideoSource → Video
A source can have many videos, while a video may optionally reference a source.
Video
id
string
url
string
sourceId
string
Video → PlaylistVideo
A video can appear in multiple playlists through PlaylistVideo.
PlaylistVideo
id
string
videoId
string
playlistId
string
customTitle
string
customDescription
string
PlaylistVideo
Each PlaylistVideo must reference exactly one video and one playlist. It also stores playlist-specific data.
Playlist
id
string
userId
string
Playlist → PlaylistVideo
A playlist can contain many videos, with each relationship represented by a PlaylistVideo.
Ongoing Development
The project is still something I continue to improve as I find areas where the design or implementation can be made clearer.
Rich text editor for video notes
Instagram support


