Skip to content

Conversation

@devakesu
Copy link
Owner

@devakesu devakesu commented Feb 8, 2026

Implement EzyGo API Batch Fetcher with Rate Limiting and Circuit Breaker

  • Added EzyGo API Batch Fetcher to optimize concurrent API calls.
  • Implemented request deduplication using LRU cache with a 15-second TTL.
  • Introduced rate limiting to restrict concurrent requests to a maximum of 3.
  • Integrated a circuit breaker pattern to handle API failures gracefully.
  • Created health check endpoint to monitor rate limiter and circuit breaker status.
  • Developed comprehensive documentation for rate limiting and verification processes.
  • Ensured client-side hooks and server-side calls are protected against rate limiting.

- Added EzyGo API Batch Fetcher to optimize concurrent API calls.
- Implemented request deduplication using LRU cache with a 15-second TTL.
- Introduced rate limiting to restrict concurrent requests to a maximum of 3.
- Integrated a circuit breaker pattern to handle API failures gracefully.
- Created health check endpoint to monitor rate limiter and circuit breaker status.
- Developed comprehensive documentation for rate limiting and verification processes.
- Ensured client-side hooks and server-side calls are protected against rate limiting.
Copilot AI review requested due to automatic review settings February 8, 2026 11:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces an EzyGo batching layer to reduce upstream load (dedupe + concurrency limiting) and adds a circuit breaker with monitoring, while also updating the dashboard to SSR-prefetch and hydrate client queries. It also includes a number of UI/CSS refactors, documentation additions, CI hardening (OSSF Scorecard), and a version bump to v1.5.0.

Changes:

  • Add an in-memory request deduper + global concurrency limiter for EzyGo requests and integrate a circuit breaker.
  • SSR-prefetch dashboard data and hydrate React Query hooks with initialData; add /api/health/ezygo status endpoint.
  • Update docs/config/CI for monitoring & security posture, plus assorted UI/CSS cleanups and release version updates.

Reviewed changes

Copilot reviewed 35 out of 36 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
src/lib/ezygo-batch-fetcher.ts New rate-limited + deduped EzyGo fetch utilities and dashboard batch fetch.
src/lib/csp.ts CSP tweaks (style-src-attr notes; dev websocket allowances).
src/lib/circuit-breaker.ts New circuit breaker implementation used by batch fetcher and proxy.
src/hooks/courses/courses.ts Add React Query initialData support for SSR hydration.
src/hooks/courses/attendance.ts Add React Query initialData support for SSR hydration.
src/components/user/login-form.tsx Layout class adjustments.
src/components/ui/dropdown-menu.tsx Tailwind/Radix data-attribute variant refactor.
src/components/ui/checkbox.tsx Checkbox radius style tweak.
src/components/loading.tsx Loading warning timing/message update; remove spinner CSS import.
src/components/legal/AcceptTermsForm.tsx Gradient utility class update.
src/components/layout/private-navbar.tsx Spacing/utility class updates and minor layout tweaks.
src/components/layout/footer.tsx Utility class updates (supports variant, gradient class, divider width).
src/components/attendance/course-card.tsx Style/class updates for card layout and progress stripes.
src/components/attendance/attendance-chart.tsx Replace ResponsiveContainer with measured dimensions approach.
src/components/attendance/attendance-calendar.tsx Spacing/utility class updates and minor layout tweaks.
src/components/attendance/AddAttendanceDialog.tsx Popover/select sizing utility updates.
src/app/globals.css Tailwind @apply and utility refactors for custom styles.
src/app/api/health/ezygo/route.ts New health endpoint exposing limiter + circuit breaker status.
src/app/api/backend/[...path]/route.ts Wrap proxy fetch in circuit breaker; map open-circuit to 503.
src/app/accept-terms/page.tsx Gradient/background utility refactor.
src/app/(public)/layout.tsx Add inert attribute feature-detected for hidden navbar.
src/app/(protected)/profile/ProfileClient.tsx Gradient utility refactor and sizing tweaks.
src/app/(protected)/dashboard/page.tsx SSR auth/token check + server-side dashboard prefetch + hydration.
src/app/(protected)/dashboard/DashboardClient.tsx Accept initialData and pass it into hooks; minor styling updates.
public/api-docs/openapi.yaml API docs version update (but currently mismatched to release).
package.json Bump to 1.5.0; add dev HTTPS script; add lru-cache.
package-lock.json Lockfile updates for new dependency/version bump.
next.config.ts Serwist config tweaks for reload/cache-on-navigation.
docs/SECURITY.md Removed security implementation guide.
docs/EZYGO_VERIFICATION.md New verification/monitoring report for rate limiting & breaker.
docs/EZYGO_RATE_LIMITING.md New architecture + tuning documentation for rate limiting approach.
docs/EDGE_CASES_TESTS.md New edge-case checklist/scenario doc.
README.md Badges/tooling updates; mention new batching/caching strategy.
Dockerfile Verify service worker exists; adjust public/ asset copy behavior.
.github/workflows/scorecard.yml Add scheduled/push OSSF Scorecard workflow.
.example.env Bump exposed app version to 1.5.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@devakesu
Copy link
Owner Author

devakesu commented Feb 8, 2026

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Feb 8, 2026

@devakesu I've opened a new pull request, #293, to work on those changes. Once the pull request is ready, I'll request review from you.

* Initial plan

* Fix PR review issues: security, docs, error handling, and UI

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Add comprehensive unit tests for circuit breaker and rate limiter

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 37 out of 38 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@devakesu
Copy link
Owner Author

devakesu commented Feb 8, 2026

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Feb 8, 2026

@devakesu I've opened a new pull request, #294, to work on those changes. Once the pull request is ready, I'll request review from you.

…lation (#294)

* Initial plan

* Fix PR review feedback: cache normalization, TTL behavior, circuit breaker error handling, CSS import, test isolation

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Address code review feedback: fix return type consistency and improve documentation

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Address PR review feedback: add tests, fix error handling, narrow 4xx scope, evict failed promises

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Address code review feedback: refine cache eviction and improve documentation

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 37 out of 38 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@devakesu
Copy link
Owner Author

devakesu commented Feb 8, 2026

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Feb 8, 2026

@devakesu I've opened a new pull request, #295, to work on those changes. Once the pull request is ready, I'll request review from you.

…ocs (#295)

* Initial plan

* Address PR review comments: hydration, syntax, cleanup, docs

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Remove redundant clearTimeout call

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Fix ldrs CSS import path for Turbopack compatibility

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Update src/app/(protected)/dashboard/DashboardClient.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
Co-authored-by: Devanarayanan <fusion@devakesu.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 37 out of 38 changed files in this pull request and generated 12 comments.

Comments suppressed due to low confidence (1)

src/components/attendance/attendance-calendar.tsx:597

  • Widths like w-32.5 / w-22.5 and heights like max-h-70 aren’t default Tailwind tokens, so the Select triggers/menus may not size correctly. Use supported tokens or arbitrary values (e.g. w-[130px], max-h-[280px]).
              <SelectTrigger className="w-32.5 h-9 bg-background/60 border-border/60 text-sm capitalize custom-dropdown" aria-label="Filter attendance by status">
                <SelectValue>{filter === "all" ? "All" : filter.charAt(0).toUpperCase() + filter.slice(1)}</SelectValue>
              </SelectTrigger>
              <SelectContent className="bg-background/90 border-border/60 backdrop-blur-md custom-dropdown max-h-70">
                <SelectItem value="all">All</SelectItem>
                <SelectItem value="present">Present</SelectItem>
                <SelectItem value="absent">Absent</SelectItem>
                <SelectItem value="dutyLeave">Duty Leave</SelectItem>
                <SelectItem value="otherLeave">Other Leave</SelectItem>
              </SelectContent>
            </Select>
            <Select value={currentDate.month!.toString()} onValueChange={handleMonthChange}>
              <SelectTrigger className="w-32.5 h-9 bg-background/60 border-border/60 text-sm capitalize custom-dropdown" aria-label="Select month">
                <SelectValue>{monthNames[currentDate.month!]}</SelectValue>
              </SelectTrigger>
              <SelectContent className="bg-background/90 border-border/60 backdrop-blur-md custom-dropdown max-h-70">
                {monthNames.map((month, index) => (
                  <SelectItem key={month} value={index.toString()} className={currentDate.month === index ? "bg-white/5 mt-0.5" : "capitalize"}>
                    {month}
                  </SelectItem>
                ))}
              </SelectContent>
            </Select>
            <Select value={currentDate.year!.toString()} onValueChange={handleYearChange}>
              <SelectTrigger className="w-22.5 h-9 bg-background/60 border-border/60 text-sm custom-dropdown" aria-label="Select year">
                <SelectValue>{currentDate.year}</SelectValue>
              </SelectTrigger>
              <SelectContent className="bg-background/90 border-border/60 max-h-70 backdrop-blur-md custom-dropdown">
                {yearOptions.map((year) => (

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@devakesu
Copy link
Owner Author

devakesu commented Feb 8, 2026

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Feb 10, 2026

@devakesu I've opened a new pull request, #320, to work on those changes. Once the pull request is ready, I'll request review from you.

…solation (#320)

* Initial plan

* Changes before error encountered

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Fix test isolation by resetting circuit breaker state before each Rate Limiting test

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Improve timeout test mock robustness with signal validation and early abort handling

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 42 out of 44 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@devakesu
Copy link
Owner Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Feb 10, 2026

@devakesu I've opened a new pull request, #321, to work on those changes. Once the pull request is ready, I'll request review from you.

…ircuit breaker tests (#321)

* Initial plan

* Fix AbortSignal.timeout() compatibility and circuit breaker mock isolation

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 42 out of 44 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@devakesu
Copy link
Owner Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Feb 11, 2026

@devakesu I've opened a new pull request, #322, to work on those changes. Once the pull request is ready, I'll request review from you.

* Initial plan

* Fix resource leaks: cancel reader on size limit, clear timeout on fetch completion, improve AbortSignal.timeout detection

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Address review feedback: fix docstring, await reader.cancel(), add timer cleanup tests

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Fix comment: remove mention of logging that isn't implemented

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 42 out of 44 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@devakesu
Copy link
Owner Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Feb 11, 2026

@devakesu I've opened a new pull request, #323, to work on those changes. Once the pull request is ready, I'll request review from you.

* Initial plan

* Fix invalid Tailwind CSS class names

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Remove trailing whitespace from AcceptTermsForm.tsx

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 40 out of 43 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

* Initial plan

* Fix attendance hook unit tests for initialData support

- Add beforeEach/afterEach hooks to prevent test state pollution
- Disable background refetch settings in test QueryClient
- Increase timeout for error state test to 3000ms
- All 5 attendance tests now passing
- No regressions in other tests (399 tests passing)

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

* Remove redundant afterEach hook

The beforeEach already clears mocks, so afterEach is unnecessary

Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
@devakesu devakesu merged commit b1ff827 into main Feb 11, 2026
8 checks passed
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.

2 participants