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.
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.
So I added / edited Clients, Products, Invoices Pages
In this devlog there is really nothing much to say as It was all trial and error as this tech is new to me.
Added a debounced username uniqueness check for welcome page and settings page
Changed few things to make some pages feel less AI like the auth pages, they look cool now.
Changed readme for both the projects to make it feel more simpler.
Provided .env.example for both the repos
Removed some dead code.
This devlog is for small changes I made.
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.
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.
Also I renamed both the repos to something short -> Bms-Backend & Bms-Frontend.
Lets talk about the frontend that is on NextJs.
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.
z.coerce.number() or .date
So I think this one is the last before ship, I promise. 😂🥹
I got no friends, or the friends I have aren’t like best of friends So I wasn’t able to test the game on scale. Feel free to open a issue in github or message me on slack
So I have done lots of stuff and this is the last devlog before the first ship.
Little sleepy rn as its 2:35 am my time, so I will wrap up fast.
Added pino in Nextjs (Its a logger)
Added caching wherever possible in nextjs using the cacheLife
Added auth refresh event so if the name is changed it doesn’t need socket reconnect
Optimised some code in socket server and also nextjs.
Games getting saved to DB and there is a career history page now.
Mostly did fixes of stuff and redesigned some elements in the lobby page.
Like there is nothing else to talk about I’m mostly fixed stuff.
I gotta sleep, have to ship the project too maybe I do it after waking up because readme is not ready yet.
I think I’m gonna do after waking up so tired rn
I will keep this devlog sweet and short as I wanna ship this project as soon as possible as It has taken a lot of time now.
I know this devlog doesn’t feel personal and I only talk about the stuff I did, its because I wanna Ship this project as soon as possible and get done with it and move on to something else, because projects like this never end and you have to decide when to stop.
I think next devlog will be the last devlog before the first ship
Big devlog, here we go again.
Lets talk about nextjs first.
So I added magic link to the app as the feedback I received was I don’t wanna use my google account as I don’t the trust the website enough to use it and I also want to use all the features so guest won’t work. This pushed me to add somewhat of a email login. I dont like password login so I wanted to add passwordless login and it wasn’t a debate I just picked one which is magic link.
Now lets talk about the big thing which made this a long devlog !!! Drum Roll please 🥁🥁🥁 I decided to restructure many parts of my socket server because of scalability as my previous architecture wouldn’t have survived If i added more gamemodes and all.
Because when I started the restructure I didn’t know how my architecture would look like or what would work ( still haven’t tested anything ). So I researched some stuff but some stuff you decide along the way.
I learnt that no matter what the project is and what you decide at the start that you are gonna build there will always be a time where the plans fail and we have to decide should we go through with it or suffer in the future or should we just focus right now and work hard so that in the future it all comes back to us with a lots of happiness!!!
Cheers,
Neerav
Another Long Devlog Time
So I was setting up my project to be deployed on the nest container that I have since nest only gives public ipv6 I couldn’t host my nextjs app on vercel because then I wouldn’t have been able to connect to my postgres database which was on nest as vercel dont have ipv6 support so I moved my nextjs to nestjs and It caused me hell lot of problems and bugs.
Lets talk about the project what I update in that
friends: [],
requests: [
incoming: [],
outgoing: []
]
Then socket server retrieves all the playes using their playerid from redis via mget and then returns the same object structure but in friends its adds a online: true/false to the player objects
Now let me tell you a funny story. When testing stuff in prod, I was confused why stuff wasn’t working because it was working fine during development then i remembered I didn’t update the .env file in prod. It may have cut some years from my lifetime.
This is gonna be a long devlog.
Now lets talk about backend that made this devlog of 10 hours

which made me spent so much time looking for what is the issue why isn’t my room details getting sent to me and I was looking in nextjs frontend for the issue. I spent so much time finding this bugFinally let me tell you something when visting the website if the thing looks small the implementation of that thing takes so much time.
Bro Literally the friends sidebar took so much code to make in the frontend and in the backend and in the socket server as well. like that small piece of the page took me so much time to make which also made this devlog So long.
Incountered so many bugs along the way. They were all silly mistakes some were logic error but most were silly mistakes as there are so many files in the project now its hard to find some things.
So I am now using drizzle with postgres and I also took some time to tinker with it and understand it a little better.
I am also using better auth with google signIn and anonymous login.
In the user i have username and name , username is for adding friends or locating a user, name is to be displayed , username is unique, name isn’t.
Created the db model with friends support and matches history.
We can add friends in the game also added user settings to customise stuff.
Project is starting to look like something. All the drizzle + backend part that i have done in the period is committed and pushed but the frontend part still remains to be committed.
So first of all I switched from using npm to pnpm and updated the docker file accordingly for the socket server.
Then I started working on adding users / db functionality in the nextjs app.
I created login and register page with two options for signIn -> google or guest.
I started tinkering with prisma and better auth and the prisma8 has just come so I started setting it up and had made the schema and had written up some services too but then when I tried to logIn i got few problems which I researched and searched and found out that betterAuth hasn’t adjusted to prism8.
So I did what I should have done before, I switched to drizzle. Around 3-4 or more hours were wasted!.
Now I’m using drizzle and have setup the schema and tables and also better auth in it and the signIn are working.
Now I have to create routes or server Actions to retrieve data or send data. Now the games will be saved and stored once finished and user will able to see it in match history.
Backend Socket Server
Now Frontend
Future Plan
Making this devlog after a long time of doing all this work, the frontend part is still uncommited in github though
Lets talk about backend first ->
Now Frontend