I developed the backend for the NLW Connect project using Node.js, Fastify, and the Drizzle ORM, creating a referral system for online events. The following routes were implemented: event registration, invitation lookup and redirection to the new user registration based on the referral, counting clicks on the invitation, querying the number of referrals that signed up, checking the current ranking position, and displaying the top 3 users who made the most referrals. The system uses PostgreSQL as the database and Redis.
- 🧭 Table of contents
- 🎥 Implementation Video
- 👏 Learning and more Implementations
- 💡 Technologies Used
- 🚀 Running the Project
- 📝 Routes
- 🌎 License
- ✒ Author
Project.NLW.Connect.-.Referral.system.for.online.events.mp4
The main takeaway was using Redis as a database to store ranking positions, as well as creating Swagger documentation for the routes, using Zod for validation.
- Nodejs
- Fastify
- @fastify/cors
- TypeScript
- zod
- fastify-type-provider-zod
- @fastify/swagger
- @fastify/swagger-ui
- drizzle-orm
- postgres
- ioredis
Clone the project
git clone https://github.com/VagnerNerves/nlw-connect-nodejs-022025.git
Enter the project directory
cd nlw-connect-nodejs-022025
Install with dependencies
npm install
You will need to run Docker and then execute the command to create the PostgreSQL and Redis databases
docker compose up -d
Execute the Drizzle ORM migrate and generate command to create the database and tables
npx drizzle-kit migrate
npx drizzle-kit generate
Create the .env file according to the .env.example file.
Start the server
npm run dev
Now your backend will be running at http://localhost:33333, and you can view and interact with the routes through the Swagger documentation at http://localhost:33333/docs.
Access http://localhost:33333/docs for the route documentation with Swagger.
This project is under the MIT license. See the LICENSE file for more details.
Made with love and hate 😅, get in touch!