This is a Flight Management System built with Next.js, React, and TypeScript. It provides functionality for user authentication, flight creation, editing, deletion, and searching.
- Features
- Tech Stack
- Project Structure
- Setup Instructions
- Component Design Patterns
- API Integration
- Testing
- Deployment
- User Authentication (Login/Register)
- Flight Management (Create, Read, Update, Delete)
- Flight Search
- Responsive Design
- Next.js 13 (with App Router)
- React 18
- TypeScript
- Tailwind CSS
- shadcn/ui components
- React Hook Form
- Zod (for form validation)
- Jest (for unit testing)
- Cypress (for end-to-end testing)
flight-management/
├── app/
│ ├── auth/
│ │ └── page.tsx
│ ├── flights/
│ │ └── page.tsx
│ ├── layout.tsx
│ └── page.tsx
├── components/
│ ├── auth/
│ │ ├── login-form.tsx
│ │ └── register-form.tsx
│ ├── flights/
│ │ ├── flight-form.tsx
│ │ └── flight-list.tsx
│ └── ui/
│ └── ... (shadcn/ui components)
├── contexts/
│ └── auth-context.tsx
├── hooks/
│ ├── use-api.ts
│ └── use-form.ts
├── lib/
│ ├── api.ts
│ └── utils.ts
├── types/
│ ├── auth.ts
│ └── flight.ts
├── .env.local
├── jest.config.js
├── next.config.js
├── package.json
├── README.md
└── tsconfig.json
-
Clone the repository: ``` git clone https://github.com/your-username/flight-management.git cd flight-management ```
-
Install dependencies: ``` npm install ```
-
Create a
.env.localfile in the root directory and add your environment variables: ``` NEXT_PUBLIC_API_URL=your_api_url_here ``` -
Run the development server: ``` npm run dev ```
-
Open http://localhost:3000 with your browser to see the result.
-
Atomic Design: We've structured our components following the Atomic Design methodology, with atoms (basic UI components), molecules (groups of atoms), and organisms (groups of molecules and/or atoms).
-
Container/Presentational Pattern: We separate the logic and presentation concerns. Container components (like pages) handle data fetching and state management, while presentational components focus on rendering UI.
-
Composition: We use composition to build complex components from simpler ones, promoting reusability and maintainability.
-
Hooks: We extensively use React Hooks for state management and side effects. Custom hooks (
use-api.ts,use-form.ts) encapsulate reusable logic. -
Context API: We use React's Context API for global state management, particularly for user authentication (
auth-context.tsx). -
Render Props: Some components use the render props pattern to share code between components.
We use a custom api object (lib/api.ts) to interact with the backend. This object provides methods for all necessary API calls, handling authentication and request/response processing.
-
Unit Testing: We use Jest and React Testing Library for unit tests. Run unit tests with: ``` npm run test ```
-
End-to-End Testing: We use Cypress for E2E tests. Run E2E tests with: ``` npm run test:e2e ```
This project is set up to be easily deployed on Vercel. Connect your GitHub repository to Vercel for automatic deployments on every push to the main branch.
For other platforms, make sure to build the project first:
``` npm run build ```
Then, you can start the production server:
``` npm start ```