S
API Service2026CompletedFeatured Project

Billcraft Server

Business Billing Suite - ServerNirman Bahi Khata Pro - Server A production-ready Node.js backend for billing and inventory management with JWT authentication, role-based access con...

RoleSole Developer
Classificationhigh
Client / ContextOpen Source Project
Development TimelineCompleted

Technical Architecture & Engineering Overview

Detailed system design and core implementation

Core Architecture

The server follows a classic micro‑service style, with a single Express application exposing a set of RESTful routes grouped by domain: auth, products, customers, shops, and bills. Each route file delegates business logic to a dedicated controller, keeping the routing layer thin and the controllers focused on orchestrating data access via Mongoose models.

Data Ingestion & Persistence

All domain entities are persisted in a MongoDB Atlas cluster named construction_billing. Mongoose schemas enforce field types, required constraints, and custom validation logic. The application uses a soft delete strategy for products, customers, shops, and bills, marking records with an isActive flag instead of physically removing them, which preserves historical data for audit and reporting.

Execution Flow

A typical request follows this pipeline: the request hits an Express route, passes through AuthMiddleware (token verification, role checks, and rate limiting), then ValidationMiddleware (schema validation via validator), and finally the controller performs the requested CRUD operation. Responses are sent with standardized JSON payloads, and errors are caught by a global error‑handling middleware that logs details via morgan and returns a sanitized error message.

Security Guardrails & Build Topology

Security is layered: helmet sets secure HTTP headers, cors restricts origins, express‑rate‑limit throttles authentication endpoints, and JWTs are signed with a secret stored in environment variables. The build topology is simple: the start script runs node index.js, while dev uses nodemon for hot reloading. Deployment instructions in DEPLOYMENT.md outline a CI‑CD pipeline that builds the Docker image, pushes to a registry, and deploys to a cloud provider, with the frontend served from Vercel, Netlify, or Render.

System Diagrams & Flow Visualizations

Interactive Mermaid architecture & execution flows

Architectural Visualizer · System Architecture

Core System Features

Key capabilities & architectural features

FEATURE 01

JWT authentication with role‑based access control

JWT authentication with role‑based access control

FEATURE 02

Rate limiting on authentication endpoints

Rate limiting on authentication endpoints

FEATURE 03

Soft delete strategy for all domain entities

Soft delete strategy for all domain entities

FEATURE 04

Meta endpoints for product categories and brands

Meta endpoints for product categories and brands

FEATURE 05

Shop analytics and shop‑wise analysis endpoints

Shop analytics and shop‑wise analysis endpoints

FEATURE 06

Pagination and filtering for shop listings

Pagination and filtering for shop listings

FEATURE 07

Structured logging with Morgan

Structured logging with Morgan

FEATURE 08

Security headers via Helmet and CORS protection

Security headers via Helmet and CORS protection

FEATURE 09

Environment‑based configuration with dotenv

Environment‑based configuration with dotenv

FEATURE 010

CLI scripts for creating admin and shop users

CLI scripts for creating admin and shop users

Engineering Challenges & Solutions

Problem statements & resolution strategies

Challenge #1

Balancing security and usability while implementing rate limiting on login routes

Balancing security and usability while implementing rate limiting on login routes

Challenge #2

Designing a soft delete mechanism that preserves historical data without cluttering queries

Designing a soft delete mechanism that preserves historical data without cluttering queries

Challenge #3

Ensuring consistent error handling across all controllers and middleware

Ensuring consistent error handling across all controllers and middleware

Challenge #4

Managing environment variables securely for JWT secrets and DB connection strings

Managing environment variables securely for JWT secrets and DB connection strings

Challenge #5

Optimizing shop analytics queries to aggregate data efficiently

Optimizing shop analytics queries to aggregate data efficiently

API Reference & Endpoints

REST API surface & route documentation

METHODENDPOINT PATHDESCRIPTIONCOPY
GET/Endpoint defined in index.js
GET/healthEndpoint defined in index.js
POST/admin/registerEndpoint defined in routes/auth.js
POST/admin/loginEndpoint defined in routes/auth.js
POST/shop/loginEndpoint defined in routes/auth.js
POST/refreshEndpoint defined in routes/auth.js
POST/logoutEndpoint defined in routes/auth.js
GET/profileEndpoint defined in routes/auth.js
PUT/change-passwordEndpoint defined in routes/auth.js
GET/verifyEndpoint defined in routes/auth.js
GET/number/:billNumberEndpoint defined in routes/bills.js
GET/:idEndpoint defined in routes/bills.js
POST/Endpoint defined in routes/bills.js
PUT/:idEndpoint defined in routes/bills.js
DELETE/:idEndpoint defined in routes/bills.js
POST/update-pending-amountsEndpoint defined in routes/customers.js
GET/analyticsEndpoint defined in routes/dashboard.js
GET/shop-wise-analysisEndpoint defined in routes/dashboard.js
GET/shop-analytics/:shopIdEndpoint defined in routes/dashboard.js
GET/meta/categoriesEndpoint defined in routes/products.js
GET/meta/brandsEndpoint defined in routes/products.js
GET/:shopIdEndpoint defined in routes/shops.js
PUT/:shopIdEndpoint defined in routes/shops.js
DELETE/:shopIdEndpoint defined in routes/shops.js

Key Code Modules & Architecture

Core file entrypoints and service responsibilities

ConfigMODULE 01
config

Module component managing config source logic

ControllersMODULE 02
controllers

Module component managing controllers source logic

MiddlewareMODULE 03
middleware

Module component managing middleware source logic

ModelsMODULE 04
models

Module component managing models source logic

RoutesMODULE 05
routes

Module component managing routes source logic

ScriptsMODULE 06
scripts

Module component managing scripts source logic

ServicesMODULE 07
services

Module component managing services source logic

UtilsMODULE 08
utils

Module component managing utils source logic

User Journey Pipeline

  1. 1User Access & Preset Selection: User opens client interface and configures request parameters or task workflow presets.
  2. 2Client Payload Dispatch: Front-end components (React) serialize input objects and send HTTP/WebSocket requests to `/`.
  3. 3Middleware & Validation Check: API Gateway evaluates CORS headers, authorization tokens, and input validation schemas.
  4. 4Service & Inference Execution: Service controllers dispatch request frames to model inference engine (Local Engine) or storage layer.
  5. 5Response Delivery & State Synchronization: Serialized output payload is returned to the client and rendered in the visual workspace.

Execution Code Flow

  1. 1Client or caller initiates request to application entrypoint
  2. 2Backend router validates request parameters and applies middleware
  3. 3Database ORM/client executes storage query
  4. 4Application serializes JSON/audio/data response back to client

System FAQ & Technical Specifications

Frequently asked questions and core architecture details

Q: What technologies are used in Billcraft Server?

Billcraft Server is engineered using modern full-stack frameworks.

Q: What core engineering problem does Billcraft Server solve?

Business Billing Suite - ServerNirman Bahi Khata Pro - Server A production-ready Node.js backend for billing and inventory management with JWT authentication, role-based access con...

Q: How is 'Balancing security and usability while implementing rate limiting on login routes' resolved in Billcraft Server?

Resolved through specialized system architecture and resilient state handling.

Related Systems & Case Studies

Explore similar technical architectures and projects

View All Systems