Version based API - Pushed here before the 5000 and 8000

This commit is contained in:
2025-06-21 15:16:52 +05:30
parent dead851b1a
commit 3ec45276f4
114 changed files with 7547 additions and 1436 deletions

View File

@@ -0,0 +1,172 @@
DWINZO-BETA-BACKEND
Repository Structure:
DWINZO_BACKEND/
├── .gitignore
├── package.json
├── .env
└── src/
├── api-server/
│ │
│ └── controller/
│ ├─── Routes/
│ ├── V1
│ │ └── v1Controllers/
│ │ ├── v1Routes/
│ ├─── app.ts
│ ├─── main.ts
├── shared
│ │
│ └── connect/
│ ├─── middleware/
│ ├─── model/
│ ├─── redis/
│ ├─── services/
│ ├─── swagger/
│ ├─── utils/
│ ├─── V1Models/
├── socket-server
│ │
│ └── controllers/
│ ├─── manager/
│ ├─── services/
│ ├─── socket/
│ ├─── utils/
│ ├─── index.ts
VERSION CONTROL MODULE:
The Version Control Module is a backend system component designed to track, store, and manage multiple versions of data entities (such as scenes, assets, layouts, or entire projects). It enables developers and users to:
- View the historical state of an entity.
- Restore previous versions.
- Audit changes over time.
- Enable branching workflows like clone and rollback.
TECH STACK:
Language: Typescript
Framework: Express.js
Database: Mongodb
Architecture FOR API:
Entry Point:
- src/api-server/main.js starts the server and runs the main application.
- src/api-server/app.js sets up the Express app, middleware, and routes.
Components:
- src/api-server/V1/ (controllers, routes).
- src/shared/services/ (Service logics).
Utils:
- src/shared/utils/ contains Express middleware functions (e.g., hashing,tokenDatas).
Database:
- src/shared/connect/ handles database configuration and connection logic.
Models:
- src/shared/V1Models/ handles mongo schema structure and datatype.
Routing for Version:
________________________________________________________________________________________________
|Method | Routing | Description |
|__________|___________________________________|________________________________________________|
|POST | /generateVersion | Create New version |
|__________|___________________________________|________________________________________________|
|POST | /version/rollback | Version Rollback for the previous version |
|__________|___________________________________|________________________________________________|
|GET | /:projectId/versions | Project based Version histories |
|__________|___________________________________|________________________________________________|
|GET | /version/:versionId/:projectId | Get a Version Datas |
|__________|___________________________________|________________________________________________|
NEW VERSION instructions:
Request Datas:
- userId, organization from the User authenticationtoken.
- hierarchyVersion(parentVersion),description,projectId,createdBy(userId) from the body data.
LOGIC:
- checking for the valid userId,projectId and parentVersion.
- checking for the PreviousVersion based on the project.
- NewVersion Creation based on th PreviousVersion and parentVersion.
- Cloning for the previousVersion Datas(Scenes,asset,etc.) for the newVersion.
- Update the project data based on the latestVersion.
Response Datas:
- Http response with status code of 404 for User not found, Project not found and Parent Version not found.
- Http response with status code of 200 with Newversion unique Id(mongo _id).
- Http response with status code of 500 for Internal server error and Unknown error.
ROLL BACK instructions:
Request Datas:
- userId, organization from the User authenticationtoken.
- projectId,versionId from the body data.
LOGIC:
- checking for the valid userId,projectId and versionId(rollback versionId).
- checking for the PreviousVersion based on the project.
- NewVersion Creation based on th PreviousVersion and parentVersion(rollback versionId).
- Cloning for the parentVersion(rollback versionId) Datas(Scenes,asset,etc.) for the newVersion.
- Update the project data based on the latestVersion.
Response Datas:
- Http response with status code of 404 for User not found, Project not found and Mentioned Version not found for the Rollback.
- Http response with status code of 200 with Newversion unique Id(mongo _id) and message:"Rollback successfull".
- Http response with status code of 500 for Internal server error and Unknown error.
VERSION HISTORY instructions:
Request Datas:
- userId, organization from the User authenticationtoken.
- projectId params data.
- page,limit query data.
LOGIC:
- checking for the valid userId,projectId.
- fetching the allversions based on projectId for the Total count.
- filtering total project versions based on the sorting,limit and page.
- After filtering finalResponse with metaDatas like total count,page,limit and hasNextPage is provided
Response Datas:
- Http response with status code of 404 for User not found, Project not found and Mentioned Version not found for the Rollback.
- Http response with status code of 200 for Version History Datas.
- Http response with status code of 200 for Versions not found with empty Array[].
- Http response with status code of 500 for Internal server error and Unknown error.
PARTICULAR VERSION DATA instructions:
Request Datas:
- userId, organization from the User authenticationtoken.
- projectId,versionId params data.
LOGIC:
- checking for the valid userId,projectId.
- checking for the versionId based on the project.
- For existingVersion Fetching all the Builder, Simulation, RTViz datas based on the projectId and versionId
Response Datas:
- Http response with status code of 404 for User not found, Project not found and Mentioned Version not found for the Rollback.
- Http response with status code of 200 for Version based Datas.
- Http response with status code of 200 for Versions not found with empty Array[].
- Http response with status code of 500 for Internal server error and Unknown error.