56 lines
2.6 KiB
Plaintext
56 lines
2.6 KiB
Plaintext
---
|
|
title: How it works
|
|
description: 'Learn the architecture of the project'
|
|
---
|
|
|
|
The entire project is built under [NX](https://nx.dev/) to have a monorepo with multiple projects.<br /><br />
|
|
Unlike other NX project, this project has one `.env` file that is shared between all the apps.<br />
|
|
It makes it easier to develop and deploy the project.<br /><br />
|
|
When deploying to websites like [Railway](https://railway.app) or [Heroku](https://heroku.com), you can use a shared environment variables for all the apps.<br /><br />
|
|
|
|
**At the moment it has 6 projects:**
|
|
|
|
- [Frontend](#frontend) - Provides the Web user interface, talks to the Backend.
|
|
- [Backend](#backend) - Does all the real work, provides an API for the frontend, and posts work to the redis queue.
|
|
- [Workers](#worker) - Consumes work from the Redis Queue.
|
|
- [Cron](#cron) - Run jobs at scheduled times.
|
|
- [Docs](#docs) - This documentation site!
|
|
|
|
<img
|
|
src="/images/arch.png"
|
|
alt="Architecture of Gitroom"
|
|
/>
|
|
|
|
## Architecture
|
|
### Frontend
|
|
The frontend is built with [NextJS](https://nextjs.org/) and [TailwindCSS](https://tailwindcss.com/).<br />
|
|
It works directly with the Backend to:
|
|
- Show analytics
|
|
- Schedule posts
|
|
- Manage users
|
|
|
|
### Backend
|
|
The backend is built with [NestJS](https://nestjs.com/) with a basic architecture of controllers, services, repositories and dtos.<br /><br />
|
|
It uses [Prisma](https://www.prisma.io/) as an ORM to interact with the database.<br />
|
|
By default Prisma uses [Postgres](https://www.postgresql.org/) as a database, but it can be easily changed to any other database since there are no native queries.<br /><br />
|
|
It uses Redis to schedule posts and run background jobs.
|
|
|
|
### Cron
|
|
The backend is built with [NestJS](https://nestjs.com/) and share components with the backend.<br />
|
|
At the moment the use of the cron is:
|
|
- Refresh tokens from different social media platforms.
|
|
- Check for trending change every hour and inform users about it.
|
|
- Sync the amount of stars for every repository at the end of the day.
|
|
|
|
### Worker
|
|
The backend is built with [NestJS](https://nestjs.com/) and share components with the backend.<br />
|
|
At the moment the use of the worker is:
|
|
- Post scheduled posts to social media platforms.
|
|
- Perform multiple jobs coming from the cron.
|
|
|
|
### Docs
|
|
The documentation website is built with [Mintlify](https://www.mintlify.com/).<br />
|
|
The reference in the documentation is being auto-generated by the backend.<br />
|
|
NestJS has a built-in Swagger module that generates a JSON file with all the routes and their documentation.<br />
|
|
It makes it very easy to track API changes and deploy them.
|