Skip to content

Conversation

@yamcodes
Copy link
Contributor

@yamcodes yamcodes commented Apr 17, 2025

Description

Rearranged the architecture into layered architecture.

For context see the added ARCHITECTURE.md file.


PR Checklist

  • Read the Developer's Guide in CONTRIBUTING.md
  • Use a concise title to represent the changes introduced in this PR
  • Provide a detailed description of the changes introduced in this PR, and, if necessary, some screenshots
  • Reference an issue or discussion where the feature or changes have been previously discussed
  • Add a failing test that passes with the changes introduced in this PR, or explain why it's not feasible
  • Add documentation for the feature or changes introduced in this PR to the docs; you can run them with bun docs

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 17, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@github-actions github-actions bot left a comment

Copy link
Contributor

@github-actions github-actions bot left a comment

Copy link
Contributor

@github-actions github-actions bot left a comment

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

Biome

[Biome] reported by reviewdog 🐶

https://github.com/agnyz/bedstack/blob/52cff0031032c2624c9a2805beaecb894552ecb8/src/comments/dto/comment-response.dto.ts#L3-L3


[Biome] reported by reviewdog 🐶

https://github.com/agnyz/bedstack/blob/52cff0031032c2624c9a2805beaecb894552ecb8/src/comments/dto/create-comment.dto.ts#L1-L1


[Biome] reported by reviewdog 🐶

https://github.com/agnyz/bedstack/blob/52cff0031032c2624c9a2805beaecb894552ecb8/src/comments/schema/comment-relations.schema.ts#L1-L1


[Biome] reported by reviewdog 🐶

https://github.com/agnyz/bedstack/blob/52cff0031032c2624c9a2805beaecb894552ecb8/src/comments/schema/comment-relations.schema.ts#L3-L3


[Biome] reported by reviewdog 🐶

https://github.com/agnyz/bedstack/blob/52cff0031032c2624c9a2805beaecb894552ecb8/src/comments/schema/comment-relations.schema.ts#L4-L4


[Biome] reported by reviewdog 🐶

https://github.com/agnyz/bedstack/blob/52cff0031032c2624c9a2805beaecb894552ecb8/src/comments/schema/comments.schema.ts#L2-L2


[Biome] reported by reviewdog 🐶

https://github.com/agnyz/bedstack/blob/52cff0031032c2624c9a2805beaecb894552ecb8/src/comments/schema/comments.schema.ts#L4-L4


[Biome] reported by reviewdog 🐶

https://github.com/agnyz/bedstack/blob/52cff0031032c2624c9a2805beaecb894552ecb8/src/database.providers.ts#L2-L2


[Biome] reported by reviewdog 🐶

https://github.com/agnyz/bedstack/blob/52cff0031032c2624c9a2805beaecb894552ecb8/src/users/users.schema.ts#L4-L4

This was linked to issues Apr 20, 2025
yamcodes added 15 commits June 7, 2025 00:37
…ethods

- Updated article response DTO to encapsulate article details within an 'article' object.
- Refactored articles service methods to improve type handling and ensure consistent article data mapping.
- Removed unused query parameters in article fetching logic for cleaner service calls.
- Enhanced error handling in article creation and update methods to ensure articles are found post-operation.
- Cleaned up comments and organized imports for better code readability.
- Introduced a new mapping function `toFeedResponse` for transforming article data into the feed response format.
- Updated the articles controller to utilize `toFeedResponse` for article data mapping.
- Modified DTO exports to include `article-feed-response.dto` and reorganized existing exports for clarity.
- Changed the author type in the article feed interface to `ProfileFeed` for better alignment with the new response structure.
…handling

- Replaced `articlesPlugin` with `articlesController` in the app module for improved structure.
- Updated article schema imports across various files to maintain consistency.
- Refactored `CommentsRepository` to use a new `CreateCommentDto` type for better clarity and type safety.
- Cleaned up unused imports and comments for enhanced code readability.
- Modified summary descriptions in the articles controller for clarity, changing 'Article Feed' to 'Feed Articles', 'Add Comment to Article' to 'Add Comments to an Article', and 'Get Comments from Article' to 'Get Comments from an Article'.
- Updated the tags plugin summary from 'List Tags' to 'Get Tags' for consistency.
- Adjusted user plugin summaries, changing 'Register' to 'Registeration', 'Login' to 'Authentication', and 'Current User' to 'Get Current User' for improved clarity.
- Moved the article creation endpoint to a new position within the articles controller for improved readability and structure.
- Ensured the endpoint retains its functionality, including user authentication and response formatting.
- Updated the endpoint's summary details to maintain consistency with other routes.
- Replaced `ListArticlesQueryDto` with `ArticleFeedQueryDto` in the articles controller to enhance query handling for the article feed.
- Added a detailed description for the feed articles endpoint, specifying additional query parameters.
- Removed the now obsolete `article-feed-response.dto.ts` file to streamline the DTO structure.
- Updated DTO exports in the index file to reflect the changes.
- Added a detailed description to the 'List Articles' endpoint, outlining the default behavior and available query parameters for filtering results.
- Clarified that authentication is optional and specified the ordering of returned articles.
- Introduced new response mapping functions for articles and comments, enhancing the clarity and consistency of the API responses.
- Removed the obsolete `article.dto.ts` file and updated the `create-article.dto.ts` to eliminate the slug field.
- Enhanced the `ArticlesResponseDto` and `CommentResponseDto` to better encapsulate response structures.
- Updated the comments repository and service to improve type handling and ensure accurate data retrieval.
- Cleaned up imports and organized code for better readability.
- Updated the `toDomain` function to accept an optional `tagList` parameter, allowing for more flexible article data representation.
- Enhanced the article creation process to update the tag list based on the result of the upsert operation.
- Ensured consistent handling of `currentUserId` by using `undefined` instead of `null` for better type safety.
- Simplified tag list handling by destructuring `tagList` from the article object.
- Updated the `upsertArticleTags` method call to improve clarity and maintainability.
- Enhanced the `toDomain` function to include the updated `tagList`, ensuring accurate representation of article data.
- Renamed the `comment` field to `body` in the comment response DTO for clarity.
- Removed the article mapping from the comment response and service, simplifying the data structure.
- Cleaned up unused imports and improved type handling in the comments service.
- Introduced type aliases for `FindFilters` and `FindOptions` to enhance code clarity and maintainability.
- Simplified the parameter destructuring in the `find` method, improving readability and type safety.
- Consolidated multiple CTEs into a single base query for improved readability and performance.
- Simplified the handling of authors, favorites, and tags using coalesce and exists functions.
- Enhanced the overall structure of the query to reduce complexity and improve maintainability.
@yamcodes yamcodes linked an issue Jun 7, 2025 that may be closed by this pull request
4 tasks
- Added a new ConflictError class to handle duplicate article titles.
- Implemented unique slug generation for articles based on the author's username and existing slugs.
- Updated error handling in the errorHandler to include ConflictError with appropriate status codes.
- Improved logging for error codes and statuses in the app module.
@yamcodes yamcodes linked an issue Jun 7, 2025 that may be closed by this pull request
4 tasks
yamcodes added 3 commits June 7, 2025 23:50
- Updated followUser method to accept username as the first parameter for clarity.
- Added a check to prevent following a user that is already followed, throwing a ConflictError if applicable.
- Introduced findFollowByUsers method in ProfilesRepository to check existing follow relationships.
- Enhanced error messages for better user feedback.
- Renamed variables for clarity, changing 'existingFollow' to 'isFollowing'.
- Updated followUser method to prevent following a user if already followed.
- Enhanced unfollowUser method to check if the user is being followed before attempting to unfollow.
- Simplified error handling by removing unnecessary checks and ensuring consistent return values.
- Eliminated console logging of error codes and statuses in the app module to streamline error handling.
- Improved clarity by focusing on setting the appropriate error status without extraneous output.
@yamcodes yamcodes changed the title Layered Architecture Layered Architecture Phase 1 - Articles Jun 7, 2025
@yamcodes yamcodes closed this Jun 7, 2025
@yamcodes yamcodes deleted the layered branch June 7, 2025 19:03
@yamcodes yamcodes changed the title Layered Architecture Phase 1 - Articles Layered (old PR - before branch rename) Jun 7, 2025
@yamcodes yamcodes mentioned this pull request Jun 7, 2025
6 tasks
@yamcodes
Copy link
Contributor Author

yamcodes commented Jun 7, 2025

Renamed branch and continued in #163

aruaycodes pushed a commit that referenced this pull request Jun 14, 2025
### Description

<!-- Provide a comprehensive description here about what your PR aims to
solve. -->

<!-- You may also add additional context -->

- Rearranged the architecture into layered architecture, focusing on
articles (making minimal changes in other features just to support the
articles feature)
- Fixed API summaries to match
https://realworld-docs.netlify.app/specifications/backend/endpoints

For context see [the added ARCHITECTURE.md
file](https://github.com/agnyz/bedstack/blob/3bae8b09298d43d0019bbf1609287790d25c82a5/ARCHITECTURE.md).

Continued from #153 

---

### PR Checklist

<!-- Please do not remove this section -->

<!-- Mark each item with an "x" ([ ] becomes [x]) -->

- [x] Read the Developer's Guide in
[CONTRIBUTING.md](https://github.com/agnyz/bedstack/blob/main/CONTRIBUTING.md)
- [x] Use a concise title to represent the changes introduced in this PR
- [x] Provide a detailed description of the changes introduced in this
PR, and, if necessary, some screenshots
- [x] Reference an issue or discussion where the feature or changes have
been previously discussed
- [x] Add a failing test that passes with the changes introduced in this
PR, or explain why it's not feasible
- [x] Add documentation for the feature or changes introduced in this PR
to the docs; you can run them with `bun docs`


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Introduced a comprehensive, RESTful articles and comments API with
full CRUD operations, authentication, and validation.
  - Added support for article feeds, favoriting, and following authors.
  - Enhanced error handling with more descriptive error responses.
- Implemented new endpoints and DTOs for articles, comments, and user
profiles.

- **Bug Fixes**
- Improved type safety and consistency across data models and API
responses.

- **Documentation**
  - Added detailed architecture and project structure documentation.

- **Refactor**
- Restructured codebase for better modularity, type safety, and
maintainability.
- Replaced and reorganized schema and interface definitions for articles
and comments.

- **Chores**
  - Updated configuration files for linting, formatting, and tooling.
  - Enhanced TypeScript configuration and path aliases.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants