How suunidhi/campuschain_v2 works
1. Overall shape: This repository is split into two independently packaged apps: a Node/Express backend in backend/ and a React/Vite single-page frontend in frontend/. The architecture is a standard client–server split with the frontend consuming HTTP APIs from the backend.
2. Backend runtime and entrypoint: backend/server.js is the backend bootstrap point. It is responsible for wiring the Express app together with database connectivity, authentication setup, and route registration.
3. Backend data layer: backend/models/User.js and backend/models/Product.js define the core persisted entities. Their presence, together with backend/config/db.js, indicates a model-driven persistence layer, very likely backed by MongoDB/Mongoose-style document storage.
4. Backend authentication: Authentication is centralized through backend/config/passport.js and backend/middleware/auth.js. Passport config suggests strategy-based login handling, while the auth middleware is the boundary that protects private API routes and enforces session/token checks.
5. Backend API surface: The API is organized by resource in backend/routes/authRoutes.js, backend/routes/userRoutes.js, and backend/routes/productRoutes.js. This suggests separate concerns for login/registration, user profile or account operations, and product/item CRUD.
6. Backend request flow: Requests enter the Express server, pass through auth middleware where needed, then reach route handlers, which read/write the User/Product models and return JSON responses. Protected endpoints likely depend on Passport-derived identity or request context.
7. Frontend application shell: The frontend is a React SPA bootstrapped from frontend/src/main.jsx and composed in frontend/src/App.jsx. It uses page-level components under frontend/src/pages/ and shared UI in frontend/src/components/.
8. Frontend navigation and screens: The main user flows are represented by Home, Login, Register, Dashboard, Marketplace, ListItem, and AuthCallback. This implies the app supports onboarding/authentication, a user dashboard, a marketplace browsing experience, and a flow for creating listings.
9. Frontend API boundary: frontend/src/api/axios.js is the shared HTTP client layer, so all backend communication is funneled through a centralized Axios configuration. frontend/src/config.js likely holds runtime values such as backend base URLs or environment-specific settings.
10. Client-side state and auth support: frontend/src/utils/storage.js abstracts browser storage for session/auth data, and frontend/src/utils/wallet.js suggests wallet-related interaction or identity handling on the client. AuthCallback.jsx indicates the app may complete an external auth redirect or wallet-auth handshake before entering the main UI.
11. Shared UI and presentation: Navbar, Footer, and PolygonBg are reusable UI elements that frame the pages and provide consistent styling/navigation. CSS is split between global styles (index.css, App.css) and component-specific styles (navbar.css).
12. Important architectural boundary: The repo keeps backend logic, persistence, and auth enforcement entirely in backend/, while the React app remains a thin client concerned with routing, UI state, and calling APIs. Any architecture diagram should show the frontend talking only to the backend API, with the backend owning authorization and data access.
Main entry points: App.jsx App Shell · server.js Server · authRoutes.js Auth API · userRoutes.js User API
Components 25
Backend
Express API, auth, and persistence
- Server · Wires middleware, auth, database, and routes.
backend/server.js - DB Config · Database connection setup for the backend.
backend/config/db.js - Passport · Configures authentication strategy handling.
backend/config/passport.js - Auth MW · Protects private routes and checks identity.
backend/middleware/auth.js - User · Persistent user/account entity.
backend/models/User.js - Product · Persistent product/listing entity.
backend/models/Product.js - Auth API · Login and registration endpoints.
backend/routes/authRoutes.js - User API · User/account endpoints.
backend/routes/userRoutes.js - Product API · Product CRUD and listing endpoints.
backend/routes/productRoutes.js
Frontend
React SPA and client-side flows
- Main · Bootstraps the SPA.
frontend/src/main.jsx - App Shell · Top-level routing and composition.
frontend/src/App.jsx - API Client · Shared HTTP client for backend requests.
frontend/src/api/axios.js - Config · Frontend runtime settings and base values.
frontend/src/config.js - Storage · Browser storage abstraction for auth/session data.
frontend/src/utils/storage.js - Wallet · Wallet or identity interaction helpers.
frontend/src/utils/wallet.js - Navbar · Primary navigation bar.
frontend/src/components/Navbar.jsx - Footer · Page footer component.
frontend/src/components/Footer.jsx - Bg · Decorative background component.
frontend/src/components/PolygonBg.jsx - Home · Landing page.
frontend/src/pages/Home.jsx - Login · Sign-in flow.
frontend/src/pages/Login.jsx - Register · Account creation flow.
frontend/src/pages/Register.jsx - Dashboard · Authenticated user workspace.
frontend/src/pages/Dashboard.jsx - Marketplace · Browse listings and products.
frontend/src/pages/Marketplace.jsx - List Item · Create a new listing.
frontend/src/pages/ListItem.jsx - Auth Callback · Completes redirect-based auth or handshake.
frontend/src/pages/AuthCallback.jsx
Connections 30
- Server → DB Config: connects · Initializes persistence before serving requests.
- Server → Passport: configures · Registers authentication strategy setup.
- Server → Auth API: mounts · Exposes auth endpoints.
- Server → User API: mounts · Exposes user endpoints.
- Server → Product API: mounts · Exposes product endpoints.
- Auth API → Passport: uses · Delegates login/auth flow handling.
- User API → Auth MW: protects · Applies request guards to private user routes.
- Product API → Auth MW: protects · Applies request guards to private product routes.
- Auth API → User: reads/writes · Creates and validates user records.
- User API → User: reads/writes · Loads and updates account data.
- Product API → Product: reads/writes · Creates and queries product data.
- User → DB Config: persists via · Stored through the configured database layer.
- Product → DB Config: persists via · Stored through the configured database layer.
- Main → App Shell: renders · Starts the application shell.
- App Shell → API Client: calls · Uses shared API client for backend communication.
- App Shell → Config: reads · Consumes runtime configuration.
- App Shell → Storage: uses · Loads and stores session/auth data.
- App Shell → Wallet: uses · Supports wallet or external identity flows.
- App Shell → Navbar: composes · Includes shared navigation.
- App Shell → Footer: composes · Includes shared footer.
- App Shell → Bg: composes · Includes decorative background.
- App Shell → Home: routes to · Hosts the landing screen.
- App Shell → Login: routes to · Hosts sign-in flow.
- App Shell → Register: routes to · Hosts registration flow.
- App Shell → Dashboard: routes to · Hosts authenticated workspace.
- App Shell → Marketplace: routes to · Hosts marketplace browsing.
- App Shell → List Item: routes to · Hosts listing creation.
- App Shell → Auth Callback: routes to · Completes redirect-based auth flow.
- API Client → Server: HTTP API · Frontend talks to backend over HTTP.
- Auth Callback → Storage: stores · Persists auth/session result after callback.