**Please Note**: This application is hosted on a free web service provider that may become idle after 15 seconds of inactivity. To ensure a smooth user experience, some redemption events have been pre-filled. If you don't see any events initially, please wait for about a minute for the server to restart. Thank you for your patience and understanding!
React Frontend Client Documentation can be seen here.
- Backend: NestJS for REST API
- Swagger: API Documentation
- Database: PostgreSQL for data storage
- Staff pass ID will not be longer than 100 characters
- Team name will not be longer than 45 characters
- Event name will not be longer than 45 characters
NestJS uses TypeScript and that allows us to write safe and robust code with early detection of possible type errors. NestJS also comes with middleware validation pipelines to intercept incoming request and apply our preprocessing logic and validation before they reach the controllers.
Swagger allows you to describe the structure of your APIs and automatically build interactive API documentation that can be used for early testing before a frontend is built.
Initially I started with MySQL as it was one of the more common databases. However, I wanted to host the website so that you will be able to interact with it without having to download everything. Since, I found a free provider that allows me to host my web service with their PostgresSQL for free, I decided to move to PostgresSQL.
If you would like to run the web service on your machine,
-
Clone the repository
-
Install the dependencies using
npm install -
Change
.envaccordinglyPGUSER=USER PGPASSWORD=DB_PASSWORD NODE_ENV=production PGHOST=DB_HOST PGDB=DB_NAME PGPORT=DB_PORT -
Start the web service locally using
npm run start
This is the Entity Relationship Diagram (ERD) for the project's database.
If you would like to recreate the following tables you can use the following SQL query
CREATE DATABASE gift_redemption;
CREATE TABLE events (
event_id SERIAL PRIMARY KEY,
event_name VARCHAR(45) DEFAULT NULL,
created_at TIMESTAMP DEFAULT NULL
);
CREATE TABLE redemption (
redemption_id SERIAL PRIMARY KEY,
redeemed_at TIMESTAMP DEFAULT NULL,
team_name VARCHAR(45) DEFAULT NULL,
event_id INT DEFAULT NULL,
FOREIGN KEY (event_id) REFERENCES events(event_id)
);
CREATE TABLE staffs (
staff_pass_id VARCHAR(100) PRIMARY KEY,
team_name VARCHAR(45) DEFAULT NULL,
created_at TIMESTAMP DEFAULT NULL
);Of course, no software will be complete without automated testing! We can create AAA quality tests by following the AAA principle which is, Arrange-Act-Assert. Each module should have their own spec file.
You can run Jest and test each service by,
- Running
npm test match <MODULE.SERVICE.SPEC.TS>in the root directory
For example,
npm test match staffs.service.spec.ts
npm test match events.service.spec.ts
npm test match redemption.service.spec.ts
You can write similar tests by following this example.
it('should return "redeemed successfully" if not already redeemed', async () => {
// arrange
const assert = { status: HttpStatus.CREATED, response: 'Team RUST redeemed successfully!!' };
const data = { event_id: 1, staff_pass_id: 'BOSS_T000000001P' };
// act
const act = await service.create(data);
// assert
expect(act).toEqual(assert);
});If you would like to add or build on top of this project, the important files are stored in the following file structure.
├── ...
├── src
│ ├── events
│ │ ├── dto
│ │ ├── entities
│ │ ├── models
│ │ ├── events.controller.ts
│ │ ├── events.module.ts
│ │ ├── events.service.spec.ts
│ │ └── events.service.ts
│ ├── redemption
│ │ ├── dto
│ │ ├── entities
│ │ ├── redemption.controller.ts
│ │ ├── redemption.module.ts
│ │ ├── redemption.service.spec.ts
│ │ └── redemption.service.ts
│ ├── staffs
│ │ ├── dto
│ │ ├── entities
│ │ ├── staffs.controller.ts
│ │ ├── staffs.module.ts
│ │ ├── staffs.service.spec.ts
│ │ └── staffs.service.ts
│ ├── app.controller.ts
│ ├── app.module.ts
│ ├── app.service.ts
│ ├── main.ts
│ └── TestingConnectionModule.ts
└── ...
Documentation for technologies used can be found in the following links.
Thank you for taking your time to look through my project! Hope you enjoyed it as much as I did during the development of this project!
Feel free to contact me to discuss any issues, questions or comments.






