How zakariaghrib/nfccard works
Project type and purpose
• This is a single‐page application (SPA) built with React and Vite.
• Purpose: an educational administration dashboard with two roles (admin and professeur) supporting login, dashboard views, CRUD pages (etudiants, filieres, modules, présences, salles, séances), and live presence tracking.
File structure
• Top level: package.json, vite.config.js, index.html, public/ (static assets), src/ (application source).
• src/main.jsx & index.html: entry points for the React app.
• src/App.jsx: root component that sets up routing and global providers.
• src/layouts: layout wrappers (AdminLayout, ProfLayout) handling common UI shell per role.
• src/pages: role‐specific pages under admin/ and professeur/.
• src/components: reusable components (DashboardWidget, Sidebar variants).
• src/assets: images and static assets referenced by components.
• Configs: eslint.config.js for lint rules, vite.config.js for build/dev-server behavior.
Key insights from README
• Uses Vite for fast bundling and HMR.
• React refreshed via plugin-react or plugin-react-swc.
• ESLint integration recommended for code quality.
Main components
a. Client (Browser)
• Runs the built SPA, interacts via HTTP(s) to backend APIs.
b. Frontend Application
• Vite Dev Server (during development with HMR).
• Bundler/Build pipeline (vite build producing static assets).
• React App
• EntryPoint: index.html + main.jsx
• Core Modules: App.jsx (router), Layouts, Pages, Components, Assets, Stylesheet (index.css)
c. Backend API Layer (external to this repo)
• Authentication service (login endpoint, JWT or session)
• Data service for students, filieres, modules, presence, salles, séances
d. Persistent Storage
• Relational or NoSQL database behind the API
e. Optional services
• CDN for serving static assets (the built SPA)
• Monitoring/logging (e.g., Sentry, Datadog)
• CI/CD pipeline invoking vite build, lint, tests, and deployment
Relationships and interactions
• Browser → (HTTP) → Frontend App (served by CDN or static server)
• Frontend App → (REST/GraphQL calls) → Backend API
• API → (DB queries) → Database
• Vite Dev Server ↔ Browser (WebSocket HMR) during development
• CI/CD → (build & deploy) → Static hosting / CDN & API hosting
Architectural patterns and principles
• Component‐based UI (React) with separation of concerns: Layout vs. Page vs. UI Component
• Role‐based routing and layout composition (AdminLayout, ProfLayout)
• Asset‐folder pattern: public vs. src/assets for static vs. imported assets
• Build vs. Dev environments managed by Vite config
• Linting as part of CI to enforce code quality
Detail
• Every layer from developer workflow (lint, dev‐server, HMR) through build (vite build) to deployment (static host).
• Clearly separate reusable “components” vs. “pages” vs. “layouts.”
• Role‐based UI flows: e.g., after login, user is routed to AdminLayout or ProfLayout.
• Do not overcrowd: use zoom‐in callouts for deep dives (e.g., inside src/components).