Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ Expected high-level structure:

`apps/web` is the React frontend.

Within `apps/web/src`, use `app/` for application-wide composition such as the
protected shell, access boundary, and identity shared across routed features.
Keep `features/` reserved for product capabilities such as dashboard, routines,
workouts, and authentication.

`apps/api` is the Express backend.

`packages/contracts` contains code that represents contracts shared between the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Verifies dashboard access states with an isolated router and query cache for each case.
// Verifies application access states with an isolated router and query cache for each case.
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import {
createMemoryHistory,
Expand All @@ -11,10 +11,10 @@ import {
import { cleanup, render, screen } from '@testing-library/react';
import { afterEach, describe, expect, it, vi } from 'vitest';

import { createPublicUser } from '../../test/fixtures/public-user.fixture';
import { startGuestSession } from '../auth/guest-session';
import { startGuestSession } from '../features/auth/guest-session';
import { createPublicUser } from '../test/fixtures/public-user.fixture';
import { ApplicationAccessBoundary } from './application-access-boundary';
import { ApplicationShell } from './application-shell';
import { DashboardAccessBoundary } from './dashboard-access-boundary';

const publicUser = createPublicUser({
avatarUrl: 'https://images.example.com/avatar.png',
Expand All @@ -26,7 +26,7 @@ afterEach(() => {
vi.unstubAllGlobals();
});

describe('dashboard access boundary', () => {
describe('application access boundary', () => {
it('allows an authenticated visitor into the dashboard', async () => {
vi.stubGlobal(
'fetch',
Expand Down Expand Up @@ -115,13 +115,13 @@ function renderDashboard() {
getParentRoute: () => rootRoute,
path: '/dashboard',
component: () => (
<DashboardAccessBoundary>
<ApplicationAccessBoundary>
{(identity) => (
<ApplicationShell identity={identity}>
<h1>Dashboard</h1>
</ApplicationShell>
)}
</DashboardAccessBoundary>
</ApplicationAccessBoundary>
),
});
const testRouter = createRouter({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
import { Navigate } from '@tanstack/react-router';
import type { ReactNode } from 'react';

import { Button } from '../../components/ui/button';
import { useCurrentUser } from '../auth/current-user.query';
import { isGuestSession } from '../auth/guest-session';
import { Button } from '../components/ui/button';
import { useCurrentUser } from '../features/auth/current-user.query';
import { isGuestSession } from '../features/auth/guest-session';
import type { ApplicationIdentity } from './application-identity';

type DashboardAccessBoundaryProps = {
type ApplicationAccessBoundaryProps = {
children: (identity: ApplicationIdentity) => ReactNode;
};

export function DashboardAccessBoundary({
export function ApplicationAccessBoundary({
children,
}: DashboardAccessBoundaryProps) {
}: ApplicationAccessBoundaryProps) {
const currentUser = useCurrentUser();

if (isGuestSession()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { cleanup, render, screen, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { afterEach, describe, expect, it } from 'vitest';

import { router } from '../../router';
import { isGuestSession, startGuestSession } from '../auth/guest-session';
import {
isGuestSession,
startGuestSession,
} from '../features/auth/guest-session';
import { router } from '../router';

afterEach(() => {
cleanup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
import { Link } from '@tanstack/react-router';
import { useState, type ReactNode } from 'react';

import wordmarkUrl from '../../assets/goforlift-wordmark.png';
import { cn } from '../../lib/utils';
import wordmarkUrl from '../assets/goforlift-wordmark.png';
import { cn } from '../lib/utils';
import type { ApplicationIdentity } from './application-identity';

const navigationItems = [
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/features/dashboard/dashboard-landing.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';

import { ApplicationIdentityContext } from '../../app/application-identity';
import { createPublicUser } from '../../test/fixtures/public-user.fixture';
import { ApplicationIdentityContext } from './application-identity';
import { DashboardLanding } from './dashboard-landing';

describe('dashboard landing', () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/features/dashboard/dashboard-landing.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Introduces new dashboard visitors with identity-aware onboarding copy.
import { useApplicationIdentity } from './application-identity';
import { useApplicationIdentity } from '../../app/application-identity';

export function DashboardLanding() {
const identity = useApplicationIdentity();
Expand Down
13 changes: 0 additions & 13 deletions apps/web/src/features/dashboard/section-landing.tsx

This file was deleted.

12 changes: 9 additions & 3 deletions apps/web/src/routes/_app.history.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// Maps the history URL into the protected application layout.
import { createFileRoute } from '@tanstack/react-router';

import { SectionLanding } from '../features/dashboard/section-landing';

export const Route = createFileRoute('/_app/history')({
component: () => <SectionLanding title="History" />,
component: HistoryLanding,
});

function HistoryLanding() {
return (
<h1 className="text-3xl font-semibold tracking-tight sm:text-4xl">
History
</h1>
);
}
12 changes: 9 additions & 3 deletions apps/web/src/routes/_app.routines.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// Maps the routines URL into the protected application layout.
import { createFileRoute } from '@tanstack/react-router';

import { SectionLanding } from '../features/dashboard/section-landing';

export const Route = createFileRoute('/_app/routines')({
component: () => <SectionLanding title="Routines" />,
component: RoutinesLanding,
});

function RoutinesLanding() {
return (
<h1 className="text-3xl font-semibold tracking-tight sm:text-4xl">
Routines
</h1>
);
}
12 changes: 9 additions & 3 deletions apps/web/src/routes/_app.settings.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// Maps the settings URL into the protected application layout.
import { createFileRoute } from '@tanstack/react-router';

import { SectionLanding } from '../features/dashboard/section-landing';

export const Route = createFileRoute('/_app/settings')({
component: () => <SectionLanding title="Settings" />,
component: SettingsLanding,
});

function SettingsLanding() {
return (
<h1 className="text-3xl font-semibold tracking-tight sm:text-4xl">
Settings
</h1>
);
}
10 changes: 5 additions & 5 deletions apps/web/src/routes/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Protects and frames every route inside the signed-in or guest application area.
import { createFileRoute, Outlet, useNavigate } from '@tanstack/react-router';

import { ApplicationAccessBoundary } from '../app/application-access-boundary';
import { ApplicationIdentityContext } from '../app/application-identity';
import { ApplicationShell } from '../app/application-shell';
import { clearGuestSession } from '../features/auth/guest-session';
import { ApplicationIdentityContext } from '../features/dashboard/application-identity';
import { ApplicationShell } from '../features/dashboard/application-shell';
import { DashboardAccessBoundary } from '../features/dashboard/dashboard-access-boundary';

export const Route = createFileRoute('/_app')({
component: ProtectedApplicationLayout,
Expand All @@ -19,7 +19,7 @@ function ProtectedApplicationLayout() {
}

return (
<DashboardAccessBoundary>
<ApplicationAccessBoundary>
{(identity) => (
<ApplicationIdentityContext.Provider value={identity}>
<ApplicationShell
Expand All @@ -30,6 +30,6 @@ function ProtectedApplicationLayout() {
</ApplicationShell>
</ApplicationIdentityContext.Provider>
)}
</DashboardAccessBoundary>
</ApplicationAccessBoundary>
);
}