How pablo3360/prueba-tecnica-aidforaids works
Project Type and Purpose
• This project is a backend API for a book sales/inventory system. It follows a layered architecture focused on operations such as user authentication, book inventory management, and handling sales, including shopping cart functionality.
• The README clarifies that it is a technical test for a Backend Engineer and highlights security practices, authentication using tokens, image upload via Claudinary, and use of PostgreSQL managed via Sequelize.
Main Components
• API Services: The API is organized into several service domains (book, sales, users) inside the “apiServices” folder. Each domain contains its own controller, DAO, DTO, model, and routes.
• Middleware: There is a dedicated “middleware” folder for cross-cutting concerns (error handling, image processing, authentication).
• Routing: The “routes” directory handles high-level endpoint routing.
• Services: There are specialized services in the “services” folder, such as:
• Claudinary service (for image upload)
• Sequelize-based database service and its models (book, cart, compra, distributor, sale, user)
• Application Entry Point: Files like “app.js” and “index.js” are the starting points that wire up the application.
• External Dependencies: PostgreSQL as the database, Sequelize as the ORM, jsonwebtoken for auth, bcrypt for password hashing, and Claudinary for image storage.
Architectural Layers
• Application Layer: The HTTP server setup, routing, middleware, and API endpoints are part of this layer.
• Business Layer: The controllers and the business logic (note that the controllers in each “apiServices” component orchestrate the request and response flow).
• Data Access Layer: The “dao.js” modules in the API services and the “services/sequelize” folder that contains the database configuration and models represent database interactions.
Relationships and Data Flow
• Requests from clients hit the main API via the routes in “routes/index.js” and service-specific endpoints (e.g., /users/register, /book/create).
• Middleware intercepts requests to handle authentication and error processing.
• Requests are directed to corresponding controllers in each domain (users, book, sales) which invoke DAOs for database operations.
• The Sequelize service then interacts with the PostgreSQL database models.
• For image uploads (user profile), requests delegate to the Claudinary service.
• Responses are sent back along the layered chain (from Data Access up to Application layer).