This repository contains my project for the Introduction to Internet Applications course at AGH UST. The project implements an e-commerce application focusing on tabletop games, utilizing React.js, Material UI, Express.js and SQLite.
Make sure you have Node.js installed and clone the repo:
git clone https://github.com/psarsky/tabletop-kingdom.git
cd tabletop-kingdom
- Navigate to the
clientdirectory:cd client - Install dependencies:
npm install - Start the development server:
By default, the client will run on
npm run devhttp://localhost:5173.
- Navigate to the
serverdirectory:cd server - Install dependencies:
npm install - Configure your
.envfile:PORT=3000 TOKEN_SECRET=<<your super duper mega secret key>> - Start the server:
By default, the server will run on
npm starthttp://localhost:3000.
- Vite: Build tool for bundling the application.
- React.js: Library for building the user interface.
- React Router: Library for managing navigation and routing in the application.
- Material UI: Component library for styling and UI elements.
- Node.js: JavaScript runtime for building the server.
- Express.js: Web framework for creating the REST API.
- SQLite: Lightweight database for data storage.
- Sequelize: ORM for interacting with the SQLite database.
- JWT (jsonwebtoken): For user authentication and authorization.
- bcryptjs: For password hashing.
- dotenv: For environment variable management.
- User interface:
- Home page displaying announcements and featured products.
- Product list page with searching.
- Product details page with detailed descriptions and reviews.
- Shopping cart:
- Add products to the cart.
- Update quantities or remove items.
- Responsive design:
- Optimized for mobile, tablet, and desktop views.
More features coming as client side is still unfinished.
- User management:
- User registration and login.
- Authentication using JWT tokens.
- Role-based access control (admin/user).
- Product management:
- CRUD operations for products.
- Order processing:
- Managing user orders and order items.
- Order history retrieval.
- Reviews and ratings:
- Users can leave reviews and ratings for products.
| HTTP Request | Description | Roles allowed |
|---|---|---|
| POST /users/register | Register a new user. | Everyone |
| POST /users/login | Authenticate a user and return a JWT. | Everyone |
| PATCH /users/id/:id | Update user data. | Authenticated user (only their data) Admin (any user's data) |
| DELETE /users/id/:id | Delete user account. | Authenticated user (only their account) Admin (any user's account) |
| GET /users/id/:id | Get user data. | Authenticated user (only their data) Admin (any user's data) |
| GET /users | Get all users. | Admin only |
| HTTP Request | Description | Roles allowed |
|---|---|---|
| POST /products | Add a new product. | Admin only |
| POST /products/id/:id/reviews | Add a review for a product. | Authenticated user |
| PATCH /products/id/:id | Update product details. | Admin only |
| DELETE /products/id/:id | Delete product. | Admin only |
| GET /products/id/:id | Get details of a single product. | Everyone |
| GET /products/id/:id/reviews | Get the product's reviews. | Everyone |
| GET /products | Get a list of all products. | Everyone |
| GET /products/categories | Get a list of all categories. | Everyone |
| HTTP Request | Description | Roles allowed |
|---|---|---|
| POST /orders | Create a new order. | Authenticated user |
| PATCH /orders/id/:id | Update order details. | Admin only |
| DELETE /orders/id/:id | Delete order. | Admin only |
| GET /orders/id/:id | Get details of a single order. | Authenticated user (only their orders) Admin (any user's orders) |
| GET /orders/:userId | Get all orders for a user. | Authenticated user (only their orders) Admin (any user's orders) |
| GET /orders | Get all orders. | Admin only |
| HTTP Request | Description | Roles Allowed |
|---|---|---|
| DELETE /reviews/:id | Remove a review. | Authenticated user (only their reviews) Admin (any user's reviews) |
| GET /reviews/user/userId | Get all user's reviews. | Authenticated user (only their reviews) Admin (any user's reviews) |
| GET /reviews | Get all reviews. | Admin only |
JWT-based authentication is implemented in the auth.js middleware. Secure routes require a valid JWT token for access. Admin-only routes perform an additional role check.