How noor-2002/natours works
Main Components
• Client/Frontend:
• Static files (HTML, CSS, JS) under the "public" directory.
• Pug templates for server-rendered pages in the "views" and "dev-data/templates" directories.
• Server/Backend:
• Application entry points: "app.js" and "server.js".
• Express routes in the "routes" directory (bookingRoutes.js, reviewRoutes.js, tourRoutes.js, userRoutes.js, viewRoutes.js) that handle API endpoints and web page navigation.
• Controllers in the "controllers" directory implementing business logic (auth, tour, booking, review, error, views, etc.).
• Data models defined via Mongoose in the "models" directory, connecting with a MongoDB Atlas database.
• Utility functions and error handling utilities in the "utils" directory.
• Data Management:
• The "dev-data" directory includes sample dataset files for tours, reviews, and users, as well as scripts (like "import-dev-data.js") to populate the database.
• Third-Party Integrations:
• Authentication with JSON Web Tokens.
• Payment processing via Stripe.
• Email services (using Mailtrap or SendGrid as described in the build info).
• Configuration & Build Tools:
• ESLint, Prettier configurations and Parcel as a bundler (with commands specified in the README).
• Deployment via Heroku (deployment steps are in the README).
Understand Architectural Patterns & Data Flow
• MVC Pattern:
• The project clearly follows an MVC (Model-View-Controller) structure with directories for Models (database schema), Views (Pug templates and static pages), and Controllers (business logic).
• API endpoints vs. rendered views:
• Separate routes for handling API requests (e.g., /api/v1/tours) and view rendering for webpages.
• Dependency Flow:
• The controllers interact with the models for database operations.
• Routes are used to channel incoming requests to the appropriate controller methods.
• The frontend interacts with these endpoints (using AJAX, form submissions, etc.), and static assets are served from the "public" directory.
• Client-side Layer:
• Components like the login, tour overview, and booking pages.
• API Server:
• Node.js application (with "app.js" and "server.js") hosting Express.
• Database:
• External Services:
• Stripe for payment processing.
• Email services (Mailtrap/SendGrid) for notifications.
• Development/Build Tools:
Additional Details
• Use of the MVC pattern and separation of concerns.
• External integrations (Stripe, Email services).
• Marking the dev data seeding process (using "dev-data") as a one-off tool for setting up sample datasets.