Skip to content

A modern e‑book storefront built with Next.js App Router, React 19, Tailwind CSS, and TypeScript. It features browsing, cart/checkout (demo), simple auth with JWT, and a clean UI.

Notifications You must be signed in to change notification settings

caaaqil/E-Book-Store

Repository files navigation

Caaqil E‑Book Store

A modern e‑book storefront built with Next.js App Router, React 19, Tailwind CSS, and TypeScript. It features browsing, cart/checkout (demo), simple auth with JWT, and a clean UI.

Tech Stack

  • Next.js 15 (App Router)
  • React 19
  • TypeScript
  • Tailwind CSS
  • Radix UI + shadcn‑style components
  • jose (JWT)

Project Structure

app/                 # routes and UI
components/          # UI components
contexts/            # React context providers (auth)
hooks/               # custom hooks
lib/                 # utils (auth, db)
public/              # static assets
styles/              # global styles

Getting Started

  1. Install dependencies
    pnpm install
  2. Run the dev server
    pnpm dev
  3. Open http://localhost:3000 in your browser.

Environment Variables

The app uses a JWT secret for signing tokens. Create a .env.local file at the project root:

# Change for production
JWT_SECRET=your-strong-secret

If JWT_SECRET is not set, a default development secret is used.

Authentication

  • Email/password auth with client‑side context stored token.
  • Endpoints:
    • POST /api/auth/signup → creates user and returns { user, token }
    • POST /api/auth/login → verifies credentials and returns { user, token }
    • GET /api/auth/me → returns the current user using Authorization: Bearer <token>
  • Demo admin account (seeded):
    • email: admin@caaqil.com
    • password: admin123

Tokens are stored in localStorage by the auth context for simplicity. For production, prefer HttpOnly cookies.

Data Persistence (Important)

The default lib/db.ts is an in‑memory store intended for demos. Data resets on server restarts or refreshes during development HMR. Options to persist data:

  • Quick: write/read JSON files
  • Better DX: Prisma + SQLite
  • Production: Hosted DB (Postgres/MySQL/MongoDB)

If you want MongoDB or Prisma wired up, replace lib/db.ts with a real data layer and update API routes accordingly.

Scripts

  • pnpm dev – start dev server
  • pnpm build – build for production
  • pnpm start – start production server
  • pnpm lint – run Next lint

Notable Paths

  • Auth context: contexts/auth-context.tsx
  • Auth hooks: hooks/use-auth.ts
  • API routes: app/api/*
  • Pages: app/*

UI/Components

Radix and shadcn‑style components are used for accessible, composable UI. Tailwind is configured in postcss.config.mjs and styles.

Development Notes

  • This project targets modern Node runtimes compatible with Web Crypto API used in lib/auth.ts.
  • Update the seeded admin password only if you change hashing strategy.
  • Replace demo assets in public/ with your own.

License

MIT

About

A modern e‑book storefront built with Next.js App Router, React 19, Tailwind CSS, and TypeScript. It features browsing, cart/checkout (demo), simple auth with JWT, and a clean UI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published