How q0k0late/virtual-art-gallery works
Main Components
• Frontend Client:
• “views” layer that uses the EJS template engine, organized into sections (artworks, exhibitions, pages, purchases, and users).
• Static assets served from the “public” directory (CSS, JavaScript—including the Three.js-based exhibition script—and uploads).
• Backend Server:
• The core Express.js application (app.js) that handles incoming HTTP requests.
• “Routes” are distributed across multiple files (artworkRoutes.js, exhibitionRoutes.js, etc.) for RESTful endpoints.
• “Controllers” implement the business logic for each resource (artwork, exhibition, purchase, user, etc.).
• “Middleware” for authentication, file uploads, and other request-processing functions.
• Data and Persistence:
• Mongoose-powered models (Artwork.js, Exhibition.js, Purchase.js, User.js) that interact with MongoDB.
• A configuration module under “config/db.js” that sets up the database connection.
• Authentication & Security:
• Passport.js integration configured in “config/passport.js” and supported by custom auth middleware.
• External Services and APIs:
• The “services” directory (apiService.js) for handling external API calls such as the weather API and Art Institute of Chicago API.
• Additional Infrastructure:
• Environment configuration (.env file in production) and build/deployment instructions.
• Integration of additional tools like Multer (file upload handling), Connect-flash (flash messages), and method-override for handling RESTful routes.
Relationships and Interactions
• The client (browser) sends HTTP requests to various route endpoints.
• Routes then direct these requests to dedicated controllers.
• Controllers process input and interact with both the models (for CRUD operations on MongoDB) and external services via the service layer.
• Middleware functions act as gatekeepers, managing authentication (Passport via routes/middleware/auth.js) and file uploads (middleware/upload.js) prior to request processing.
• Static assets and view templates deliver the interactive front-end experience (including 3D visualization with Three.js).
• Configuration modules handle setup for database connections and authentication strategies.
Architectural Patterns
• The project follows an MVC style separation:
• Models represent the data (Mongoose schemas).
• Views (EJS templates) render the data.
• Controllers mediate between the models and views.
• The design also uses modular routing, which means the system is decomposed into several domain-specific service layers (artworks, exhibitions, users, purchases).
• Incorporation of external API integrations highlights a service-oriented mindset, isolating API calls in a dedicated services component.
Relevant Technologies and Frameworks
• Backend: Node.js, Express.js, MongoDB (Mongoose ODM), Passport.js (authentication).
• Frontend: EJS template engine, Bootstrap 5, client-side JavaScript, and Three.js for interactive 3D experiences.
• Utility Libraries: Multer (file handling), Connect-flash (notifications), and method-override.