eBookStore--React is a full-featured E-Commerce web application built with React. Designed for ordering codebooks, it demonstrates modern web development with a robust, global state-managed frontend and a mock backend. The project is ideal for learning full-stack concepts, React best practices, and real-world deployment (Netlify & Render). It showcases advanced routing, authentication, CRUD operations, and seamless integration between frontend and backend.
- Frontend Live: https://ebookstore-arnob.netlify.app
- Backend Live: https://codebook-mock-server-j8n3.onrender.com
- Backend Source: eBookStore-Mock-Server Repo
- Project Overview
- Key Features
- Demo Links
- Project Structure
- Technology Stack
- Installation & Setup
- Available Scripts
- Deployment
- API & Routing
- Component & Feature Walkthrough
- Learning Resources
- Example Usage
- Keywords
- Conclusion
eBookStore--React is a demonstration of a scalable and modular React E-Commerce site. Users can browse, search, and order codebooks, register/login (with JWT-based authentication), and manage their cartβall with persistent state. The backend is a mock server (JSON Server + Auth), making the project easy to run locally without extra setup.
- Frontend: React (with global state)
- Backend: JSON Server + JSON Server Auth (mock REST API)
- Deployment: Netlify (Frontend), Render (Backend)
- π‘ Modern React with Hooks & Context API
- π Shopping Cart Functionality
- π User Authentication (JWT)
- π RESTful API Integration
- π React Router v6 for Navigation
- π Responsive UI with Tailwind CSS
- π Deployed & Production-Ready Workflow
- π§ͺ Testing Setup
- βοΈ Environment Variables for Security
- π Example Scripts & Learning Resources
eBookStore--React/
βββ data/ # Mock database & routes config
β βββ db.json
β βββ routes.json
βββ public/ # Static assets and index.html
βββ src/ # Main React source code
β βββ components/ # Reusable and page components
β βββ context/ # Global state (Context API, Providers)
β βββ hooks/ # Custom React hooks
β βββ pages/ # Page-level components
β βββ styles/ # Tailwind / CSS styles
β βββ utils/ # Utility functions (API, helpers)
β βββ App.js # Root component & routing
β βββ index.js # Entry point
β βββ ...other files
βββ .env # Environment variables (not committed)
βββ package.json # Project metadata & dependencies
βββ tailwind.config.js # Tailwind CSS config
βββ netlify.toml # Netlify deployment config
βββ README.md # Documentation (this file)
- Frontend: React, React Router, Context API, Tailwind CSS
- Backend: JSON Server, JSON Server Auth (Mock REST API)
- Testing: React Testing Library, Jest
- Deployment: Netlify (Frontend), Render (Backend)
- Utilities: dotenv, JWT, Axios/Fetch
- Node.js (v14+ recommended)
- npm (comes with Node.js)
-
Clone the repository:
git clone https://github.com/arnobt78/eBookStore--React.git cd eBookStore--React
-
Install dependencies:
npm install
-
Install React Router:
npm install react-router-dom
-
Install JSON Server and Auth:
npm install -D json-server json-server-auth
-
Run JSON Server:
npx json-server data/db.json
-
Run Auth Server (in a second terminal):
npx json-server data/db.json -m ./node_modules/json-server-auth -r data/routes.json --port 8000
The React app runs on port 3000. The backend (mock server) runs on port 8000.
Create a .env
file in your root project directory:
REACT_APP_HOST=http://localhost:8000
[email protected]
REACT_APP_GUEST_PASSWORD=learnreact
Within the project directory, you can run:
-
Start Development Server
npm start
Open http://localhost:3000 in your browser.
-
Run Tests
npm test
Launches the test runner in interactive mode.
-
Build for Production
npm run build
-
Eject Configuration (irreversible)
npm run eject
- Login at Netlify.
- Import project from GitHub.
- Configure environment variables (
Site settings > Build & deploy > Environment > Environment variables
). - Deploy site.
- For 404 issues, see:
- Login at Render.
- Create a new Web Service, select your backend repo.
- Deploy.
- For deployment errors, check logs and push fixes to
main
branch.
- Backend REST API (mocked with JSON Server + Auth)
/books
β Fetch all books/cart
β Get/add/remove items in cart/users
β User registration/login (JWT)- Custom routes configured in
data/routes.json
- Frontend Routing (React Router)
/
β Home/login
β Login/register
β Signup/books
β Book listing/cart
β Shopping cart/profile
β User profile- ...and more
- Global State Management: Uses React's Context API for cart and auth state.
- Authentication: JWT-based, login/register with protected routes.
- Cart: Add/remove books, persistent across sessions.
- Book CRUD: List, add, and remove books via API.
- Responsive UI: Tailwind CSS for modern design.
- Custom Hooks: For API calls and state logic.
- API Layer: Centralized utility for all server interactions.
- Error Handling: Graceful fallbacks for failed requests.
- Testing: Ready for expansion with React Testing Library.
- Create React App Docs
- React Documentation
- React Router
- JSON Server
- JSON Server Auth
- JWT Debugger
- Netlify Docs
- Render Docs
Sample API Call:
// src/utils/api.js
export async function loginUser(email, password) {
const response = await fetch(`${process.env.REACT_APP_HOST}/login`, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ email, password })
});
return response.json();
}
Sample Route:
// src/App.js
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import Home from './pages/Home';
import Login from './pages/Login';
function App() {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/login" element={<Login />} />
{/* ...other routes */}
</Routes>
</BrowserRouter>
);
}
React
, E-Commerce
, Mock Server
, JWT Auth
, React Router
, Tailwind CSS
, Full Stack
, Netlify
, Render
, Learning Project
, REST API
, Codebooks
, Global State
, Context API
eBookStore--React is not just a projectβit's a learning journey. This repository combines real-world tech stacks, best practices, and deployment workflows, making it perfect for both beginners and intermediate developers keen to master modern React and full-stack development. Fork, clone, and start coding!
Thank you for using and learning from this project. If you have questions or suggestions, feel free to open an issue or pull request.