How rbsuhail/appoint-care works
1. Overall shape
- AppointCare is a classic MERN-style split architecture: a Vite/React client in client/ and a Node/Express API at the repo root.
- The backend talks to MongoDB through Mongoose, and the frontend consumes the API for login, booking, doctor management, and admin operations.
2. Frontend application shell
- The client entrypoint is client/src/main.jsx, which mounts App.jsx.
- Layout.jsx provides the shared application frame, while Spinner.jsx is used for loading states.
- Styling is a mix of index.css and theme.js, with Ant Design used for UI components.
3. Client routing and access control
- The app separates public and authenticated areas using PublicRoute.jsx and ProtectedRoute.jsx.
- This suggests route-level enforcement for roles such as patient/user, doctor, and admin, with the frontend deciding which pages are reachable after auth.
4. Frontend feature areas
- Patient-facing pages include HomePage, BookingPage, Appointments, NotificationPage, Login, and Register.
- Doctor-facing pages live under pages/doctor/ and include Profile and DoctorAppointments.
- Admin pages live under pages/admin/ and include Doctors and Users.
- ApplyDoctor.jsx appears to support a user applying to become a doctor.
5. Frontend state management
- Redux is used for global state via client/src/redux/store.js.
- userSlice.js likely stores authentication/session and current user profile data.
- alertSlice.js handles app-wide notifications or flash messages.
- This implies the client keeps auth and alert state centrally, while page components focus on view logic.
6. Frontend data/modeling
- DoctorCard.jsx is a reusable display component for doctor listings or search results.
- menuData.js likely drives navigation menus, probably varying by role.
- The presence of BookingPage and doctor cards indicates the UI is organized around selecting doctors and booking available slots.
7. Backend API structure
- The server entrypoint is server.js, which likely wires Express middleware, routes, and the database connection.
- API endpoints are split by domain in routes/userRoutes.js, routes/doctorRoutes.js, and routes/adminRoutes.js.
- Controllers mirror that split in controllers/userCtrl.js, doctorCtrl.js, and adminCtrl.js, keeping HTTP routing separate from business logic.
8. Backend business domains
- The main backend domains are users, doctors, and appointments.
- models/userModels.js, doctorModel.js, and appointmentModel.js define the persisted entities.
- From the file names, appointments are probably the core transactional object linking a patient, a doctor, and a time slot.
9. Security and authorization
- middlewares/authMiddleware.js is the key gatekeeper for protected API routes.
- This likely verifies authentication and enforces role-based access for doctor/admin operations.
- The frontend ProtectedRoute/PublicRoute components and backend auth middleware work together as layered access control.
10. Database and persistence
- config/db.js centralizes the MongoDB connection setup.
- Mongoose models define the schema boundary between application logic and persistence.
- This means the backend is stateful through MongoDB, while the frontend remains a consumer of API responses.
11. Request/data flow
- A typical flow is: client page → Redux/UI action → API request → Express route → controller → Mongoose model → MongoDB → response back to client.
- Booking and appointment management are likely the most important end-to-end flows, because they touch both doctor availability and user scheduling.
12. Operational/tooling boundaries
- The client is built with Vite; the repo also includes separate package.json files for the root and client, indicating distinct runtime/build concerns.
- The README mentions Concurrently and Nodemon, so development likely runs frontend and backend together with hot reload on the server side.
- No external services are visible in the tree beyond MongoDB, so the architecture appears self-contained around the API/database boundary.
Main entry points: App.jsx App shell · store.js Redux store · userRoutes.js API routes · BookingPage.jsx Booking
Components 21
Client
Vite/React frontend and UI state
- App entry · Mounts the client app and boots the UI
client/src/main.jsx - App shell · Top-level app composition and routing hub
client/src/App.jsx - Layout · Shared application chrome and page framing
client/src/components/Layout.jsx - Route guards · Separates public and protected client areas
client/src/components/PublicRoute.jsx - Redux store · Central client state container
client/src/redux/store.js - User state · Stores current user and authentication context
client/src/redux/features/userSlice.js - Alerts · Global flash and alert message state
client/src/redux/features/alertSlice.js - Home · Public landing and discovery page
client/src/pages/HomePage.jsx - Booking · Selects doctors and schedules appointments
client/src/pages/BookingPage.jsx - Appointments · Shows booked appointments and status
client/src/pages/Appointments.jsx - Login & register · User authentication and onboarding pages
client/src/pages/Login.jsx - Doctor area · Doctor profile and appointment management views
client/src/pages/doctor/Profile.jsx - Admin area · Doctor and user administration views
client/src/pages/admin/Doctors.jsx - Doctor card · Displays doctor summaries in lists and search results
client/src/components/DoctorCard.jsx - Menu data · Drives role-aware navigation and menus
client/src/data/menuData.js
Backend
Express API, domain logic, and persistence
- Server · Starts the API server and wires middleware and routes
server.js - API routes · Domain route modules for users, doctors, and admins
routes/userRoutes.js - Controllers · HTTP handlers split by domain
controllers/userCtrl.js - Auth middleware · Protects routes and enforces role-based access
middlewares/authMiddleware.js - Domain models · User, doctor, and appointment persistence schemas
models/userModels.js - Mongo config · MongoDB connection setup
config/db.js
Connections 22
- App entry → App shell: boots · Client entry mounts the application shell
- App shell → Layout: uses · App composes the shared page frame
- App shell → Route guards: protects · Routes split public and authenticated areas
- App shell → Redux store: connects · App reads from the shared Redux store
- Redux store → User state: contains · Store includes authentication and profile state
- Redux store → Alerts: contains · Store includes app-wide alert state
- App shell → Home: shows · Public entry includes the home page
- App shell → Booking: shows · Authenticated users can reach booking flows
- App shell → Appointments: shows · Users view their appointment history and status
- App shell → Login & register: shows · Authentication pages handle login and registration
- App shell → Doctor area: shows · Doctor-specific views live in the protected area
- App shell → Admin area: shows · Admin-specific views live in the protected area
- Booking → Doctor card: renders · Booking and discovery flows reuse doctor cards
- App shell → Menu data: drives · Navigation varies by role and session state
- Server → API routes: mounts · Server registers domain route modules
- API routes → Controllers: delegates · Routes hand off request handling to controllers
- API routes → Auth middleware: guards · Protected endpoints are wrapped with auth checks
- Controllers → Domain models: reads/writes · Controllers operate on persisted domain entities
- Domain models → Mongo config: connects via · Models depend on the MongoDB connection
- Redux store → Booking: feeds · Auth and session state support booking actions
- App shell → Server: calls API · Frontend pages request data and submit actions to the backend
- Auth middleware → Route guards: mirrors · Backend authorization complements client-side route guards