Uploading Binary Files Into MongoDB

So part of my requirements for Kotakit was that I needed to upload PDFs into MongoDB. And I’ve never done that before. After googling, it turns out that for files less than 16mb, I could simply upload them as binary files. I also know next to nothing about the binary format. After an afternoon of tinkering around, I’ve finally managed to upload a binary file into my local instance of Mongodb. So here’s an attempt to note down everything that I’ve learned about the process and what is required. ...

May 19, 2023 · 6 min · Lei

Setting Up Next Auth With Mongodb

So, recently I was exploring options for quickly spinning up an authentication system for a NextJs environment, where I stumbled upon next-auth. Spinning it up ‘quickly’ is important, because I intend to use this framework mostly for the MVP stages of a project, and I don’t want to spend too much time configuring it. I have to admit, understanding it at first was not so easy, because authentication necessarily brings along with it a lot of different parts. Luckily, resources like these and these helped. ...

January 22, 2023 · 7 min · Lei

Steps for Implementing a More Robust Backend Development Architecture Part2

In part 1, we mainly looked at laying out the groundwork for the backend project, including setting up console logging (morgan), eslint, installing various dependencies, configuration for MongoDB connection, util files such as logger, creating the models I needed, coding the express app (app.js), and finally, populating the database with some initial data to work with. In this part, I’ll begin by documenting how I go about creating and testing the routes. Then, we’ll look at middleware and error handling. Finally, I’ll connect the frontend to the backend to make sure that all the data is being pulled correctly. ...

September 23, 2021 · 4 min · Lei

Steps for Implementing a More Robust Backend Development Architecture (Part 1)

You’ve arrived at the moment where your project is getting serious and you need to begin coding some serious backend. This guide will get you started. Goal of Backend Restructure Goal of the development project is to get the backend to look like this: Backend architecture: Index.js App.js Routers: Streams Router Trades Router User Router Login Router Models Trades Model Streams Model User Model Utils Middleware Logger config.js Tests setting up test environment Laying the groundworks Step 1: Take stock of current project dependencies and structure Examine package.json to see what dependencies it currently have. Examine the project folder structure and files to check where is the backend mostly stored. For a simple express server, it is possible that all the routes, middleware, models, are stored in index.js. ...

September 22, 2021 · 8 min · Lei

Mondodb Database Design

So whilst I was trying to design the database for my investment tracking app, I stumbled upon the question of what are the differences between traditional database designs and NOSQL, and what’s the most optimal way to design the NoSQL database for best performance. After a quick look around, I discovered that there are no special things you need to do to design NoSQL schemas, apart from simply treating it like you would store info in a python dictionary: through the JSON structure. ...

August 23, 2021 · 1 min · Lei