Developing a Twitter Clone

Sometimes, in order to create something new, you need to create something old. I created YELL SOMETHING to learn modern web development techniques and get exposed to new programming languages, like TypeScript, all while replicating the popular Twitter (now X) platform. Thankfully, this project was not a complete carbon copy, because as the name suggests, in order to post something, YOU NEED TO YELL IT!

let message: string = 'This is YELL SOMETHING'

YELL SOMETHING is a simple posting service built within the T3 Stack. Once authenticated with their google account, users can YELL SOMETHING on the community message board. Here is the Live Link and GitHub Repo.

App Development

Built with:

  • Next.js - Web Framework
  • TypeScript - For type safety in the app
  • tRPC - For routing/API
  • Prisma - For scalable database functionality
  • NextAuth.js - For user authentication with Clerk
  • Tailwind CSS - For frontend styling and aesthetics

Constraining Posts

As the name suggest, you can only create a public post by typing in all caps. The code below shows how this functionality is carried out, using Zod, tRPC, and Prisma.

create: privateProcedure
  .input(
    z.object({
      content: z
        .string()
        .regex(/^[A-Z\s]+$/, 'YOU HAVE TO YELL (NO LOWERCASE ALLOWED)')
        .min(1)
        .max(280, 'YOUR MESSAGE IS TOO LONG, TRY AGAIN!'),
    }),
  )
  .mutation(async ({ ctx, input }) => {
    const authorId = ctx.userId
    const { success } = await ratelimit.limit(authorId)
    if (!success) throw new TRPCError({ code: 'TOO_MANY_REQUESTS' })

    const post = await ctx.prisma.post.create({
      data: {
        authorId,
        content: input.content,
      },
    })
  })

Key Takeaways

By no means was this application the most robust or functional, however it served its purpose. The purpose being learning! It exposed me to a variety of relevant and important web development technologies and gave me meaningful experience working within a diverse full stack application. The T3 Stack is not my immediate go-to, but knowledge of tech that pushes me out of my comfort zone will have nothing but positive affects on my aptitude as an aspiring software engineer.