Skip to content

mtsarac/plan-explorer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Plan Explorer

A filterable, sortable table application built with Next.js, TypeScript, and Tailwind CSS for exploring meal and training plans.

πŸš€ Features

  • Data Display: Interactive table showing items with ID, type, title, calories, and tags
  • Search: Real-time text search across title, tags, and calories
  • Type Filter: Filter by item type (All, Meals, Training)
  • Sorting: Click column headers to sort ascending/descending
  • Detail View: Hover cards showing detailed item information
  • Responsive: Mobile-friendly design with adaptive layouts

πŸ—οΈ Architecture

Project Structure

β”œβ”€β”€ app/                    # Next.js App Router
β”‚   β”œβ”€β”€ layout.tsx         # Root layout with metadata
β”‚   └── page.tsx           # Main page component
β”œβ”€β”€ components/            # React components
β”‚   β”œβ”€β”€ ui/               # Reusable UI primitives (shadcn/ui)
β”‚   β”œβ”€β”€ card-table.tsx    # Main container component
β”‚   β”œβ”€β”€ item-table.tsx    # Core table with state management
β”‚   β”œβ”€β”€ search-input.tsx  # Search functionality
β”‚   β”œβ”€β”€ type-filter.tsx   # Type filtering buttons
β”‚   β”œβ”€β”€ sort-button.tsx   # Sortable column headers
β”‚   └── reusable-hover-card.tsx # Item detail display
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ actions.tsx       # Pure utility functions
β”‚   └── data/
β”‚       β”œβ”€β”€ data.ts       # Data loading and types
β”‚       └── intern-case-2.json # Source data
└── tests/
    └── tests.ts          # Unit tests for utilities

Design Decisions

Component Architecture

  • Separation of Concerns: Pure functions in lib/actions.tsx separate business logic from UI
  • Single Responsibility: Each component has one clear purpose
  • Composition over Inheritance: Small, reusable components that compose together
  • Props Interface: Clear TypeScript interfaces for all component props

State Management

  • Local State: Using React useState for table state (sorting, filtering)
  • Prop Drilling: Simple prop passing for this scale (alternative: Context API for larger apps)
  • Immutable Updates: All state updates create new arrays/objects

Data Flow

JSON Data β†’ data.ts β†’ ItemTable β†’ [SearchInput, TypeFilter] β†’ Pure Functions β†’ Updated State

Technology Choices

Next.js 15

  • βœ… App Router: Modern file-based routing
  • βœ… Server Components: Better performance for static content
  • βœ… TypeScript: Full type safety

Styling: Tailwind CSS + shadcn/ui

  • βœ… Utility-first: Rapid development and consistent design
  • βœ… Component Library: Pre-built, accessible components
  • βœ… Responsive: Mobile-first design approach

State: React Built-ins

  • βœ… Simple: No external state management needed
  • βœ… Performance: Local state prevents unnecessary re-renders
  • ❌ Scale Limitation: Would need Context/Redux for complex apps

βš–οΈ Trade-offs Made

1. Client-Side vs Server-Side Filtering

  • Choice: Client-side filtering and sorting
  • Pro: Instant feedback, no network requests
  • Con: Limited to small datasets (current: 4 items)
  • Alternative: Server-side with pagination for large datasets

2. Component Granularity

  • Choice: Highly granular components (SearchInput, TypeFilter, SortButton)
  • Pro: Reusable, testable, maintainable
  • Con: More files and prop drilling
  • Alternative: Monolithic components (faster initial development)

3. Responsive Strategy

  • Choice: Single responsive table (scale-based)
  • Pro: Consistent experience across devices
  • Con: May be cramped on very small screens
  • Alternative: Card layout on mobile (implemented as hover cards)

4. Testing Strategy

  • Choice: Unit tests for pure functions only
  • Pro: Tests critical business logic
  • Con: No integration/E2E tests
  • Alternative: Full testing pyramid with React Testing Library

πŸ€– AI Assistance Used

This project was developed with assistance from GitHub Copilot for:

  • Generating tests for utility functions
  • Fixing minor bugs and typos
  • Style suggestions and code snippets
  • Writing readme sections

πŸš€ How to Extend

1. Scale for Production

Backend Integration

Database Schema

2. Enhanced UX

Loading States

const [isLoading, setIsLoading] = useState(false);
// Use TableSkeleton component during loading

Keyboard Shortcuts

useHotkeys("ctrl+f", () => searchInputRef.current?.focus());
useHotkeys("escape", () => clearFilters());

5. Testing Strategy

Unit Tests

// Already implemented for pure functions
// Extend to: validation, edge cases, error handling

πŸ› οΈ Development

Getting Started

# Install dependencies
bun install

# Run development server
bun run dev

# Run tests
bun run test

# Build for production
bun run build

Scripts

  • dev: Start development server
  • build: Build for production
  • start: Start production server
  • lint: Run Biome
  • format: Format code with Biome
  • test: Run unit tests

Tech Stack

  • Framework: Next.js 15
  • Language: TypeScript
  • Styling: Tailwind CSS + shadcn/ui
  • Runtime: Bun
  • Testing: Node.js built-in test runner

About

Plan explorer for fitness sector.

Resources

Stars

Watchers

Forks

Contributors