How arn101/ssh-library-management-system works
Purpose and deployment shape
SSH Library Management System is a role-based full-stack application for library circulation and reading-room seating. React/Vite is deployed separately from an Express API, with hosting configuration for Netlify and Render: netlify.toml, render.yaml, docs/DEPLOYMENT.md. MySQL 8 is the system of record, defined in db/schema.sql.
Application entry points
The frontend boots React from frontend/src/main.jsx into frontend/src/App.jsx; route composition is centralized in frontend/src/routes/Routes.jsx with separate student and administrator route definitions. The API server starts from backend/index.js, initializes the database pool through backend/config/db.js, and mounts auth, book, reservation, and seat routers.
Identity, roles, and protected navigation
Authentication is JWT-based, with bcrypt credential handling and refresh-token cookie support. Backend identity endpoints and token mechanics live in backend/routes/authRoutes.js, backend/controllers/authController.js, and backend/utils/tokens.js. backend/middleware/authMiddleware.js establishes authenticated request context, while backend/middleware/roleMiddleware.js gates librarian-only operations. On the client, auth state and API mutations are managed by frontend/src/redux/features/auth/authSlice.js and frontend/src/redux/features/auth/authApi.js; frontend/src/components/layout/ProtectedRoute.jsx protects role-specific screens.
API-to-client data boundary
The frontend uses Redux Toolkit with RTK Query as its API boundary. frontend/src/redux/api/baseApi.js supplies the shared API client; domain endpoints are injected by frontend/src/redux/features/book/bookApi.js, frontend/src/redux/features/reservation/reservationApi.js, and frontend/src/redux/features/seat/seatApi.js. API base URL is environment-controlled, allowing the Vite client to target local Express or deployed Render services.
Library catalog and inventory
Books flow from MySQL through the book router/controller layer to distinct student catalog and librarian inventory views. Core server endpoints are in backend/routes/bookRoutes.js and backend/controllers/bookController.js; output shaping is handled by backend/utils/bookMapper.js. Students browse/filter the catalog at frontend/src/pages/BookCatalog.jsx; librarians perform inventory administration from frontend/src/pages/BookInventory.jsx. Seed data and cover acquisition support the initial catalog via backend/data/books-seed.js and backend/scripts/seed-books.js.
Reservation circulation workflow
Reservations are the circulation state machine: students create and cancel pending requests; librarians issue or mark returned reservations. Server-side request handling is separated into backend/routes/reservationRoutes.js, backend/controllers/reservationController.js, and backend/utils/reservationMapper.js. The student-facing history/action surface is frontend/src/pages/MyReservations.jsx; librarian approval and lifecycle control is frontend/src/pages/ReservationPanel.jsx. Authorization boundaries ensure student actions apply to their own reservations and librarians manage circulation transitions.
Reading-room seating
Seat booking is a separate resource flow from book reservations. The Express seat API (backend/routes/seatRoutes.js, backend/controllers/seatController.js) reads and updates seating state persisted in MySQL. Students use the live-polled seat grid at frontend/src/pages/ReadingRoom.jsx; librarians observe occupancy and occupant information at frontend/src/pages/SeatingMonitor.jsx. RTK Query seat endpoints in frontend/src/redux/features/seat/seatApi.js provide client fetch/mutation and polling integration.
Static assets and operational boundaries
Book cover images are local static assets under frontend/public/covers, produced by backend/scripts/download-covers.js; client URL resolution is isolated in frontend/src/utils/coverUrl.js. Backend public storage also exists at backend/public/covers, creating an operational asset boundary separate from API/database data. Environment files configure DB credentials, JWT secrets, and frontend API origin: backend/.env.example, frontend/.env.example.
Main entry points: Routes.jsx Role-based routes · index.js Express server · baseApi.js RTK Query client · authMiddleware.js Auth and role gates
Components 19
React/Vite client
- React bootstrap
frontend/src/main.jsx - Role-based routes · Composes separate student and administrator screens.
frontend/src/routes/Routes.jsx - Auth state
frontend/src/redux/features/auth/authSlice.js - Protected navigation
frontend/src/components/layout/ProtectedRoute.jsx - RTK Query client · Shared environment-configured API client.
frontend/src/redux/api/baseApi.js - Student catalog
frontend/src/pages/BookCatalog.jsx - My reservations
frontend/src/pages/MyReservations.jsx - Reading room · Live-polled seat grid.
frontend/src/pages/ReadingRoom.jsx - Librarian operations · Inventory, circulation, and seating oversight.
frontend/src/pages/BookInventory.jsx
Express API
- Express server · Mounts auth, book, reservation, and seat routers.
backend/index.js - Auth controller · Handles credentials, JWTs, and refresh-token cookies.
backend/controllers/authController.js - Auth and role gates · Establishes request identity and restricts librarian operations.
backend/middleware/authMiddleware.js - Book API · Routes and shapes catalog and inventory data.
backend/controllers/bookController.js - Reservation API · Enforces student ownership and librarian lifecycle transitions.
backend/controllers/reservationController.js - Seat API · Reads and updates reading-room occupancy.
backend/controllers/seatController.js
Data and assets
- MySQL 8 · Stores identities, books, reservations, and seating state.
db/schema.sql - Book cover assets · Local client and backend cover storage.
frontend/public/covers
Deployment
- Netlify frontend
netlify.toml - Render API service
render.yaml
Connections 25
- React bootstrap → Role-based routes: renders
- Role-based routes → Protected navigation: guards role screens
- Auth state → Protected navigation: supplies session state
- Role-based routes → Student catalog: student route
- Role-based routes → My reservations: student route
- Role-based routes → Reading room: student route
- Role-based routes → Librarian operations: librarian routes
- Student catalog → RTK Query client: book queries
- My reservations → RTK Query client: reservation mutations
- Reading room → RTK Query client: seat polling
- Librarian operations → RTK Query client: admin operations
- Auth state → Express server: login and refresh
- RTK Query client → Express server: HTTP API
- Express server → Auth controller: auth routes
- Express server → Auth and role gates: protected requests
- Auth and role gates → Book API: authorizes inventory
- Auth and role gates → Reservation API: authorizes circulation
- Auth and role gates → Seat API: authorizes seating
- Auth controller → MySQL 8: users and tokens
- Book API → MySQL 8: books and inventory
- Reservation API → MySQL 8: reservation state
- Seat API → MySQL 8: seat state
- Student catalog → Book cover assets: cover URLs
- Netlify frontend → React bootstrap: serves client
- Render API service → Express server: runs API