Every day, thousands of aviation enthusiasts follow flights in flightradar24. A feature I miss on the website, though, is a chat where you can talk with other people following a specific flight.
This project attempts to fill this gap with a chrome extension.
This monorepo contains two main folders:
- Client: All the code needed to build the chrome extension. I used this boilerplate to bootstrap it. Built with React, Vite, Tailwind & TRPC.
- Server: Backend that exposes TRPC endpoints. Uses Fastify, PostgreSQL, Prisma & TRPC.
A session is created when the user opens the popup for the first time whose id is saved as a signed cookie. The session's name is a random concatenation of an adjective with an aircraft's name.
The flightId
is extracted from the browser's URL and is used as a chatId
for the next received and sent messages.
Messages are fetch with a TRPC endpoint used as an infinite query for retrieving older messages. New messages are received through a TRPC subscription.
The server uses a ChatPubSubPort
to make the subscriptions work. At the moment, this port uses a memory adapter at runtime, but it's ready to use a Redis adapter, for example, to make horizontal scaling possible.
- Clone the repo
- Run
yarn
to install client and server dependencies. cd client && cp .env.template .env
- Run
yarn dev
in the client folder. - Open a new terminal and
cd server && cp .env.template .env
- Run a PostgreSQL instance, get the URL and paste it in
.env
- Run
yarn prisma db push
to create the tables in the DB. - Run
yarn dev
in the server folder. - Go to "manage extensions" in chrome and use the "load unpacked" button to open the
client/dist
folder
Done! You can open the popup now.