How deepanshurajput-2027/intern_task works
Purpose and Entry Points
Store Rating Application is a role-based SaaS for store discovery, 1–5 star ratings, administration, and owner-facing rating analytics. It is a React SPA backed by an Express API and MySQL via Sequelize. Client bootstraps at client/src/main.jsx and server bootstraps through server/src/server.js into server/src/app.js.
Client Application Shell and Routing
React Router defines public, role-protected, and unauthorized views in client/src/routes/AppRoutes.jsx. Authentication state is centralized in client/src/context/AuthContext.jsx; route access is enforced by client/src/components/protected/ProtectedRoute.jsx. Shared authenticated page structure, including navigation/sidebar, is provided by client/src/components/layout/DashboardLayout.jsx and client/src/components/layout/Sidebar.jsx.
Role-Specific UI Modules
Admin pages manage users, stores, and aggregate metrics through client/src/pages/admin/Dashboard.jsx, client/src/pages/admin/Users.jsx, and client/src/pages/admin/Stores.jsx. Users browse/search stores and submit ratings from client/src/pages/user/UserDashboard.jsx with client/src/components/user/RatingModal.jsx. Store owners consume their ratings and settings through client/src/pages/storeOwner/Dashboard.jsx and client/src/components/storeOwner/RatingsTable.jsx.
Client API and State Flow
Views invoke domain hooks such as client/src/hooks/useStores.js, client/src/hooks/useUsers.js, and client/src/hooks/useStoreRatings.js; hooks call role/domain service modules. client/src/api/axios.js owns Axios setup and JWT interceptor behavior, while client/src/services/auth.service.js, client/src/services/admin.service.js, and client/src/services/user.service.js encapsulate API calls. This keeps component rendering separate from remote-data operations and token transport.
API Boundary and Authorization
Express routes partition API capabilities by domain and role: server/src/routes/auth.routes.js, server/src/routes/admin.routes.js, server/src/routes/store.routes.js, and server/src/routes/store-owner.routes.js, collected by server/src/routes/index.js. Requests traverse authentication and RBAC middleware in server/src/middlewares/authenticate.js and server/src/middlewares/authorize.js; controllers validate inputs with domain validators, e.g. server/src/controllers/rating.controller.js and server/src/validators/rating.validator.js.
Backend Business Layers and Persistence
The backend follows controller → service → repository → Sequelize model flow. Domain logic resides in modules such as server/src/services/store.service.js, server/src/services/rating.service.js, and server/src/services/admin.service.js; database access is isolated in corresponding repositories including server/src/repositories/store.repository.js and server/src/repositories/rating.repository.js. Core persisted entities are server/src/models/User.js, server/src/models/Store.js, and server/src/models/Rating.js, with database connection setup in server/src/config/db.js.
Runtime, Security, and Infrastructure
Client runs/builds under Vite; server runs on Node.js/Express. MySQL is the required external datastore, accessed through Sequelize and configured via server/src/config/env.js and server/src/config/db.js. JWT issuance/verification and password hashing are handled by server/src/utils/jwt.js and server/src/utils/password.js. API failures are normalized through server/src/middlewares/errorHandler.js and response/error utilities under server/src/utils/.
Components 20
React Client
- Vite bootstrap
client/src/main.jsx - App routes · Public, protected, and unauthorized views.
client/src/routes/AppRoutes.jsx - Auth state
client/src/context/AuthContext.jsx - Protected route · Enforces authenticated role access.
client/src/components/protected/ProtectedRoute.jsx - Dashboard shell · Authenticated navigation and sidebar.
client/src/components/layout/DashboardLayout.jsx - Role-specific views · Admin management, user ratings, and owner analytics.
client/src/pages/admin/Dashboard.jsx - Domain hooks · Store, user, and rating remote-data hooks.
client/src/hooks/useStores.js - API services · Domain-specific API calls.
client/src/services/auth.service.js - Axios JWT client · Configures requests and JWT interception.
client/src/api/axios.js
Express API
- Express server
server/src/server.js - Express app
server/src/app.js - API routes · Auth, admin, store, and owner route domains.
server/src/routes/index.js - Authentication & RBAC · Verifies JWTs and authorizes roles.
server/src/middlewares/authenticate.js - Controllers & validators · Validates inputs and handles domain requests.
server/src/controllers/rating.controller.js - Business services · Store, rating, and admin business logic.
server/src/services/store.service.js - Error normalization
server/src/middlewares/errorHandler.js
Data & Security
- Repositories · Isolates Sequelize data access.
server/src/repositories/store.repository.js - Sequelize models · User, Store, and Rating entities.
server/src/models/User.js - MySQL
- JWT & password utilities · Issues tokens and hashes passwords.
server/src/utils/jwt.js
Connections 20
- Vite bootstrap → App routes: mounts
- App routes → Auth state: reads session
- App routes → Protected route: protects routes
- Protected route → Dashboard shell: admits
- Dashboard shell → Role-specific views: hosts
- Role-specific views → Domain hooks: uses
- Domain hooks → API services: calls
- API services → Axios JWT client: uses
- Axios JWT client → Express app: HTTPS API requests
- Express server → Express app: starts
- Express app → API routes: mounts
- API routes → Authentication & RBAC: passes protected requests
- Authentication & RBAC → Controllers & validators: authorizes
- Controllers & validators → Business services: delegates
- Business services → Repositories: queries
- Repositories → Sequelize models: uses
- Sequelize models → MySQL: persists via Sequelize
- Authentication & RBAC → JWT & password utilities: verifies JWT
- Business services → JWT & password utilities: issues JWTs / hashes passwords
- Express app → Error normalization: normalizes failures