Skip to content

Replace mock-data.ts with a pluggable data-access layer (repository pattern) ahead of real backend integration #304

Description

@Lakes41

Difficulty: Advanced
Type: refactor

Background
The README explicitly states "all data is currently mock data (see apps/dashboard/lib/mock-data.ts)", and the project is structured as a monorepo with packages/integration-client intended as the shared API client — implying a future swap to real backend data is expected.

Problem
Data access is likely called directly against the mock module throughout dashboard components/pages, which means introducing a real backend later requires touching many call sites and risks inconsistent loading/error handling.

Expected outcome
A repository/data-access abstraction (e.g., PassRepository, GuildRepository, MemberRepository, ActivityRepository) sits between UI code and data sources, with a mock implementation today and a clear seam for a real HTTP-backed implementation later via packages/integration-client.

Suggested implementation

  • Define repository interfaces in packages/integration-client (e.g., interface PassRepository { list(params): Promise<Paginated<Pass>>; get(id): Promise<Pass>; }).
  • Implement MockPassRepository etc. backed by the current mock-data.ts content, moved/adapted as needed.
  • Introduce a simple dependency-injection point (e.g., a getRepositories() factory) so a future HttpPassRepository can be swapped in via an environment flag.
  • Migrate dashboard pages to call repositories instead of mock-data.ts directly, using React Server Components/fetch-like async functions where idiomatic for Next.js 14.
  • Add a short ADR (architecture decision record) in docs/ explaining the pattern and migration path.

Acceptance criteria

  • Repository interfaces defined and exported from packages/integration-client
  • Mock implementations pass through existing dashboard functionality with no regressions
  • Dashboard pages no longer import mock-data.ts directly
  • pnpm typecheck and pnpm build succeed
  • ADR documenting the pattern is added to docs/

Likely affected files/directories

  • packages/integration-client/
  • apps/dashboard/lib/mock-data.ts
  • apps/dashboard/app/**
  • docs/

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesOfficial Campaign | FWC26Official FWC26 campaign issue — eligible for campaign scoring and rewardsadvancedAdvanced difficulty tasks requiring significant domain knowledge and implementation effortrefactorCode restructuring without changing external behavior or API

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions