How maru33luc/nodejs---fkstore- works
Main Components
• Client/Frontend: Represented by static assets (HTML templates, CSS files, JavaScript files, and images) under the “public” folder. This is where browser interactions occur.
• Server/Backend: The main entry point (app.js) using Express. It houses controllers (in src/controllers), middleware (in src/middlewares), and route definitions (in src/routes) that determine how HTTP requests are processed.
• Views: The EJS templates found under src/views (and its subdirectories for admin, auth, shop, etc.) which are used by the backend to render dynamic HTML pages.
• Data Layer: Instead of a traditional database, FunkoShop uses JSON files stored in the “data” folder (carts.js, db.js, users.js) to persist information.
• External Services/Utilities: While not connected to external APIs per se, the use of libraries such as Bcrypt, Express Validator, and possibly others (like glide.js for frontend interactions) represent key technology dependencies.
Relationships and Interactions
• Controller Processing: Within the server block, add components for controllers (like adminController.js, authController.js, mainController.js, shopController.js) that process incoming requests, decide business logic, and choose which view to render.
• Middleware: Indicate usage of middleware (ensuring authentication, admin authorization, and input validation) that intercepts requests before reaching the controllers.
• Data Services: Connect the controllers to service components (cartServices.js, funkoServices.js, userServices.js) that interact with the JSON data files (data/carts.js, data/db.js, data/users.js) to read and update state.
Architectural Patterns & Design Principles
• MVC Pattern: The separation of concerns is evident with Controllers managing logic, Views handling presentation with EJS, and a simplistic model/data access through JSON files.
• Layered Structure: Distinct layers (routes, middleware, controllers, services, and data) help in maintaining the clean separation of logic.
• Modular Routing: The project clearly separates routes based on functionality (adminRoutes, authRoutes, mainRoutes, shopRoutes).
Technical Stack & Key Technologies
• Backend: Node.js with Express for request handling.
• Template Engine: EJS for dynamic HTML rendering.
• Frontend: Static assets (CSS, JavaScript, images) are managed under the public directory.
• Dependencies: Bcrypt for secure password handling, Express Validator for input checks.
• Data Storage: JSON-based persistence (data files).
Putting It All Together
• Start at the Browser level, linking to the endpoint definitions (like /login, /register, /admin, /shop, etc.).
• How controllers then invoke the services to manipulate JSON data.