This guide explains how to set up, run, and develop the Hiking Logbook frontend application locally.
The frontend is a React.js application built with:
Before setting up the development site, ensure you have:
frontend/
├── public/ # Static assets
│ ├── index.html # Main HTML template
│ ├── favicon.ico # Site icon
│ └── manifest.json # PWA manifest
├── src/ # Source code
│ ├── components/ # Reusable React components
│ ├── pages/ # Page components
│ ├── hooks/ # Custom React hooks
│ ├── utils/ # Utility functions
│ ├── styles/ # CSS and styling
│ ├── App.js # Main App component
│ └── index.js # Application entry point
├── package.json # Dependencies and scripts
├── tailwind.config.js # Tailwind CSS configuration
└── postcss.config.js # PostCSS configuration
# Clone the repository (if not already done)
git clone <your-repo-url>
cd Hiking-Logbook/frontend
# Install dependencies
npm install
Create a .env.local
file in the frontend directory:
# Frontend environment variables
REACT_APP_API_URL=http://localhost:3000
REACT_APP_FIREBASE_API_KEY=your_firebase_api_key
REACT_APP_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
REACT_APP_FIREBASE_PROJECT_ID=your_project_id
Note: Replace the Firebase values with your actual Firebase project credentials.
# Check if everything is working
npm run lint
npm run format:check
npm start
This will:
http://localhost:3000
# Development
npm start # Start development server
npm run build # Build for production
npm run eject # Eject from Create React App (irreversible)
# Code Quality
npm run lint # Check for linting issues
npm run lint:fix # Fix linting issues automatically
npm run format # Format code with Prettier
npm run format:check # Check if code is formatted correctly
# Testing
npm test # Run tests in watch mode
npm run test:coverage # Run tests with coverage report
# Create a new component
mkdir src/components/NewComponent
touch src/components/NewComponent/NewComponent.js
touch src/components/NewComponent/NewComponent.test.js
// Example component with Tailwind classes
function Button({ children, onClick, variant = "primary" }) {
const baseClasses = "px-4 py-2 rounded-lg font-medium transition-colors";
const variantClasses = {
primary: "bg-blue-600 hover:bg-blue-700 text-white",
secondary: "bg-gray-200 hover:bg-gray-300 text-gray-800",
};
return (
<button
className={`${baseClasses} ${variantClasses[variant]}`}
onClick={onClick}
>
{children}
</button>
);
}
# Run tests for a specific file
npm test -- NewComponent.test.js
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode (default)
npm test
The tailwind.config.js
file configures:
The postcss.config.js
file sets up:
# Kill process on port 3000
npx kill-port 3000
# Or use a different port
PORT=3001 npm start
# Clear npm cache
npm cache clean --force
# Delete node_modules and reinstall
rm -rf node_modules package-lock.json
npm install
# Check for syntax errors
npm run lint
# Verify environment variables
echo $REACT_APP_API_URL
sm:
, md:
, lg:
)REACT_APP_API_URL
environment variableAfter setting up the development site:
If you encounter issues:
This guide covers Sprint 1 frontend setup. For additional features, check the main README.