You are browsing as a guest. Sign up (or log in) to start making projects!

Multi Tenant Business Management App

  • 13 Devlogs
  • 76 Total hours

A multi-tenant REST API for invoicing, payments, and business operations. Models a real SaaS invoicing platform and solves the core architectural problems those systems face: per-tenant data isolation, concurrent invoice numbering, transactional payment recording, and financial record immutability.

Stack: Bun · Node.js · TypeScript · Express 5 · MongoDB · JWT · Passport.js · Cloudinary · Puppeteer · Resend · Docker · Vitest · Supertest

Open comments for this post

8h 13m 21s logged

Devlog 12

So I added the payments page and fixed a lot of bugs.
I have only slept 6 hours (3:30 prev night and around 2 at evening) for the past 35+ hours. I am only one coffee deep rn.

So lets talk about the bugs and all in a little detail.

  • The latest bug I was facing was, I am using an paginate plugin in the backend mongoose aggregate paginate v2 so it doesn’t allow complex queries and stuff and there is a option countQuery which is to be set to the same aggregate used in aggregatePaginate, let me show you with the code

const payments = await Payment.aggregatePaginate(paymentAggregate, {
  page,
  limit,
  countQuery: Payment.aggregate(pipeline)
});
  • I had no idea this thing existed because the docs are not well properly documented for the plugin.

  • First of all I was thinking why isn’t the search working my code is completely right, then I came to the conclusion with the help of AI also debugging with me ofc that aggregatePaginate is the problem then I found out that i can use countQuery.

  • Also before this, the search in products table wasn’t working, as I am using a template underneath so I checked the implementation, nuqs package is used for searchParams and for the table I’m using Tanstack Table which also had search filter so I had to get the value from the tanstack table search filter instead of from nuqs which also took me a while to debug.

  • Then before that bug, I had a bug where the table weren’t getting updated if actions were performed on the same page without refresh like delete or in client page create or update, so the issue was I was invalidating queris serverSide instead I had to invalidate clientSide.

  • Also some minor backend things, invoice get route filters had email / name differently i combined them to one search.

  • The index in products on sku + businessId was considering null as one so I added

{
  unique: true,
  partialFilterExpression: {
    sku: { $type: 'string' },
  },
}
  • Also in frontend, the fetch wrappers I had were converting all the body into json, so i fixed that If formData is present send it as formData not json.

  • Also I’m uploading files and sending the request via server actions in Nextjs, there was a default limit of 1mb so I added config for it in next.config.ts, it is a experimental config though.

I think that is It, Just couple more hours of the project left then I will ship it.

0
0
2
Open comments for this post

8h 42m 51s logged

Devlog 11

So I added / edited Clients, Products, Invoices Pages

  • Each one of them uses Tanstack Table, Query and Form
  • It took my time to understand the structure and all.
  • There is nothing to say as the time was taken by the coding part, the type errors I faced and all
  • Invoice form was a little complex as I had to add a combobox with debounced search to add products and link to a client.

In this devlog there is really nothing much to say as It was all trial and error as this tech is new to me.

0
0
3
Open comments for this post

5h 31m 11s logged

Devlog 11
So i fixed a bug in backend, zod url validation is strict and also requires the protocol https:// to be in the url but now I am using string with regex.

For the NextJS part

  • Sign In, Sign Up page fully done with Backend For Frontend (BFF) architecture.

  • Improved fetch wrappers a bit.

  • Also in login api route in nextjs the cookies weren’t getting transfered to the browser so fixed that as well.

  • Added the home page (/businesses) also added the create business page + a success page with a Confetti canvas animation

  • Added api routes in nextjs for fetching user businesses (get) and creating a user business (post).

I’ve been working for almost 8 hours on this for two days, so tired rn goal is to finish this by tomorrow or I can say today as 1:20 am rn.

0
0
7
Open comments for this post

8h 19m 54s logged

Devlog - 10

So now that I’m continuing this project, I decided to use a admin dashboard template and adjust it according to my needs as the main thing I wanna show is my backend skills.

  • So first of all I was using bun in the backend, I switched to pnpm (personal preference)
  • Now I am using tsdown for building the express app.
  • There was some issue in extended Request type so I fixed it.
  • Also I was using a mongodb cluster free tier, now I am using a mongodb replica set on docker.
  • Also the global rate limiter was applied on everything not just /api/v1 so fixed that.

Also I renamed both the repos to something short -> Bms-Backend & Bms-Frontend.

Lets talk about the frontend that is on NextJs.

  • I am now using a template which includes a dashboard not fully complete for my need so I will be doing that, it had sentry, clerk and some other stuff, I removed that as It removed a cleanup script.
  • Added the login form and attached it with the backend.
  • I was previously using axios, but now I am using fetch and I am using a architecture called BFF (Backend for Frotend). So the client components call the nextjs backend and that backend calls the express Api whereas server component directly call the express Api so I created fetch wrappers for client calls and server calls.
  • Added a logo for the app.
  • Added proxy.ts and its logic
0
0
8
Open comments for this post

4h 47m 24s logged

Devlog 09

So, I combine two stardance projects (backend, frontend) into one (fullstack), at the time I thought I could ship both together but I had to have both repos connected in one project, I didn’t know at the time and I then abandoned the project and this project was the backend & I added the frontend repo to it so all the fronted devlogs are gone.

In this devlog I will write the changes made to backend after the previous devlog + I will summarised what was done in the fronted so far and after this devlog, I will write the devlog as normal as you guys will catch up to speed.

Backend (Express)

  • In zod using z.number() or .date() were resulting in error if passed as a string as data would always get converted to string before reaching backend so i added z.coerce -> z.coerce.number() or .date
  • Added github actions workflow to automatically pull changes and build with docker + fixed perms issue in Dockerfile.
  • Added redirecting of / to /docs

Frontend (NextJS)

  • Auth Pages are done (Login, Signup, Forgot-Password, Reset-Password) with zod and react-hook-form validation
  • Pages are made using shadcn ui components
  • Home page is done with listing of business that user is a part of
  • Sidebar, header, Create-business-form and BusinessCard, invoice table components are also commited
0
0
8
Open comments for this post

12h 29m 44s logged

Devlog - 08

Since I was building a front end for this project and when designing the front end I didn’t had a route for getting all the businesses the logged in user is part of. So I added that route to show all the businesses on the home page of dashboard

And also I have email, password login so I needed a route to verify the user who has used email password using a verification code sent on their email. So I updated the user model and added that route too.

Next thing was I added those routes to my openApi docs and also I updated my readme.md and other mds in root docs/ folder.

One more thing is left in this project is to have separate analytics routes for separate modules like clients analytics, products analytics then main dashboard analytics.

I will make them once a get a jump on front end since I’m laking behind there

0
0
7
Open comments for this post

4h 3m 36s logged

Devlog - 07

Since its a Backend API so I needed to create a api endpoints docs to showcase the project to other people as some UI helps in showcasing

I used scalar and openAPI docs for my project, It took me some time to understand what to do but I was finally able to do it

And then during deployment I made an error of putting some dependencies into dev dependencies as they were prefixed with @.

Finally was able to get my docker deployment working

0
0
6
Ship #1 Pending review

What did you make?
I built an open-source business management platform backend with authentication, Google OAuth, workspaces, clients, products/services, invoices, payments, analytics, PDF invoice generation, email delivery, and Docker support.

What was challenging?
Building a scalable architecture, writing integration tests, handling workspace permissions, debugging file uploads, and getting Puppeteer PDF generation working reliably in Docker.

What are you proud of?
The complete business workflow, clean architecture, Dockerized deployment, and 39+ integration tests that help ensure reliability.

How can people test it?
Docker setup and environment configuration are included. They can directly docker compose or run using bun or npm

  • 6 devlogs
  • 24h
Try project → See source code →
Open comments for this post

28m 53s logged

Devlog -6

Added a analytics endpoint and its time to end the backend project and move on to the frontend of the project.

If issues come up designing the frontend, will have to comeback to fix it.

Till then i have deployed it with docker on railway.com

0
0
5
Open comments for this post

1h 50m 12s logged

Devlog - 05

After adding tests, I decided to dockerize the project. But i was using puppeteer and it causes some issues in docker so i changed it to puppeteer-core and add install commands for chromium separately in docker file.

I made everything work after some brutal hours of debugging and fixing and learning as this is my first time working with docker

0
0
3
Open comments for this post

10h 1m 9s logged

Devlog 4 - Backend Testing Marathon 🧪

Spent few days building out integration tests for my Express + TypeScript backend.

Added test coverage for:

  • User registration & login
  • Refresh token flow
  • Forgot/reset password
  • Clients
  • Products (including file uploads)
  • Invoices & payments
  • Workspace/business authorization

Also set up:

  • MongoDB Memory Server for isolated test databases
  • Factories for generating users, businesses, invoices, products, etc.
  • Mocks for Cloudinary, Resend, and bcrypt

Ran into a pretty annoying EPIPE error while testing multipart file uploads. After a lot of debugging, I tracked it down to file stream handling in tests. Switching upload tests to use Buffers instead of fixture files made the suite stable again.

Current stats:

  • 39 tests
  • 15 test files
  • Full integration test suite passing ✅
0
0
2

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…