How mjwhite10/diverr works
Overall Project Breakdown
• Two major layers:
• Frontend Client: Built with React and organized into pages, components, hooks, context, services, and utilities.
• Backend API Server: A Node/Express application that exposes RESTful endpoints, controls business logic through controllers (for users and diverrs), and connects to an SQL database.
• Database as a separate component, using the provided SQL schema definitions and relationships (User, Diverrs, States, Categories, Solutions, and Comments).
Main Components and Their Interactions
a. Frontend (React):
• Pages: Representing various views (HomePage, DiverrPage, LoginPage, RegisterPage, etc.).
• Components: Divided into smaller, reusable UI pieces (Header, Footer, DiverrCard, Comment, etc.).
• Context Providers: AuthContext and QueryContext that manage authentication state and search functionalities.
• Services & Utilities: API service functions to handle HTTP calls (userService, diverrService, API utility).
• Hooks: Custom hooks (e.g., useDiverr, useMyDiverrs, useCategories) for managing data fetching and state.
b. Backend (Express API):
• Server Bootstrap: The entry point (server.js) that sets up the Express server and middleware.
• Controllers: Separated by domain (users and diverrs). The controllers folder further divides operations into CRUD actions (e.g., new, delete, edit, list, get) for both users and diverrs (and their associated comments/solutions).
• Middlewares: For authentication and role verification (e.g., isUser, isAdmin) ensuring proper access control.
• Validators: To enforce correct request payloads (diverrsValidators.js and userValidators.js).
• Database Layer: Contains database initialization (initDB.js), queries (getDB.js), and SQL file (diverr.sql). It represents the connection and interactions with the SQL-based datastore.
• Helpers & Utilities: Shared functions that orchestrate common logic across controllers.
c. Database:
• A SQL database that stores:
• Users (with credentials, profile details, etc.)
• Diverrs (each digital service need with title, info, file associations, price, etc.)
• Comments, Solutions, Categories, and Statuses for diverrs.
• For the Frontend:
• Main sub-components (Pages, Components, Contexts, Hooks, Services, Utilities).
• For the Backend:
• Backend to the Database indicating CRUD operations performed by the backend.
• For the Database:
• Data flow from Backend → Database and vice versa.
• Optionally, indicate the testing and configuration files (like .env, .eslint, etc.) as supporting the overall configuration and reliability of the system.
Emphasizing Architectural Patterns and Technologies
• That the project employs a layered architecture:
• The presentation layer (React Frontend) is decoupled from business logic (Express backend).
• The backend itself follows a controller-service pattern with middleware for authentication/authorization.
• That RESTful API endpoints are used for all interactions, following a typical full-stack pattern.