I built this project to really learn how to make a backend API that can handle many different users (or "tenants") and control what they can do (that's the RBAC part).Why I Made This:
- I wanted to get good with some cool tools: Fastify (it's super fast!), Drizzle ORM (great for working with databases in TypeScript), and PostgreSQL.
- I needed to figure out how to build one API that many different "apps" or clients can use safely, without mixing up their data.
- I also wanted to build a good system for permissions – deciding who gets to do what.
- Learning to test my code properly was a big goal. So, I set up Vitest for both small tests (unit) and bigger tests that check if everything works together (integration tests, even with a mini-database).
- My idea was also to make a good starting point for my next projects that need these kinds of features.
What I Learned (It was a lot!):
- Fastify and Drizzle are awesome! Fastify is quick, and Drizzle makes database stuff much easier and safer with TypeScript. I really liked using them.
- I got a much better idea of how to keep data separate for different users in a multi-tenant app.
- Figuring out the RBAC (roles and permissions) was challenging but rewarding. Now I know how to protect API routes based on what a user is allowed to do.
- Testing properly is a game-changer. Writing tests made me feel much more sure that my code was working right.
- I'm happy with how I organized the project files. It feels clean and easy to find things.
This project was a big step for me in building backend apps. I learned so much and now have a solid base for future projects.