Using Prisma or tRPC API from T3 Stack in different project

Hi, I've created a small app using the t3 stack including tRPC and Prisma. To update some of the tables in the database created by prisma, I need to create a little project outside of the scope of nextjs (or so I believe) to connect to a kafka topic and consume data that gets transformed and upserted/deleted in my prisma db. What's the best way to organize this and kickstart the second project so that I can reuse the things I created in my next app? Would it be better to directly use prisma to do this, or should I create separate tRPC API Endpoints to accomplish this task? My gut instinct tells me that I would prefer the latter, but I am unsure if this is even possible or advisable. It is my understanding that the monorepo pattern is something that I would need to look into, but I am having trouble in understanding how this would actually work in my context. Do I need to convert my nextjs/t3 project to something different, and again, how would I organize this? I hope I verbalized my question clearly and would love if someone could answer it or pinpoint me in the right direction using articles or whatever. Thanks in advance.
6 Replies
AllesCoolAllesBestens
Would it be reasonable to move the serverdirectory from my t3 app outside of the app directory like so: I could move the src/utils/api.tsas well, import it inside nextjs' pages/_app.tsx and I guess nextjs would work as before. However I would need to do the same on my kafka_consumer_app and this would just create a new tRPC router including all the routes I need for my nextjs app but not for my consumer. It wouldn't really use my existing tRPC API but duplicating it. Doesn't feel right. This would probably work if I use the genreated prisma client I guess, but I would like to know how tRPC would be used in this context, or if it doesn't make sense at all to use tRPC like this.
AllesCoolAllesBestens
I believe my question is answered here: https://trpc.io/docs/quickstart#1-setup-the-trpc-client
Quickstart | tRPC
Learn how to quickly get started and setup tRPC
AllesCoolAllesBestens
If you read this thank you for listening to me thinking out loud lol However if someone with more experience in this area has something to add I would love to hear it.
NotLuksus
NotLuksus13mo ago
Imo a monorepo is probably by far the best choice. Checkout create-t3-turbo as a reference point: https://github.com/t3-oss/create-t3-turbo Monorepos seem quite dauntin at first, however it's actually quite simple. Imagine it like creating your own local npm packages / libraries you can import anywhere across the project. Yes it involves learning a bit about build pipelines, but documentation and examples are great. https://turbo.build/repo/docs
GitHub
GitHub - t3-oss/create-t3-turbo: Clean and simple starter repo usin...
Clean and simple starter repo using the T3 Stack along with Expo React Native - GitHub - t3-oss/create-t3-turbo: Clean and simple starter repo using the T3 Stack along with Expo React Native
Turbo
Turborepo Quickstart – Turborepo
Create your first monorepo or add Turborepo to an existing project.
AllesCoolAllesBestens
Thank you, the example repo is very helpful I was looking into turborepo as well
Want results from more Discord servers?
Add your server