{"id":19867067,"url":"https://github.com/azurespheredev/digication-work-sample","last_synced_at":"2025-02-28T23:45:06.064Z","repository":{"id":248583021,"uuid":"828974528","full_name":"azurespheredev/Digication-Work-Sample","owner":"azurespheredev","description":"✔ My technical solution for developing React DnD frontend and portfolio management backend using React, TypeScript, GraphQL and SQLite database..","archived":false,"fork":false,"pushed_at":"2024-11-01T18:11:11.000Z","size":3257,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-11T15:50:18.129Z","etag":null,"topics":["graphql","nodejs","react","react-dnd","sqlite","typeorm","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/azurespheredev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-15T13:54:55.000Z","updated_at":"2024-11-01T18:11:16.000Z","dependencies_parsed_at":"2024-11-12T10:58:35.348Z","dependency_job_id":null,"html_url":"https://github.com/azurespheredev/Digication-Work-Sample","commit_stats":null,"previous_names":["azuresphere7/digication-work-sample","blitzsprinter/digication-work-sample","azurespheredev/digication-work-sample"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azurespheredev%2FDigication-Work-Sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azurespheredev%2FDigication-Work-Sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azurespheredev%2FDigication-Work-Sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azurespheredev%2FDigication-Work-Sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azurespheredev","download_url":"https://codeload.github.com/azurespheredev/Digication-Work-Sample/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241278754,"owners_count":19938019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","nodejs","react","react-dnd","sqlite","typeorm","typescript"],"created_at":"2024-11-12T15:28:14.459Z","updated_at":"2025-02-28T23:45:06.023Z","avatar_url":"https://github.com/azurespheredev.png","language":"TypeScript","readme":"# Digication Work Sample\n\nThank you for inviting me to this exciting assessment process and would love to submit my technical solution for your review. I have implemented versioning entities and APIs in managing portfolios and pages in the backend and extended the algorithm by ensuring grid layout system with specific movement and collision requirements provided.\n\n## Backend: TypeScript, GraphQL, TypeORM\n\n### Data Models\n\n- **Portfolio**: Contains fields `id`, `name`, and `url`.\n- **Page**: Contains fields `id`, `name`, `url`, and a reference to the `PortfolioVersion` it belongs to.\n- **PortfolioVersion**: Contains fields `id`, `type`, and references to `Portfolio` and `Pages`.\n\n### Relationships\n\n- A `Portfolio` can have multiple `PortfolioVersions`.\n- A `PortfolioVersion` can have multiple `Pages`.\n- A `Page` belongs to exactly one `PortfolioVersion`.\n\n### Versioning of Pages\n\nTo support versioning, I introduced a new `PortfolioVersion` entity. This entity allows for multiple versions of a set of pages, including `DRAFT`, `PUBLISHED`, and `SNAPSHOT` versions.\n\n### Implementation\n\n1. **Entity Modifications**:\n\n   - Updated `PortfolioEntity` to include a one-to-many relationship with `PortfolioVersionEntity`.\n   - Updated `PortfolioVersionEntity` to include a one-to-many relationship with `PageEntity`.\n\n2. **Cascade Deletions**:\n\n   - Configured cascading delete rules to ensure related entities are deleted when a portfolio is deleted.\n   - Added manual deletion logic in the `deletePortfolio` mutation to handle the constraints properly.\n\n3. **Resolvers**:\n   - Implemented queries and mutations to create versions, move pages between versions, and fetch versions and pages.\n   - Included detailed error handling and validations.\n\n### Queries and Mutations\n\n- **Queries**:\n\n  - `listPortfolios`: Fetch all portfolios with their versions.\n  - `listPages`: Fetch all pages algonside their versions.\n  - `getPortfolio`: Fetch a specific portfolio by ID with its versions.\n  - `getPage`: Fetch a specific page by ID.\n  - `listPortfolioVersions`: Fetch all versions of a portfolio.\n  - `listPagesByVersion`: Fetch all pages of a specific version.\n\n- **Mutations**:\n  - `createPortfolio`: Create a new portfolio.\n  - `createPage`: Create a new page in the draft version.\n  - `createPublishedVersion`: Create a published version from the draft version.\n  - `createSnapshotVersion`: Create a snapshot version from the draft version.\n  - `updatePortfolio`: Update a portfolio by ID\n  - `updatePage`: Update a portfolio by ID\n  - `deletePortfolio`: Delete a portfolio along with its versions and pages.\n  - `deletePage`: Delete a portfolio along with its versions and pages.\n\n### Testing\n\nI used Jest for unit testing to make sure that all functionalities work as expected. I also created additional test helpers including creating portfolios, versions, moving pages between versions and deleting portfolios along with their related entities.\n\n\u003cimg alt=\"backend_test_result\" src=\"./screenshots/backend_test_result.jpg\" /\u003e\n\n## Frontend: TypeScript, React, Drag \u0026 Drop\n\n### Definition\n\n1. **Layout container**: A 12-column grid layout with 10px gutter size. The container can contain multiple module objects.\n2. **Module**: A rectangle object with boundary properties relative to the layout container.\n3. **Module boundary properties**:\n   - **x**: The left coordinate value of the module relative to the layout container.\n   - **y**: The top coordinate value of the module relative to the layout container.\n   - **w**: The width of the object in grid columns.\n   - **h**: The height of the object in pixels.\n\n### Implementation\n\n1. **Drag and Drop**:\n\n   - Implemented module movement using the HTML Drag and Drop API.\n   - Ensured modules snap to the grid column units.\n\n2. **Collision Detection**:\n   - Implemented logic to detect and prevent module overlaps.\n   - Maintained the required gutter size between modules.\n\n### Testing\n\n- Ensured modules can move within the layout container and snap to the grid.\n- Verified that modules do not overlap and maintain the required gutter size.\n\n\u003cimg alt=\"frontend_test_result\" src=\"./screenshots/frontend_test_result.jpg\" /\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazurespheredev%2Fdigication-work-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazurespheredev%2Fdigication-work-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazurespheredev%2Fdigication-work-sample/lists"}