Skip to content

chore: harden CampusLoop engineering foundations - #4

Open
SH20RAJ wants to merge 42 commits into
mainfrom
chore/platform-best-practices
Open

SH20RAJ wants to merge 42 commits into
mainfrom
chore/platform-best-practices

Conversation

@SH20RAJ

@SH20RAJ SH20RAJ commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

CampusLoop engineering foundations pass

I scanned the complete repository tree (1,134 blob files) plus the architecture/engineering guides, then targeted the highest-leverage cross-cutting issues rather than rewriting large feature surfaces blindly.

Applied

Performance

  • Removed redundant Google Fonts external loading; CampusLoop already uses next/font.
  • Reused the centralized fetcher in the feed hook.
  • Added a 15s API request timeout with a user-friendly timeout error.
  • Bounded client feed/pending-post memory caches.
  • Changed feed hydration so ordinary votes are represented by aggregate SQL counts + the viewer's own vote, instead of loading every vote row.
  • Changed poll hydration to grouped vote counts + viewer state, instead of loading every poll vote row.
  • Removed the duplicate standalone production build before OpenNext deploy.

Security / reliability

  • Added runtime validation and normalization for create-post JSON payloads, including body/title/options/type/scope.
  • Invalid JSON and invalid payload types now return 400 instead of accidental 500s.
  • Hardened feed query validation for scope/type/visibility/page/limit/hashtag.
  • Added a Redis-backed fixed-window rate limiter for post creation with Retry-After.
  • Rate limiting fails open when Redis is unavailable so Redis outages cannot block normal posting.
  • Added read-only GITHUB_TOKEN workflow permissions.
  • Preserved the existing anonymous-author boundary and moderation/auth flow.

Architecture / maintainability

  • Removed the remaining direct database schema-module import at a discovered hotspot.
  • Added ESLint guardrails for raw fetch() in client UI, array-index keys, and oversized source files.
  • Re-enabled key Biome accessibility, security, and React correctness rules as warnings instead of leaving them disabled.

Testing / CI

  • Added focused unit tests for post payload validation.
  • Added PR quality workflow for typecheck, lint, and unit tests.
  • Deploy workflow now runs lint/tests before the actual deploy.

Verification status

The GitHub PR is currently mergeable/clean, but this environment cannot run the repository's Bun toolchain locally (bun is not installed here), and GitHub has not reported any check runs for the branch yet. So I am not claiming a passing build without evidence.

I intentionally did not merge or deploy this PR to production automatically.

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