Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Latest commit

 

History

History
110 lines (87 loc) · 3.58 KB

README.md

File metadata and controls

110 lines (87 loc) · 3.58 KB

Faketicket

SJTU CS1951 lab assignment

Assignment details: https://github.com/ACMClassCourse-2021/TicketSystem

Getting Started

You need CMake (≥ v3.16) and a C++ compiler capable of C++ 20. We use g++ and clang++. To build the project, run bin/build from the root directory. More details can be found in HACKING.md.

A Node.js binding is available. To build the binding, you need to have a recent version of Node.js and npm, and cmake-js on your $PATH. To build the binding, run bin/build-node from the root directory.

This project runs only on *nix systems (i.e. not Microsoft Windows).

Code Owners

Overall structure: Alan-Liang
Library utilities: Alan-Liang
Misc, Order, User, Parser: Alan-Liang
Rollback, Train: BLeaves
Frontend:
  UI & API Design, Implementation, BFF: BLeaves
  Node-C++ interop: Alan-Liang

Code Structure

lib/ contains library stuff unrelated to business logic. It is written to replace many useful utilities in the C++ STL, and to implement file storage.

src/ contains business logic of the ticket system. The main function performs a Read-Eval-Print Loop (REPL). The node module provides an interface to the Node platform. The command parser parses the command string into command arguments, and main dispatches the command.

Frontend code is to be written in JavaScript utilizing the Vue.js library. A backend-for-frontend (BFF), also written in JavaScript and to be ran in the Node runtime, acts as the intermediary between frontend API calls and the C++ backend. It also serves static assets. Optionally, a reverse proxy could be used to achieve load balancing, HTTPS, logging or other purposes.

The frontend would be a single-page application (SPA). The frontend code would fetch raw data in JSON format from the BFF, and turn it into a DOM structure to be rendered in the browser. Detailed UI/UX design is TBD.

For the detailed code structure, see docs/refman.pdf or https://faketicket-docs-demo.vercel.app/, both generated by Doxygen. They contain the same contents. You can generate these docs by running doxygen in the root directory of this repository.

Database files

  • orders: orders
  • orders.user.ix: index of orders on username
  • orders-pending.ride.ix: index of pending orders on ride (i.e. train ID and date)
  • rollback-log: rollback log
  • trains: trains
  • trains.train-id.ix: index of trains on train ID
  • trains.stop.ix: index of trains on station names
  • ride-seats: remaining seat count information
  • ride-seats.ride.ix: index of ride-seats on ride
  • users: users
  • users.username.ix: index of users on username

Checklist when adding/removing files

  • Add/Remove the file::File instance
  • Update the list above
  • Update command::Clean in src/misc.cpp

Data flow

+-----------------------------------------+
|  Filesystem                      Server |
|     ^                                   |
|     | Filesystem APIs                   |
|     v                                   |
| C++ "./code"                            |
|     ^                                   |
|     | Node-API                          |
|     v                                   |
| BFF (Backend for frontend)       Server |
+-----^-----------------------------------+
|     | http(s)                   Network |
+-----v-----------------------------------+
|  Browser                         Client |
+-----------------------------------------+

License

SPDX-License-Identifier: GPL-3.0-or-later