Skip to content

shafikul-dev/fresh-hervest-management-system

Repository files navigation

SM Technology Frontend Development Task

A responsive frontend application built with Next.js, Tailwind CSS, and Redux RTK Query for SM Technology's development task.

πŸš€ Technology Stack

  • Framework: Next.js 15.5.4 with App Router
  • Language: TypeScript
  • Styling: Tailwind CSS 4
  • State Management: Redux Toolkit with RTK Query
  • Testing: Jest with React Testing Library
  • Linting: ESLint with Next.js config

πŸ“‹ Features

  • βœ… Responsive design across all devices
  • βœ… Modern UI components with Tailwind CSS
  • βœ… Redux RTK Query for API integration
  • βœ… TypeScript for type safety
  • βœ… Component-based architecture
  • βœ… Testing setup with Jest
  • βœ… SEO optimized with Next.js
  • βœ… Performance optimized

πŸ› οΈ Installation & Setup

Prerequisites

  • Node.js 18.0 or later
  • npm or yarn package manager

1. Clone the Repository

git clone <repository-url>
cd sm-technology-frontend

2. Install Dependencies

npm install

3. Environment Configuration

Create a .env.local file in the root directory:

# API Configuration
NEXT_PUBLIC_API_BASE_URL=https://your-live-server-url.com

# App Configuration
NEXT_PUBLIC_APP_NAME=SM Technology
NEXT_PUBLIC_APP_VERSION=1.0.0

4. Run the Development Server

npm run dev

Open http://localhost:3000 in your browser to see the application.

πŸ“ Project Structure

src/
β”œβ”€β”€ app/                    # Next.js App Router
β”‚   β”œβ”€β”€ layout.tsx         # Root layout
β”‚   β”œβ”€β”€ page.tsx           # Home page
β”‚   └── globals.css        # Global styles
β”œβ”€β”€ components/            # Reusable components
β”‚   β”œβ”€β”€ layout/           # Layout components
β”‚   β”‚   β”œβ”€β”€ Header.tsx
β”‚   β”‚   └── Footer.tsx
β”‚   β”œβ”€β”€ sections/         # Page sections
β”‚   β”‚   └── Hero.tsx
β”‚   β”œβ”€β”€ ui/               # UI components
β”‚   β”‚   β”œβ”€β”€ Button.tsx
β”‚   β”‚   β”œβ”€β”€ Input.tsx
β”‚   β”‚   └── LoadingSpinner.tsx
β”‚   └── providers/        # Context providers
β”‚       └── Providers.tsx
β”œβ”€β”€ store/                # Redux store
β”‚   β”œβ”€β”€ index.ts          # Store configuration
β”‚   β”œβ”€β”€ hooks.ts          # Typed hooks
β”‚   └── api/              # API slices
β”‚       └── apiSlice.ts
β”œβ”€β”€ types/                # TypeScript types
β”‚   └── index.ts
└── config/               # Configuration
    └── env.ts

πŸ”§ Available Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run start - Start production server
  • npm run lint - Run ESLint
  • npm run test - Run tests
  • npm run test:watch - Run tests in watch mode
  • npm run test:coverage - Run tests with coverage

🌐 API Integration

The application uses Redux RTK Query for API integration. The base configuration is set up in src/store/api/apiSlice.ts.

Adding New API Endpoints

  1. Define your endpoint in the apiSlice.ts file:
export const api = createApi({
  // ... existing config
  endpoints: (builder) => ({
    getUsers: builder.query<User[], void>({
      query: () => 'users',
      providesTags: ['User'],
    }),
    createUser: builder.mutation<User, Partial<User>>({
      query: (user) => ({
        url: 'users',
        method: 'POST',
        body: user,
      }),
      invalidatesTags: ['User'],
    }),
  }),
})
  1. Export the generated hooks:
export const {
  useGetUsersQuery,
  useCreateUserMutation,
} = api
  1. Use in your components:
import { useGetUsersQuery } from '@/store/api/apiSlice'

function UsersList() {
  const { data: users, error, isLoading } = useGetUsersQuery()
  
  if (isLoading) return <LoadingSpinner />
  if (error) return <div>Error loading users</div>
  
  return (
    <ul>
      {users?.map(user => (
        <li key={user.id}>{user.name}</li>
      ))}
    </ul>
  )
}

🎨 Styling Guidelines

The project uses Tailwind CSS for styling. Follow these guidelines:

  • Use utility classes for styling
  • Create custom components for reusable UI elements
  • Follow mobile-first responsive design
  • Use consistent spacing and color schemes
  • Maintain accessibility standards

πŸ§ͺ Testing

The project includes Jest and React Testing Library for testing.

Writing Tests

Create test files with .test.tsx or .spec.tsx extension:

import { render, screen } from '@testing-library/react'
import { Button } from '@/components/ui/Button'

describe('Button', () => {
  it('renders correctly', () => {
    render(<Button>Click me</Button>)
    expect(screen.getByText('Click me')).toBeInTheDocument()
  })
})

πŸš€ Deployment

Build for Production

npm run build

Deploy to Vercel

  1. Push your code to GitHub
  2. Connect your repository to Vercel
  3. Configure environment variables
  4. Deploy

Deploy to Other Platforms

The application can be deployed to any platform that supports Node.js:

  • Netlify
  • AWS Amplify
  • Railway
  • DigitalOcean App Platform

πŸ“± Responsive Design

The application is fully responsive and tested on:

  • Mobile devices (320px and up)
  • Tablets (768px and up)
  • Desktop (1024px and up)
  • Large screens (1280px and up)

πŸ”’ Security Considerations

  • Environment variables are properly configured
  • API tokens are handled securely
  • Input validation is implemented
  • XSS protection is enabled
  • CSRF protection is configured

πŸ“ˆ Performance Optimization

  • Next.js automatic code splitting
  • Image optimization with Next.js Image component
  • Lazy loading for components
  • Bundle analysis and optimization
  • SEO optimization with Next.js metadata

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite
  6. Submit a pull request

πŸ“ž Support

For any questions or support, please contact:

πŸ“„ License

This project is created for SM Technology's frontend development task.


Project Submission Date: September 27, 2025, 11:59 PM Submission Link: Submit Here# fresh-hervest-management-system

Releases

No releases published

Packages

No packages published