How chenna319/dorm-mangement-app works
Project Type and Purpose
• Project Type: React SPA (frontend‑only) for dormitory management.
• Purpose: Enable users to sign up/in, view a dashboard, manage rooms & residents, and persist session data in browser localStorage.
Main Architectural Components
a. Client (Browser)
b. React Application
• Entry point: src/main.jsx
• Root component & router: src/App.jsx + React Router
• Pages: src/pages (Dashboard, Rooms, RoomDetails, AddRoom, AddResident, Login, Register)
• Shared UI components: src/components (Layout, Sidebar, ProtectedRoute)
• State management: src/context/AuthContext.jsx + custom hook useAuth (src/hooks/useAuth.js)
• Utilities: src/utils/localStorage.js
c. Styling engine: Tailwind CSS (configured in tailwind.config.js, postcss.config.js)
d. Build & Packaging: Vite (vite.config.js)
e. Hosting & Deployment: Vercel (vercel.json) serving static assets from /public + build output
Data Flows and Interactions
• On initial load, Vercel/CDN serves index.html → main.jsx bootstraps the React SPA.
• App.jsx uses React Router to decide which Page component to render.
• AuthContext wraps the component tree:
– Exposes user state and auth functions.
– Persists/loads session via localStorage (src/utils/localStorage.js).
• ProtectedRoute checks AuthContext before granting access to private pages (Dashboard, Rooms, etc.).
• Components dispatch actions to AuthContext (via useAuth) to update state and localStorage.
• Pages call context or local state to fetch and update room/resident data (all in‑memory or localStorage, no external backend).
• Sidebar and Layout render navigation/structure consistently across private pages.
Build & Deployment Workflow
1. Developer commits code → pushes to Git (e.g., GitHub).
2. Vercel CI/CD detects push → runs npm install & npm run build (Vite).
3. Built static assets (/dist) are deployed to Vercel’s CDN.
4. End users’ browsers request index.html and associated assets via HTTPS.
Architectural Patterns & Design Principles
• Component‑based architecture (separation of concerns).
• Declarative UI with React.
• Context API + custom hooks for state & side‑effect management.
• Single‑page routing via React Router.
• Utility‑first styling with Tailwind CSS.
• Static hosting (Jamstack) – no server‑side code.
• Clear, concise labels for each component and file grouping (e.g., “src/context/AuthContext”).
• Legends or annotations for key config files (vite.config.js, tailwind.config.js, vercel.json).