A Next.js application for managing stock, built with the app router.
- Built with Next.js 16 and App Router
- Styled with Tailwind CSS and dark theme
- Form handling with react-hook-form
- Date manipulations with date-fns
- Database integration with Supabase
- Inventory management with CRUD operations
- Search and sort functionality
- Low stock alerts
- Data visualization with charts
- Item categories
- Responsive design with icons
First, install dependencies:
npm installThen, run the development server:
npm run devOpen http://localhost:3000 with your browser to see the result.
- @supabase/supabase-js
- tailwindcss
- react-hook-form
- date-fns
Tailwind CSS is already configured. The configuration files are:
tailwind.config.jspostcss.config.mjssrc/app/globals.css(with Tailwind directives)
To set up Tailwind CSS manually (if needed):
-
Install Tailwind CSS:
npm install -D tailwindcss postcss autoprefixer
-
Initialize Tailwind config:
npx tailwindcss init -p
-
Add Tailwind directives to your CSS (e.g.,
src/app/globals.css):@tailwind base; @tailwind components; @tailwind utilities;
-
Configure
tailwind.config.js:/** @type {import('tailwindcss').Config} */ module.exports = { content: [ "./src/pages/**/*.{js,ts,jsx,tsx,mdx}", "./src/components/**/*.{js,ts,jsx,tsx,mdx}", "./src/app/**/*.{js,ts,jsx,tsx,mdx}", ], theme: { extend: {}, }, plugins: [], }
-
Create a Supabase Account:
- Go to supabase.com and sign up for a free account.
-
Create a New Project:
- Click "New Project" in your dashboard.
- Choose your organization, enter a project name (e.g., "stock-management").
- Select a database password and region.
- Click "Create new project".
-
Wait for Project Setup:
- It takes a few minutes for the project to be fully set up.
-
Get API Keys:
- Go to Settings > API in your project dashboard.
- Copy the "Project URL" and "anon public" key.
-
Update Environment Variables:
- Open
.env.localin your project root. - Replace the placeholder values:
NEXT_PUBLIC_SUPABASE_URL=https://your-project-id.supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key-here
- Open
-
Create the Database Table:
- Go to the SQL Editor in your Supabase dashboard.
- Copy and paste the contents of
supabase-setup.sqlfrom your project root. - Click "Run" to execute the query.
-
Enable Row Level Security (Optional but Recommended):
- Go to Authentication > Policies in your dashboard.
- For the
itemstable, create policies to allow read/write access. - For development, you can allow all operations for authenticated users.
-
Test the Connection:
- Restart your development server:
npm run dev - Try adding an item - it should now save to Supabase instead of using mock data.
- Restart your development server:
- Build Errors: If you see Supabase errors during build, ensure your environment variables are set correctly.
- Permission Errors: Check your RLS policies in Supabase.
- Connection Issues: Verify your project URL and API key are correct.
src/app/- App router pages (Dashboard, Inventory, Add Item, Reports)src/components/- Reusable components (Navbar, Modal)src/lib/- Utility libraries (Supabase client)public/- Static assetstailwind.config.js- Tailwind configurationpostcss.config.mjs- PostCSS configuration
The project has been initialized with Git. To push to a remote repository:
git remote add origin <your-repo-url>
git push -u origin main