How edgardortega/proyecto_ejtech works
Project Type & Purpose
• This is a full-stack web application (a Marketplace named EJtech) that allows users (Clientes and Administradores) to browse, purchase, and manage technology products.
• The README details separate flows for user authentication, product browsing, shopping cart operations, and administrative tasks like managing products and users.
Main Components
a. Frontend Client:
• Built with ReactJS (using React Router for navigation).
• Responsible for rendering views (Home, Galeria, Carrito, Login, Register, Profile, etc.) and interacting with the backend via HTTP calls (Axios).
• Organized into components, view pages, and context providers (AuthContext, CartContext, HistoryContext).
• Uses Vite for development and React-Bootstrap/Bootstrap for UI styling.
b. Backend Server:
• Built on Node.js with Express.js.
• Entry point: index.js which sets up the server and integrates middleware (authentication with authMiddleware, logger, etc.).
• Defines multiple route modules (authRoutes, productRoutes, userRoutes, orderRoutes, etc.) to handle RESTful API endpoints.
• Uses JWT for authentication and bcrypt for password encryption.
• Has an SQL script (script.sql) for PostgreSQL database setup.
• Contains test directories for API testing (using jest & supertest).
c. Database:
• PostgreSQL is used as the database.
• The provided SQL script sets up tables (usuario, rol, categoria, producto, carrito, orden, detalle_orden) capturing the application’s relational model.
d. External/Supporting Elements:
• Environment configuration files (the .env files for both backend and frontend).
• Deployment details (Render deploy link, PGAdmin for managing the database).
• Tools like nodemon for hot reloading and ESLint for code quality.
Relationships & Interactions
• The Frontend communicates with the Backend via HTTP/REST API calls (managed by Axios).
• The Backend handles these requests by interfacing with the PostgreSQL database to perform CRUD operations.
• Authentication is managed at the backend with JWT tokens which are provided to the frontend during login.
• Middleware processes (logging, authentication) ensure data integrity and security across requests.
• There are clear role-based flows: Admins can access additional endpoints to manage products and users while clients have different route accesses.
Architectural Patterns & Design Principles
• Separation of Concerns: Clear division between presentation (React frontend) and logic (Express backend).
• Layered Architecture: The backend segregates routing, middleware, and database access.
• RESTful API design: Distinct routes for each resource (users, products, orders) promoting modularity.
• Use of context providers in React promotes state management (for user authentication, cart data, and history).
Final Assembly
1. Client Layer: Frontend (React, context, components).
2. Application Layer: Backend (Express server, middleware, RESTful endpoints).
3. Data Layer: PostgreSQL (table schema as shown in the SQL script).
• Use annotations around “Role-based Access Control” to denote routes/views available for Administrators and Clients.
Happy diagramming!