Friendless

Full-stack AI chat companion app built with Next.js, tRPC, PostgreSQL, Prisma, and Bun.

July 23rd, 2024


Summary

Friendless is a slightly silly, slightly dystopian full-stack AI companion app designed to replace human communication, or at least parody the idea.

Built with Next.js, tRPC, PostgreSQL, Prisma, and Bun.

Demo it here

Features

Motivation

The main motivation behind this project was to get hands-on experience with a TypeScript monorepo using tRPC and to explore how tightly coupled front–back communication changes development workflow. As far as the subject matter of the app (AI "friends"), it's a simple parody of dystopian AI startups that are outsourcing enjoyable parts of the human experience.

Architecture Overview

Technologies Used

Key Design Decisions

Why tRPC?

tRPC enables end-to-end type safety by enforcing consistent types between your database and your application using Zod. It required a bit of initial boilerplate, but the result was far fewer difficult-to-trace errors than I have had in previous Next.js projects that relied on different API paradigms.

Why Next.js

My reasoning for NextJS was largely that I wanted access to the vast amount of UI libraries and components built for React. I actually think that Next.js was the least crucial part of this experience. It could have just as easily been replaced with SvelteKit and had similar functionality.

Challenges

Key Takeaways

tRPC is really great

Using tRPC as a backend in a TS monorepo feels really, really good. It makes it very intuitive to understand the flow of the data in your application. Instead of feeling like you're building a separate frontend and an API in the same repo, it creates a unified experience where you're defining a router to do the exact thing you're calling in your frontend and calling it like any other function.

React is overkill for most applications

This project illustrated clearly to me that in the vast majority of non-enterprise (and even many enterprise) cases, React is complete overkill. I don't necessarily regret it, but the app could have just as easily been built in a lighter-weight framework like SvelteKit, while still getting the same benefits for tRPC. React is a double-edged sword where you get access to the ecosystem at the cost of having to write React.