A modern order management system built with Next.js, featuring user authentication and comprehensive order management capabilities.
- π User authentication and login
- π¦ Create new orders
- π View order lists
- π Filter and search orders
- π Paginated order display
- π¨ Responsive design
- Framework: Next.js 15 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS v4
- UI Components: Shadcn/UI + Radix UI
- HTTP Client: Axios
- State Management: React Context API
- Form Handling: React Hook Form + Zod
- Icons: Lucide React
- Authentication: JWT with automatic token refresh
src/
βββ app/ # Next.js App Router pages
β βββ dashboard/ # Dashboard page
β βββ login/ # Login page
β βββ test/ # Test page
β βββ layout.tsx # Root layout
β βββ page.tsx # Home page
β βββ not-found.tsx # 404 page
β βββ globals.css # Global styles
β βββ favicon.ico # Favicon
βββ components/ # React components
β βββ ui/ # Shadcn/UI components
β β βββ badge.tsx # Badge component
β β βββ button.tsx # Button component
β β βββ card.tsx # Card component
β β βββ form.tsx # Form components
β β βββ input.tsx # Input component
β β βββ label.tsx # Label component
β β βββ select.tsx # Select component
β β βββ table.tsx # Table component
β βββ CreateOrder.tsx # Create order component
β βββ OrderList.tsx # Order list component
β βββ ErrorBoundary.tsx # Error boundary component
β βββ LoadingSpinner.tsx # Loading spinner component
βββ contexts/ # React Context
β βββ AuthContext.tsx # Authentication context
βββ lib/ # Utility libraries
β βββ api.ts # API configuration
βββ services/ # API services
β βββ authService.ts # Authentication service
β βββ orderService.ts # Order service
βββ types/ # TypeScript type definitions
βββ auth.ts # Authentication types
βββ order.ts # Order types
Additional Configuration Files:
components.json
- Shadcn/UI configurationtailwind.config.js
- Tailwind CSS configurationnext.config.ts
- Next.js configurationDockerfile
- Docker configuration.github/workflows/ci-cd.yml
- CI/CD pipelineDEPLOYMENT.md
- Deployment guide
npm install
The project supports multiple environment configurations:
Copy the example file and configure your local settings:
cp .env.example .env.local
Edit .env.local
with your local configuration:
NEXT_PUBLIC_API_BASE_URL=http://3.93.213.141:8000
NEXT_PUBLIC_APP_NAME=Order Management (Local)
NODE_ENV=development
NEXT_PUBLIC_DEBUG=true
NEXT_PUBLIC_LOG_LEVEL=debug
.env.local
- Local development (overrides all other env files).env.development
- Development environment settings.env.staging
- Staging environment settings.env.production
- Production environment settings.env.example
- Template file with all available variables
Variable | Description | Required | Example |
---|---|---|---|
NEXT_PUBLIC_API_BASE_URL |
Backend API endpoint | Yes | http://3.93.213.141:8000 |
NEXT_PUBLIC_APP_NAME |
Application display name | Yes | Order Management System |
NODE_ENV |
Environment mode | No | development / production |
NEXT_PUBLIC_DEBUG |
Enable debug mode | No | true / false |
NEXT_PUBLIC_LOG_LEVEL |
Logging level | No | debug / info / warn / error |
npm run dev
Visit http://localhost:3000 to view the application.
This application connects to the backend API service at http://3.93.213.141:8000
, using the following main endpoints:
POST /auth/login
- User loginGET /users/me
- Get current user information
POST /orders
- Create new orderGET /orders
- Get order list (supports pagination and filtering)GET /orders/{id}
- Get single order detailsPATCH /orders/{id}/status
- Update order statusDELETE /orders/{id}
- Delete order
- Enter username and password on the login page
- After successful login, you'll be automatically redirected to the dashboard
- Fill in order information in the "Create New Order" section on the dashboard
- Include customer name, product name, quantity, and unit price
- The system will automatically calculate the total amount
- Click "Create Order" button to submit
- The order list displays all order information
- Filter by customer name and order status
- Browse with pagination support
- Adjust the number of items displayed per page
- Pending: Newly created orders
- Confirmed: Confirmed orders
- Shipped: Shipped orders
- Delivered: Successfully delivered orders
- Cancelled: Cancelled orders
npm run build
npm run start
npm run lint
npm run type-check
The project includes Docker support for containerized deployment:
# Build Docker image
docker build -t nextjs-order-management .
# Run container
docker run -p 3000:3000 nextjs-order-management
This project includes a complete CI/CD pipeline for AWS deployment:
- Setup: Follow the
DEPLOYMENT.md
guide for AWS configuration - Auto Deploy: Push to
main
branch for production,develop
for staging - Manual Deploy: Use GitHub Actions workflow dispatch
- Push code to GitHub
- Import project in Vercel
- Configure environment variables
- Deploy
Make sure to configure the correct environment variables, especially NEXT_PUBLIC_API_BASE_URL
.
- CORS Issues: If you encounter CORS errors, the backend API needs to be configured to allow cross-origin requests from the frontend domain
- Authentication Token: The login token is stored in localStorage and will automatically restore login state on page refresh with automatic token refresh
- Error Handling: The application includes comprehensive error handling with ErrorBoundary components for both network errors and API errors
- UI Components: Uses Shadcn/UI for consistent, accessible, and customizable components
- Docker Support: Includes production-ready Dockerfile with multi-stage builds for optimized container size
DEPLOYMENT.md
: Complete deployment guide for AWS EC2 with CI/CDTESTING.md
: Testing documentation and guidelinescomponents.json
: Shadcn/UI configuration for component generation.github/workflows/ci-cd.yml
: GitHub Actions CI/CD pipelineDockerfile
: Multi-stage Docker build configuration
-
Cannot Login
- Check if the API service is running normally
- Verify username and password are correct
- Check browser console for error messages
-
Empty Order List
- Confirm successful login
- Check if API endpoints return correct data
- Verify network requests are successful
-
Styling Issues
- Ensure Tailwind CSS v4 is configured correctly
- Check if CSS is loading properly
- Verify Shadcn/UI components are properly imported
-
Build Errors
- Run
npm run type-check
to identify TypeScript errors - Check for missing dependencies with
npm install
- Verify environment variables are properly set
- Run
-
Docker Build Issues
- Ensure Docker is installed and running
- If you get "Cannot find module 'typescript'" error, the Dockerfile has been updated to include dev dependencies
- For permission issues, check that Docker has access to the project directory
- π Deployment Guide: See
DEPLOYMENT.md
for complete AWS deployment instructions - π§ͺ Testing Guide: See
TESTING.md
for testing setup and guidelines - π¨ UI Components: Built with Shadcn/UI for modern, accessible components
- π³ Docker: Production-ready containerization with multi-stage builds
Welcome to submit issues and feature requests!
MIT License