How win24-gruppprojekt/frontend works
Project type and purpose
• This is a Single-Page Application (SPA) frontend built with React and Vite.
• Its purpose is to provide a user portal (gym members) and trainer portal (session creation) that integrates with multiple backend microservices (Events, Venues, Bookings, Auth, Notifications).
• It’s hosted as a static web app (Azure Static Web Apps via .github/workflows/...yml) and communicates exclusively over RESTful HTTP.
File structure
Top-level:
• index.html, public/staticwebapp.config.json → static host entry point & routing rules
• vite.config.js, .env → build & environment configuration
• src/ → all React source code
– layouts/ → layout components (LandingLayout, PortalLayout)
– pages/ → top-level pages (StartPage, SessionListPage, ProfilePage, etc.)
– components/ → reusable UI (SessionCard, Header, modals, buttons, filters, etc.)
– lib/api.js & lib/http.js → wrapper around fetch for token injection, retries, error handling
– main.jsx & App.jsx → root of React router & context setup
• .eslint.config.js → coding standards
• package.json → dependencies (React, React Router, react-spinners, etc.)
README insights
• Confirms React 18 + Vite, React Router DOM for routing, custom CSS, React hooks for state, fetch wrapper for API calls.
• Lists five backend microservices with distinct responsibilities and configurable base URLs via .env (VITE_*_API_BASE_URL).
• Shows role-based UI: trainer vs. member flows.
• Mentions hosted as static web app and used for a school assignment.
• Browser / User device (desktop/mobile)
• Static-hosting environment (Azure Static Web Apps / CDN)
• React SPA (App.jsx + Router + layouts + pages + components)
• API Client (lib/http.js + lib/api.js for token handling + fetch wrapper)
• Five External Microservices:
– AuthService (JWT login/refresh)
– EventService (CRUD sessions)
– VenueService (location data)
– BookingService (book/unbook sessions)
– NotificationService (email confirmations)
• Configuration Layer (.env → VITE_*_API_BASE_URL)
b. Relationships & interactions:
1. Browser requests index.html from Static-host → React assets (JS/CSS).
2. SPA boots, React Router hands off to StartPage or authenticated PortalLayout.
3. User actions (view sessions, book, create) trigger lib/api calls.
4. API client injects JWT (AuthService) and dispatches HTTP requests to the appropriate microservice endpoint.
5. Microservices respond; SPA updates state via hooks and re-renders components.
6. BookingService → on success → NotificationService for email notifications (the SPA may trigger this or the backend orchestrates it).
c. Architectural patterns & design principles:
• SPA pattern with client-side routing (React Router).
• Modular React components (separation of concerns).
• Single API client layer for cross-cutting concerns (logging, retries, auth injection).
• Environment-driven configuration for microservice endpoints.
• Role-based UI rendering (conditional rendering based on JWT claims).
d. Key technologies & frameworks:
• React 18, React Router DOM
• Vite (dev + build tooling)
• Fetch wrapper in src/lib (for retries, token management)
• react-spinners for loading states
• Azure Static Web Apps (CI/CD via GitHub Actions)