How guptaryan73/aahar works
Main Components
• Frontend:
• EJS templates located under the “views” directory (with subdirectories for admin, agent, donor, auth, home and common partials).
• Static assets – CSS, JavaScript, and images in the “assets” folder.
• Backend:
• The main application defined in “app.js”.
• Routing modules under the “routes” directory, individually serving admin, agent, donor, auth, and home functionalities.
• Middleware in the “middleware” folder to manage request processing.
• Authentication is handled with Passport.js, as indicated in “config/passport.js”.
• Database:
• MongoDB is configured via “config/dbConnection.js” and environment variables in the “.env” file.
• Models:
• Data models defined under the “models” directory (e.g., user.js, donation.js) that contain schema definitions and represent collections in MongoDB.
• Configuration:
• Application configuration and environment settings via the “config” folder.
Relationships and Interactions
• Data Flow:
• Users interact via the Frontend (rendered EJS pages) which submits requests to the backend endpoints.
• The Express server (app.js) routes these requests through role-specific routes (admin.js, agent.js, donor.js, auth.js, home.js).
• Controllers (implicitly part of the route handlers) interact with the database through models.
• Passport.js integrated within the backend handles user authentication and session management.
• Separation of Concerns:
• Clear divisions between static content (assets), dynamic content (EJS views), business logic (routes and middleware), and data persistence (MongoDB models).
Architectural Patterns and Key Principles
• MVC-like Structure:
• Role-Based Access Control:
• Distinct routes and view folders indicate careful handling of different user roles (donor, agent, admin).
• Modularization:
• The application is broken down into modular directories (routing, middleware, models) to promote separation of concerns and maintainability.
• Real-time Updates (if any WebSockets or other schemes are used, otherwise it is mainly via HTTP requests).
Relevant Technologies
• Frontend: EJS, Bootstrap, CSS/JS assets.
• Backend: Node.js, Express.
• Authentication: Passport.js.
• Database: MongoDB.
• Configuration Management: Environment variables in .env.
Specific Elements
• Clear labels for each component:
• How users interact with the frontend and how requests are routed to the backend.
• Connection from the backend to the MongoDB.