Backend Development 14 min read

Backend Technology Selection for a Low‑Code Poster Platform

This article explains the backend technology choices for a low‑code poster platform, covering Node.js framework selection, database decisions (MySQL, MongoDB, Redis), authentication methods (Session vs JWT), and unit/integration testing tools such as Mocha, SuperTest, and related code examples.

Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Backend Technology Selection for a Low‑Code Poster Platform

This article, originally published in the Rare Earth Juejin technical community, details the backend technology selection for a low‑code poster platform, focusing on framework, database, authentication, and testing choices.

Framework Selection

The team evaluated three criteria: the application scenario (REST API), team expertise (familiarity with Koa2 and Express), and industry trends. Considering these factors, they chose koa2 as the Node.js framework because it offers a lightweight, expressive architecture built by the same team that created Express, and it simplifies asynchronous flow with co and generator .

Database Selection

For structured work metadata, a relational database is preferred, so MySQL is used; for unstructured JSON‑like content, MongoDB is chosen; and Redis serves as an in‑memory cache for high‑concurrency scenarios.

MySQL is a relational DBMS that stores data in tables. The project uses the Sequelize ORM to interact with MySQL:

const result = await UserModel.findOne({
    where: { id }
});
const result = await UserModel.findAndCountAll({
    order: [["id", "desc"]],
    where: whereOpt,
});
const result = await UserModel.create(data);
const result = await UserModel.update(data, {
    where: { username },
});

MongoDB is a document‑oriented database that stores JSON‑like objects. The project uses the mongoose ODM for Node.js:

const newContent = await WorkContentModel.create({
    components,
    props,
    setting,
});
const content = await WorkContentModel.findById(contentId);
await WorkContentModel.findByIdAndUpdate(contentId, {
    components: content.components || [],
    props: content.props || {},
    setting: content.setting || {},
});

Redis is an open‑source, in‑memory key‑value store used as a cache to improve read performance in high‑traffic situations.

Login Verification

The article compares two common authentication mechanisms: Session (server‑side state) and JWT (stateless token). Session stores data on the server and uses cookies, offering easy revocation but poor cross‑domain support. JWT encodes user information in a signed JSON object, enabling stateless RESTful APIs but relying on token expiration for revocation.

Example JWT payload:

{
  "name": "Forest",
  "role": "BrickMover",
  "expires": "2022-11-09 19:09"
}

The implementation uses the jsonwebtoken npm package.

Unit and Interface Testing

For backend testing, the team adopts Mocha as the primary test framework. A simple unit test for an addition function looks like:

function add(a, b) {
    return a + b;
}
var assert = require('assert');
describe('Calculator', function() {
  describe('#add()', function() {
    it('should get 3 when 1 add 2', function() {
      assert.equal(3, add(1, 2));
    });
  });
});

For HTTP endpoint testing, the article shows two approaches: using Node's native http module and assert , and using SuperTest for a more concise syntax.

require('../server.js');
var http = require('http');
var assert = require('assert');
it('should return hi cosen', function(done) {
  http.get('http://localhost:8000', function(res) {
    res.setEncoding('utf8');
    res.on('data', function(text) {
      assert.equal(res.statusCode, 200);
      assert.equal(text, 'hi cosen');
      done();
    });
  });
});
var request = require('supertest');
var server = require('../server.js');
var assert = require('assert');
it('should return hi cosen', function(done) {
  request(server)
    .get('/')
    .expect(200)
    .expect(function(res) {
      assert.equal(res.text, 'hi cosen');
    })
    .end(done);
});

In summary, the article outlines the rationale behind choosing Koa2, MySQL + Sequelize, MongoDB + Mongoose, Redis for caching, JWT for stateless authentication, and Mocha/SuperTest for testing, setting the foundation for the platform's backend architecture.

BackendRedisMySQLJWTMongoDBnodejskoa2mocha
Rare Earth Juejin Tech Community
Written by

Rare Earth Juejin Tech Community

Juejin, a tech community that helps developers grow.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.