Melak12 / react-modular-boilerplate

The well structured with modular (feature based) oriented architecture template (starter kit) for building medium to enterprise react web app.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React Modular Boilerplate for Enterprise Apps

πŸš€ Quickly dive into your product development without worring about the folder structure and configurations.

This is well structured template (starter kit) with modular (feature-driven) architecture for building medium to enterprise react web app.

As we all know the complexity of the code grows with the time of the app being in development. This particular architecture will be an overkill for a simple 1-3 page app or prototype. But for an app which is expected to grow with a new and new features added to it, this structure provides quite an accessible way to balance the growing complexity.

In his artcle Screaming Architecture Bob Martin says:
  "Your architectures should tell readers about the system, not about the frameworks you used in your system. If you are building a health-care system, then when new programmers look at the source repository, their first impression should be: β€œOh, this is a heath-care system”."

benefits

  • The biggest pro of this structure is the ease of adding/updating code. Since the bulk of the code is broken down into different features (modules) it is easy to add new features or update existing modules. This separation also simplifies the codebase since now files can be considered private which helps with understanding the codebase.

  • Another benefit is that the code outside the modules folder is generally pretty simple to understand since most of the business logic is wrapped up inside the modules folder. This again makes understanding and working with the code that much easier.

  • Better code discoverability - it's easier to locate things, what is located where.

  • Better encapsulation - no need for other modules to know too much about each other or too easily include code from each other, no need for the code which is used only for one feature to pile in the common place;

  • Better testability - the more separate the components are, the easier to test them independently from each other.

  • Easier to work for a team - different people can work on different features (modules) without interfering much with each other's work.

  • Better reusability, the core can be reused for other apps, also features can be detached more or less freely, considering that the core will stay the same or similar;

Rule of Thumb

  • Don't use or import one module in another module directly. Use global store to manage common states.
  • Only import resources or components from modules coming from their .index.ts file only. Unless doing so, you would get ESlint error.

Features

  • 100% Typescript
  • Axios Http Client with interceptiors
  • Sample Todo Examples
  • Modular architecture: in compliance with the best architectural practices
  • Import alias
  • Unit testing with Jest
  • MUI - Material UI
  • ESLINT - Configured to get Eslint error when you try to import a component or a class inside a module that doesn't come from index.ts
  • Commonly used utility functions (/src/utils/)
  • MIT License

Tech Stack

Directory Structure

β”œβ”€β”€assets β€” Global static assets such as images, svgs, icons, so on.
β”œβ”€β”€components β€” Global shared components
β”œβ”€β”€config β€” Global configurations and constants
β”œβ”€β”€contexts β€” Shared React Contexts
β”œβ”€β”€hooks β€” Shared custom react hooks
β”œβ”€β”€models β€” Application wise model classes
β”œβ”€β”€modules β€” Modules (features) that are independent each other.
  β€ƒβ”œβ”€β”€Auth β€” module related to Authentication
  β€ƒβ”œβ”€β”€Todo β€” module related to Todo List
  β€ƒβ”œβ”€β”€...
β”œβ”€β”€pages β€” Shared pages that are not necessarily be included in modules.
β”œβ”€β”€routes β€” Anything related to routing setup.
β”œβ”€β”€services β€” Contains all external and shared services.
β”œβ”€β”€tests β€” Contains tests for shared services, functions and components.
       Note: tests for individual modules are included in the module (feature) directory.
β”œβ”€β”€utils β€” Global Utility functions
β”œβ”€β”€index.html β€” HTML page containing application entry point
β”œβ”€β”€index.tsx β€” Single-page application (SPA) entry point
β”œβ”€β”€package.json β€” Workspace settings and NPM dependencies
β”œβ”€β”€tsconfig.ts β€” TypeScript configuration
β”œβ”€β”€tsconfig.aliases.ts β€” Extended Typescript configuration that contains import aliases.
└──vite.config.ts β€” JavaScript bundler configuration (docs)
β”œβ”€β”€.eslintrc.json β€” ESlint configuration and rules

Installation

# install dependencies
npm install

# serve at localhost
npm run dev

Requirements

Optional Recommendations

  • VSCode: Free code editing IDE

Contribution

Let’s create great products together! We encourage and welcome collaboration and any type of contribution. πŸ‘‰ Learn the contributing docs on how to contribute the right way.

Give a shout-out to me

  • ⭐ Star my GitHub repo
  • 🐞 Create requests, submit bugs, suggest new features
  • β˜„οΈ Share to your friends and collegues
  • πŸ”₯ Follow me on Twitter and LinkedIn

About

The well structured with modular (feature based) oriented architecture template (starter kit) for building medium to enterprise react web app.

License:MIT License


Languages

Language:TypeScript 98.9%Language:HTML 1.1%