Skip to content
Nick Gallimore edited this page Aug 3, 2024 · 1 revision

Nufacturing API Wiki

Table of Contents

  1. Overview
  2. Getting Started
  3. Configuration
  4. Running the Server
  5. Project Structure
  6. API Documentation
  7. Models
  8. Routes
  9. Controllers
  10. Middleware
  11. Utilities
  12. Environment Setup
  13. Branching Strategy
  14. Contribution Guidelines

Overview

The Nufacturing API is a Node.js-based backend service that provides various functionalities for managing the Nufacturing application, including customer management, order processing, inventory management, and more. This API uses MongoDB as its database and follows a RESTful architecture.

Getting Started

Prerequisites

  • Node.js (v14.x or higher)
  • npm (v6.x or higher)
  • MongoDB (v4.x or higher)

Installation

Clone the repository:

git clone https://github.com/yourusername/nufacturing-api.git
cd nufacturing-api

Install dependencies:

npm install

Configuration

The API uses environment variables for configuration. Create a .env file in the root directory with the following variables:

PORT=3000
MONGODB_URI=<your-mongodb-uri>
JWT_SECRET=<your-jwt-secret>

Running the Server

To start the server, run:

npm start

The server will start on the port defined in your .env file. By default, it will run on http://localhost:3000.

Project Structure

The project follows a modular structure with separate folders for models, controllers, routes, middleware, and utilities.

nufacturing-api/
├── .env
├── .gitignore
├── README.md
├── app.js
├── package.json
├── src/
│   ├── config/
│   │   ├── db.js
│   │   └── logger.js
│   ├── controllers/
│   │   ├── product-development-controller/
│   │   │   ├── formulaController.js
│   │   │   ├── productSkuController.js
│   │   │   └── productTypeController.js
│   │   ├── sales-controller/
│   │   │   ├── customerController.js
│   │   │   ├── orderController.js
│   │   │   └── quoteController.js
│   │   ├── authController.js
│   │   ├── inventoryController.js
│   │   └── userController.js
│   ├── middleware/
│   │   ├── authMiddleware.js
│   │   └── roleMiddleware.js
│   ├── models/
│   │   ├── product-development-model/
│   │   │   ├── formulasModel.js
│   │   │   ├── productSkuModel.js
│   │   │   └── productTypeModel.js
│   │   ├── sales-model/
│   │   │   ├── customerModel.js
│   │   │   ├── orderModel.js
│   │   │   └── quoteModel.js
│   │   ├── inventoryModel.js
│   │   └── userModel.js
│   ├── routes/
│   │   ├── product-development-routes/
│   │   │   ├── formulaRoutes.js
│   │   │   ├── productSkusRoutes.js
│   │   │   └── productTypeRoutes.js
│   │   ├── sales-routes/
│   │   │   ├── customerRoutes.js
│   │   │   ├── orderRoutes.js
│   │   │   └── quoteRoutes.js
│   │   ├── inventoryRoutes.js
│   │   └── userRoutes.js
│   ├── utils/
│   │   ├── scheduledTasks.js
│   │   └── sendEmail.js
└── swagger.js

API Documentation

Swagger documentation is available for the API. To view the documentation, start the server and navigate to http://localhost:3000/api-docs.

Models

Customer

Manages customer information.

Order

Handles customer orders.

Quote

Manages quotes provided to customers.

InventoryItem

Handles inventory items, including raw materials and finished products.

ProductType

Defines different product types.

ProductSKU

Manages product SKUs.

Routes

Routes are defined for different modules of the application, including product development, sales, inventory, and user management.

Controllers

Controllers contain the logic for handling API requests and responses.

Middleware

Middleware functions are used for authentication and role-based access control.

Utilities

Utility functions include scheduled tasks and email sending functionality.

Environment Setup

The Nufacturing API employs a multi-environment setup to facilitate streamlined development, testing, and deployment. The environments include Local, Development, Testing, Staging, and Production.

Branching Strategy

Branch Types

  • Feature Branches: For new features or enhancements.
  • Hotfix Branches: For urgent fixes.
  • Staging Branch: For pre-production testing.
  • Production Branch: For production deployment.

Branching Rules

  • Enforce Branch Naming Policies: Use Git hooks and GitHub Actions.
  • Commit Message Pattern: Follow conventional commit standards.
  • Pull Requests: Require pull requests for merging into development, staging, and production branches.

Contribution Guidelines

  1. Fork the repository.
  2. Create a new feature branch (git checkout -b feature/NFG-<issue-number>-<short-description>).
  3. Commit your changes with descriptive messages.
  4. Push your branch (git push origin feature/NFG-<issue-number>-<short-description>).
  5. Create a pull request.