Table of Contents
For my ITIS 4166 class (Network-based App Development), my professor wants us to build an e-commerce website. So I built a luxury cheese marketplace for cheese connoisseurs
so I could control 1 percent of the market and get VC funding. Jokes aside, I pretty much went straight into making it from the beginning of the semester. I learned a lot about
how express.js works and used its templating engine ejs
for routing the HTML. Then I imported Tailwind CSS CDN and stylized everything to try and make it look like a
premium place to bid and trade cheeses.
- I used Model View Controller (MVC) architecture which made it easy to structure the project while separating the inner components and functionality into three interconnected parts.
- Used express built-in middleware
express.static()
to serve my static files & parse request body (JSON)express.urlencoded({})
. Most of the files are images that I made such as the branding and others are art generated by Midjourney. - Middleware libraries that I've used are:
- UUID - Used to generate different IDs for each object. Useful for preventing CSRF attacks.
- Morgan - Logs request (HTTP) and its associated endpoints.
- Nodemon - Easily launch the project to a dev environment and enable hot-reload refresh on local change saved.
- Multer - Enables the ability to upload files (specifically with image file extensions). All uploads are stored in my project directory (local).
- express-session - Allow for user authorization and authentication. Sessions are stored in the database and compared with cookies. Sessions are cleared every time we exit the project instance.
- express-validator - Sanitizes and validates form data.
- express-rate-limit - Limits repeated authentication requests to protect against network-based guessing attacks.
- General libraries used:
- bcrypt - Hashing library used to hash passwords before storing them into MongoDB.
- connect-mongo - Allowed storing a user session
express-session
into the Mongo database. - connect-flash - Used for flash messages (displaying warnings or success) to provide user feedback.
- My models only contain the abstraction written with
Mongoose
. Since Mongo doesn't do relational databases, I cannot use foreign keys but I can still explicitly reference other documents by having references.- For example my
offerSchema
for the offer model holds reference to User & Cheese model.
- For example my
- My controllers contain callback functions for my routes to use. This is where I defined what the route is expected to do such as POST data into my database or make a GET request to display
HTML
with data (depends). For my routes, I can also attach configured middlewares to my route as args to perform for example form validation or authorize whether the user is allowed to visit the page. - Any
HTML
goes into/views/
. To avoid redundancy, I made reusable components such as a navbar or footer which goes to/views/partials/
. - My project is not perfect though, it contains some bugs and are missing small details so if you discover anything, please make an issue.
Distributed under the MIT License. See LICENSE.txt
for more information.