ZaydSkaff 8503ee728d Refactor/space management (#404)
* refactor: reducing used queries on get communities (#385)

* refactor: fix create space logic (#394)

* Remove unique constraint on subspace and product in SubspaceProductAllocationEntity; update product relation to nullable in NewTagEntity

* refactor: fix create space logic

* device model updated to include the fixes and final columns

* updated space models to include suggested fixes, update final logic and column names

* task: removing old references of the old tag-product relation

* task: remove old use of tags

* task: remove old tag & tag model usage

* refactor: delete space

* task: remove unused functions

* fix lint rule
2025-06-11 13:15:21 +03:00
2025-03-02 00:23:59 +04:00
2024-03-13 07:28:10 -04:00
2025-06-11 13:15:21 +03:00
2024-03-13 07:28:10 -04:00
2025-02-19 13:10:28 +04:00
2024-02-27 04:34:01 +03:00
2024-03-11 19:09:16 -04:00
2024-07-31 22:26:51 +03:00
2025-04-23 10:56:03 +04:00
2025-06-11 13:15:21 +03:00
2024-04-24 13:50:33 +03:00
2024-02-12 23:28:26 +03:00
2024-02-26 11:23:44 +05:30

Backend

Overview

This is the backend for an IoT application built using NestJS. It interfaces with the Tuya IoT cloud platform to manage homes, rooms, devices, ...etc. This is the backend APIs project, developed with NestJS for Syncrow IOT Project.

Database Model

The database uses PostgreSQL and TypeORM. Below is an entity relationship diagram:

The main entities are:

User - Stores user account information Home - Represents a home/space Room - Represents a room/sub-space Device - Represents a connected device Product - Stores metadata about device products Other Entities - sessions, OTPs, etc.

The entities have a one-to-many relationship - a user has multiple homes, a home has multiple rooms, and a room has multiple devices.

Architecture

The application is deployed on Azure App Service using Docker containers. There are separate deployment slots for development, staging, and production environments.

Installation

First, ensure that you have Node.js v20.11 or newer (LTS ONLY) installed on your system.

To install the project dependencies, run the following command in the project root directory:

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

ERD Diagram

Syncrow ERD Digram

Architecture

                                   +----------------------------------+
                                   |                                  |
                                   |         Applications             |
                                   |                                  |
     +-----------------------------+-------------+--------------------+
     |                                             |                   |
     |                                             | API Calls         |
     |                                             |                   |
     |                                             v                   |
     |            +---------------------+------------------------+     |
     |            |                     |                        |     |
     |            |     Dev Slot        |     Staging Slot       |     |
     |            |                     |                        |     |
     |            +---------------------+------------------------+     |
     |                     |                          |                |
     |                     |                          |                |
     |                     |                          |                |
     |            +------------------+       +---------------------+     |
     |            |  Dev Database    |       |  Staging Database   |     |
     |            +------------------+       +---------------------+     |
     |                                                                 |
     |              +-----------------------------------------+        |
     |              |                                         |        |
     |              |                Production               |        |
     |              |                                         |        |
     |              +-----------------------------------------+        |
     |                     |                          |                |
     |                     |                          |                |
     |                     |                          |                |
     |            +------------------+                |                |
     |            | Production DB    |                |                |
     |            | Highly Available |                |                |
     |            |     Cluster      |                |                |
     |            +------------------+----------------+                |
     |            |  Production DB   |                |                |
     |            |  Standby Node    |                |                |
     |            +------------------+                |                |
     |            |  Production DB   |                |                |
     |            |  Standby Node    |                |                |
     |            +------------------+                |                |
     |            |  Production DB   |                |                |
     |            |  Standby Node    |                |                |
     |            +------------------+----------------+                |
     +-----------------------------------------------------------------+
Description
The backend APIs for Syncrow
Readme 8.3 MiB
Languages
TypeScript 98%
PLpgSQL 1.6%
HTML 0.3%