This is a modern e-commerce application built using Next.js, hono, hono RPC, Supabase, and TypeScript. The application is designed for scalability, performance, and developer-friendly workflows.
- Server-side rendering (SSR) with Next.js for optimized SEO and fast load times.
- API development using hono and hono RPC for lightweight and efficient routing.
- Database and authentication powered by Supabase.
- Real-time database triggers integrated with Supabase.
- Fully typed with TypeScript for robust and error-free development.
- Modular and reusable components.
- Prerequisites
- Installation and Setup
- Running the Application
- Setting Up Supabase Triggers
- Submitting a Pull Request (PR)
- To-Do
- Contributing
Before you begin, ensure you have the following tools installed:
- Node.js (v18+ recommended)
- npm or yarn
- Supabase CLI (optional for local database management)
- Clone the repository:
git clone https://github.com/your-username/your-ecommerce-app.git cd your-ecommerce-app
- Install dependencies:
npm install
yarn install
- Create a .env file: Copy the .env.example file and configure it with your environment variables:
cp .env.example .env
Add your Supabase project credentials:
NEXT_PUBLIC_SUPABASE_URL= NEXT_PUBLIC_SUPABASE_ANON_KEY= SUPABASE_SERVICE_ROLE_KEY=
- Set up Supabase database and triggers: Navigate to your Supabase project and access the SQL Editor. Copy the SQL files located in @/lib/Supabase/triggers into the editor and execute them.
Running the Application
- Start the development server:
npm run dev
yarn dev
The application will run on http://localhost:3000.
- Build for production:
npm run build npm start
- Run API server with hono:
npm run hono
Setting Up Supabase Triggers
To ensure real-time functionality, you need to set up database triggers in Supabase:
-
Navigate to the Supabase Dashboard.
-
Open the SQL Editor.
-
Copy the SQL files from @/lib/Supabase/triggers and paste them into the SQL Editor.
-
Execute the SQL to create the necessary database triggers.
For example:
-- Sample trigger to log new user registrations CREATE OR REPLACE FUNCTION log_new_user() RETURNS TRIGGER AS $$ BEGIN INSERT INTO user_logs (user_id, action, timestamp) VALUES (NEW.id, 'registered', NOW()); RETURN NEW; END; $$ LANGUAGE plpgsql;
CREATE TRIGGER after_user_insert AFTER INSERT ON users FOR EACH ROW EXECUTE FUNCTION log_new_user();
Submitting a Pull Request (PR)
To contribute to this project:
-
Fork the repository.
-
Create a new branch:
git checkout -b feature/your-feature-name
- Make your changes and commit them:
git commit -m "Add your meaningful commit message here"
- Push to your branch:
git push origin feature/your-feature-name
- Create a Pull Request: Go to the original repository and create a PR with a clear description of your changes.
To-Do
Here are some upcoming features and tasks for the project:
[ ] Integrate payment gateway (e.g., Stripe or PayPal).
[ ] Add product search functionality.
[ ] Implement admin panel for product and order management.
[ ] Enhance responsive design for mobile and tablet views.
[ ] Write comprehensive tests for API and UI.
Contributing
We welcome contributions from the community! Please follow the Submitting a PR guidelines. If you have any questions, feel free to open an issue.
License
This project is licensed under the MIT License. See the LICENSE file for details.