Skip to content

Randy-RM/express-js-mvc-tuto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

262 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Express.js MVC Blog API

A RESTful blog API built with Express.js 5, TypeScript, MongoDB and Passport.js. This project follows the MVC + Service Layer design pattern with role-based access control.

This application is a simple blog API with role-based authentication (user, moderator, admin).

A note for you, fellow developer β€” This project exists for one simple reason: to help you learn, grow, and get better at backend development with Express.js. Whether you're just getting started or looking to level up your skills in software architecture, clean code, and best practices, this codebase is designed to be explored, studied, and used freely for your personal projects. Every folder, every layer, every pattern here is meant to be understood β€” not just copied. Take your time, read through the code, follow the documentation, and make it your own. If you have a thirst for knowledge, you're in the right place.


Table of Contents

# Section Description
1 Project Architecture Directory structure, layers, and how they connect
2 Tech Stack & Packages All dependencies with their purpose and relationships
3 How the Application Works Middleware pipeline, authentication flow, RBAC, error handling
4 Request Lifecycle Example Step-by-step walkthrough of a POST /api/articles request
5 API Endpoints All routes with auth requirements, roles, and examples
6 Installation & Configuration Setup guide, scripts, and environment variables
7 Commit Conventions Commit message format, examples, and pre-commit hooks

Quick Start

git clone https://github.com/Randy-RM/express-js-mvc-tuto.git
cd express-js-mvc-tuto
yarn install
# Rename sample.env to .env and configure your variables
yarn seed
yarn dev

The API will be available at http://localhost:8000/api. The Swagger documentation will be available at http://localhost:8000/api-docs.


Overview

Tech Stack

Technology Purpose
Express.js 5 Web framework with async error handling
TypeScript 5 Static typing with strict mode
MongoDB + Mongoose 9 Database & ODM
Passport.js + JWT Authentication
bcrypt Password hashing
express-validator Input validation
Helmet + CORS + Rate Limit Security

Architecture

Routes  β†’  Middlewares  β†’  Validators  β†’  Controllers  β†’  Services  β†’  Models
                                                                          ↕
                                                                       MongoDB

Roles

Role Access Level
user Read articles, manage own account
moderator + update/delete articles
admin Full access

Available Scripts

Command Description
yarn dev Start development server with hot reload
yarn build Compile TypeScript to ./dist
yarn prod Run the production build
yarn seed Seed the database
yarn lint Run ESLint
yarn lint:fix Run ESLint with auto-fix
yarn format Format with Prettier

For detailed documentation, see the docs/ folder.

You can use this project as a base example for getting started with your backend projects using Node.js, Express.js & TypeScript.

About

Hello 😎!!! This project has been set up to help those who are new to BackEnd programming with Javascript in a Node Js environment. It has been organized following a few best practices πŸš€ such as the MVC design pattern, the Camel case naming convention, etc...

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors