Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding charts in dashboard #51

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

brayn003
Copy link
Owner

@brayn003 brayn003 commented Apr 13, 2024

  • Adds chart view in dashboards

Summary by CodeRabbit

  • New Features

    • Introduced a MarketFeed component for real-time stock data visualization.
    • Added an Overview component displaying key business metrics.
    • Implemented a LinePlot component for rendering line charts.
    • New FastAPI route for listing trading ticks by symbol.
  • Enhancements

    • Dashboard now features tabs for "Market Feed" and "Overview" with dynamic content rendering.
  • Dependency Updates

    • Added d3, lightweight-charts, and their respective types to dependencies for enhanced charting capabilities.
  • Refactor

    • Updated server configurations and route handling for improved data management and retrieval.

Copy link

coderabbitai bot commented Apr 13, 2024

Walkthrough

The project update introduces new components for market data visualization and key metrics display on the dashboard, enhances data handling with new dependencies, and refines backend functionality for data retrieval and management. Significant changes include integration of real-time market feeds, improved charting capabilities, and streamlined data routes for efficient processing.

Changes

File Path Change Summary
.../market-feed.tsx Introduced MarketFeed component for real-time market data visualization using SWRImmutable and lightweight-charts.
.../overview.tsx & .../page.tsx Added Overview component displaying key metrics; updated dashboard page to include new tabs and components.
.../line-plot.tsx New LinePlot component for rendering line charts with D3.
client/package.json & client/pnpm-lock.yaml Updated to include new dependencies like d3 and lightweight-charts, and their types.
server/app/... (multiple files) Backend enhancements including new types, updated route handling, and data management adjustments.

🐇✨
A hop through code, a leap through lines,
New charts and data, all aligned.
With each commit, the dashboard shines,
Metrics and markets, beautifully intertwined.
Celebrate the changes, big and small,
For every line of code, stands tall. 🌟
🐇✨


Recent Review Details

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ab1b825 and 790ae81.
Files selected for processing (11)
  • client/app/private/dashboard/_components/market-feed.tsx (1 hunks)
  • client/app/private/dashboard/_components/overview.tsx (1 hunks)
  • client/app/private/dashboard/page.tsx (2 hunks)
  • client/components/line-plot.tsx (1 hunks)
  • client/package.json (2 hunks)
  • client/pnpm-lock.yaml (12 hunks)
  • server/app/helpers/kite.py (1 hunks)
  • server/app/helpers/types.py (1 hunks)
  • server/app/main.py (2 hunks)
  • server/app/models/tick.py (2 hunks)
  • server/app/routes/tick_routes.py (1 hunks)
Additional comments not posted (25)
server/app/helpers/types.py (1)

5-5: Ensure BeforeValidator is correctly applied to PyObjectId. Typically, BeforeValidator is used with pydantic models to perform actions before validation. If the intention is to validate the format of PyObjectId, consider using a custom validator function.

server/app/routes/tick_routes.py (1)

13-16: Ensure the route handler list_ticks correctly handles potential exceptions from TickManager.list_ticks. Consider adding error handling to manage cases where the tick data cannot be retrieved.

client/components/line-plot.tsx (2)

3-7: Consider adding PropTypes or TypeScript validation for LinePlotProps to ensure data is always an array of numbers. This helps prevent runtime errors if invalid data types are passed.


7-27: Review the D3 setup in LinePlot. Ensure that the scales and line generator are correctly configured for the expected data range and chart dimensions. Consider adding comments to explain the D3 configuration for future maintainability.

client/app/private/dashboard/page.tsx (2)

7-8: Confirm the import paths for MarketFeed and Overview components are correct and that these components are properly exported from their respective modules.


22-28: The integration of MarketFeed and Overview components into the dashboard tabs is well-implemented. Ensure that the components are tested in the context of the entire dashboard to verify that they interact correctly with other components and services.

server/app/main.py (1)

3-9: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [6-36]

The inclusion of tick_routes.router in the application's routers is correctly implemented. Ensure that this new router does not conflict with existing routes and that all routes are correctly secured and perform as expected.

server/app/models/tick.py (1)

61-76: Review the list_ticks method in TickManager for performance and correctness. Ensure that the database query is optimized for large datasets and that appropriate indexes are used to speed up the query. Consider adding error handling to manage potential database errors.

client/package.json (1)

29-30: The addition of d3 and lightweight-charts dependencies, along with their types, is correctly implemented. Ensure that these new dependencies are compatible with the project's existing setup and do not introduce any breaking changes.

Also applies to: 43-43

client/app/private/dashboard/_components/market-feed.tsx (1)

46-94: Review the MarketFeed component for efficiency and correctness. Ensure that data fetching with SWRImmutable is robust, handling errors and loading states appropriately. Additionally, verify that the chart updates smoothly and correctly reflects the data changes.

server/app/helpers/kite.py (6)

1-16: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [11-17]

LGTM! The KiteConfiguration class is well-defined and uses Pydantic effectively for type validation.


Line range hint 18-27: LGTM! The KiteIntegration class correctly utilizes PyObjectId for the id field, ensuring proper type handling.


Line range hint 28-47: LGTM! The KiteNativeSession class is comprehensive and well-structured.


Line range hint 48-72: Consider adding error handling for the Playwright operations in the _automated_login method to ensure robustness in case of failures during the automated login process.


Line range hint 73-91: Consider adding error handling for the KiteConnect API calls and cache operations in the load_session method to ensure robustness in case of API failures or cache issues.


Line range hint 92-104: LGTM! The get_session method is well-implemented and handles session retrieval from the cache effectively.

client/app/private/dashboard/_components/overview.tsx (1)

3-112: LGTM! The Overview function component is well-structured and effectively uses card components to display key metrics.

client/pnpm-lock.yaml (8)

59-64: Ensure the specified versions of d3 and lightweight-charts are compatible with other project dependencies.


97-99: The version update for @types/d3 to 7.4.3 is noted. Verify that this update does not introduce type conflicts with existing D3 implementations in the project.


1402-1584: The addition of detailed resolutions for various @types/d3-* packages is a good practice to ensure version consistency. However, ensure that these versions are compatible with the main d3 package version used.


2212-2216: The update for commander to version 7.2.0 with a specified node engine version of >= 10 is appropriate. Ensure that this does not affect any existing CLI tools that depend on older versions of Node.js.

Verification successful

The verification process did not find any usage of the commander package in the identified directories within the project. This suggests that there are no CLI tools in the project that directly require commander, and therefore, the update to commander version 7.2.0 with a node engine version requirement of >= 10 is unlikely to affect any existing CLI tools in terms of their Node.js version compatibility.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Check for any CLI tools in the project that might be affected by the Node.js engine version requirement of commander 7.2.0
grep -r "commander" ./src | grep "require"

Length of output: 79



Script:

#!/bin/bash
# First, find directories that might contain JavaScript or TypeScript files to locate where `commander` might be used
find . -type f \( -name "*.js" -o -name "*.ts" \) -print | xargs dirname | sort -u

# Then, if directories are found, check for usage of `commander` in those directories

Length of output: 245



Script:

#!/bin/bash
# Check for usage of `commander` in identified directories
grep -r "require(.commander.)" ./client ./tick-workers

Length of output: 56


2237-2484: The updates and additions in the d3-* packages are extensive. It's crucial to ensure that all these packages are used in the project and that there are no redundant dependencies which could increase the bundle size unnecessarily.


2534-2538: The addition of [email protected] with a dependency on robust-predicates is noted. Verify that this package is necessary for the project's functionality, particularly in relation to the d3-delaunay package.

Verification successful

The search across the entire repository for references to delaunator only yielded results in the pnpm-lock.yaml file, indicating that delaunator is not directly used in the source code but is included as a dependency in the package lock file. This suggests that delaunator might be a transitive dependency, possibly through d3-delaunay as initially suspected.

Given this information, it appears that delaunator is not directly necessary for the project's functionality but is included as part of the dependency tree of another package. Therefore, the review comment about verifying the necessity of delaunator in relation to d3-delaunay is consistent with the findings.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Check if delaunator is used directly or only through d3-delaunay
grep -r "delaunator" ./src

Length of output: 65



Script:

#!/bin/bash
# Check if delaunator is used directly or only through d3-delaunay by searching the entire repository
grep -r "delaunator" .

Length of output: 406


3186-3189: The addition of [email protected] is directly related to the lightweight-charts dependency. Confirm that this version of fancy-canvas is compatible with the version of lightweight-charts used.


3778-3782: The dependency [email protected] added under [email protected] is appropriate as it is a required dependency for lightweight-charts. This ensures that the charting library functions correctly.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

router = APIRouter(prefix="/api")


class ListTickseResponse(BaseModel):
Copy link

Choose a reason for hiding this comment

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

Correct the typo in the class name ListTickseResponse to ListTicksResponse.

- class ListTickseResponse(BaseModel):
+ class ListTicksResponse(BaseModel):

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
class ListTickseResponse(BaseModel):
class ListTicksResponse(BaseModel):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant