How rodobriones/vino_costero works
Project Type & Purpose
• This is a full-stack web application (MVP) for vineyard management: Node.js/Express backend, React frontend (Vite), MySQL database.
• The frontend serves user interfaces for managing “catas,” “parcelas,” “lotes,” etc., and the backend exposes a REST API that interacts with MySQL.
High-Level Components
a. Web Browser & Frontend (web/)
• React SPA (Vite): pages under src/pages (Catas.jsx, Dashboard.jsx, etc.)
• Context/Auth layer (src/context/auth.jsx)
• HTTP client module (src/api/http.js) for making AJAX calls
b. Backend API (server/)
• Express app (app.js)
• Route handlers (server/routes/*.routes.js) for each entity (auth, catas, enfermedades, etc.)
• Auth middleware (server/middleware/auth.js)
• Database connector (server/db.js)
c. Database
• MySQL 8 schema and seed files (sql/schema.sql, sql/seeds.sql per README)
d. Development & Deployment
• .env for configuration
• NPM scripts (npm run dev)
• Vite config (web/vite.config.js)
Interactions & Data Flow
1) User in Browser
→ loads React app (served by Vite dev server on localhost:5173)
2) React App
→ uses http.js to send REST requests (GET/POST/PUT/DELETE) to backend at localhost:4000
3) Express API
→ auth middleware checks JWT/session
→ routes/*.routes.js handle business logic and call db.js
4) db.js
→ executes SQL queries against MySQL database
5) MySQL
→ persists data, returns results back up the chain to the client
Architectural Patterns & Principles
• Separation of Concerns: Frontend (UI/UX) vs. Backend (API & business logic) vs. Database
• RESTful APIs: one route file per resource (e.g., catas.routes.js handles all /catas endpoints)
• Middleware layering: authentication is applied centrally via auth.js
• Component modularity in React: page components + context + API layer
Final Checklist
• Arrowheads indicating request/response direction
• Notes on ports, environment variables, and key configuration files