How vmesteban/react-de-cero-a-experto-hooks-y-mern- works
Project type and purpose
• This is a *monorepo* containing:
– A series of incremental React/JavaScript tutorials and Hooks demos (01-intro-react up through 19-journal-app).
– A full-stack Calendar application built with React on the client, Express/Node on the server, and MongoDB (MERN stack).
• The README title “React-De-cero-a-experto-Hooks-y-MERN” confirms that the end goal is a MERN-stack calendar app.
File structure
• Top-level folders 01- through 21- contain isolated front-end demo apps, each with its own index.html, src/, public/, vite.config.js or CRA config.
• Folders 22-calendar-mern (likely the client), and 23-/24-calendar-Backend-mern contain the MERN-stack:
– Frontend (22-calendar-mern): React components, hooks, styles, routing, build config (vite.config.js).
– Backend (23-calendar-Backend-mern & 24-calendar-Backend-mern): Node.js/Express app with controllers/, routes/, middlewares/, models/, database config, JWT helper.
– Shared: public/index.html served to client; .env for secrets; package.json scripts for starting server & client.
README
• The top-level README is minimal, but each sub-folder (especially 23- and 24-) contains its own README.md describing endpoints and setup.
Main components
a. Client (Browser) – the React single-page application (22-calendar-mern):
• UI components, routes, hooks for form handling and data fetching.
• Calls REST endpoints via fetch/Axios.
b. Server (Node/Express API) – (23-calendar-Backend-mern & 24-calendar-Backend-mern):
• Entry point index.js → configures Express, connects to MongoDB.
• Middlewares: request body parsing, CORS, JWT validation (validar-jwt.js), field validation (validar-campos.js).
• Controllers: auth.js (login, register), events.js (CRUD for calendar events).
• Routes: /api/auth, /api/events.
• Helpers: JWT token generation/verification, date validation.
• Models: Mongoose schemas for Usuario and Evento.
c. Database (MongoDB) – stores users and events; accessed via Mongoose.
d. External Services – none (all self-hosted).
e. Static Hosting – Express serves built React assets in production (public folder).
Relationships & data flows
1. User hits the React app in their browser.
2. React router displays login/register or calendar pages.
3. On login, React sends POST /api/auth to Express.
4. Express authenticates, returns a JWT.
5. React stores JWT (localStorage).
6. Subsequent requests to /api/events include Authorization header.
7. Express middleware validar-jwt verifies token, attaches user info.
8. Controller performs CRUD on Evento model in MongoDB.
9. Express returns JSON to React, which updates the UI.
Architectural patterns & technologies
• Client: SPA built with React + Vite, uses custom React hooks for form & fetch.
• Server: MVC-like layering (routes → controllers → models).
• Auth: JWT-based stateless authentication.
• Data: RESTful endpoints serving JSON.
• Build: Vite for front end, npm scripts for back end.
Essential elements checklist
• Annotations for key middleware (JWT, validation).
• Tech stack callouts (React/Vite, Node/Express, MongoDB/Mongoose).