-
Notifications
You must be signed in to change notification settings - Fork 26
Project Structure:
Andrii Sharmar edited this page Nov 23, 2024
·
5 revisions
The CodeQuestAPI project follows a typical MVC (Model-View-Controller) pattern to ensure the separation of concerns, making the project modular, easier to maintain, and scalable. Below is a detailed breakdown of the structure:
-
config/:
- swagger.config.js: Configuration for Swagger documentation to generate API definitions.
- model.txt: Documentation or configuration details about the application’s data models.
-
controllers/:
- api.controllers.js: Handles the logic for the API routes, such as fetching questions or interacting with other services.
- index.controllers.js: Handles the logic for the general application routes, including static pages like home, about, or documentation.
-
models/:
- question.model.js: Defines the structure/schema of the "Questions" collection in MongoDB using Mongoose. This includes fields like question text, answer options, categories, code examples, and explanations.
-
public/:
- This directory contains static files such as CSS, JavaScript, images, and icons used for rendering the web pages.
- css/: Custom CSS files for styling the application.
- images/: Stores images used in the application.
- icons/: Stores various icons used in the user interface.
-
resources/:
- Stores resource files like Excel templates for exporting questions to platforms such as Kahoot or Blooket.
-
routes/:
- index.routes.js: Defines routes related to the main application pages (e.g., home, about, forms).
- api.routes.js: Defines API routes (e.g., for random questions or AI-generated questions).
-
services/:
- email.services.js: Implements functionality for sending emails to subscribers, including weekly questions and newsletters.
- question.services.js: Implements logic to interact with the database related to questions, such as fetching random questions, AI-generated questions, and storing new questions.
-
test/:
- Contains unit and integration tests for the different services, controllers, and routes, ensuring that the application's functionality is correct and reliable.
- AiGeneratedQuestions.test.js: Tests for the AI-generated questions functionality.
- question.test.js: Tests related to the question services and model.
-
utils/:
- aiPrompt.js: Helper to create prompts for AI-generated questions.
- constants.js: Stores reusable constants like categories and API keys.
- db.js: Database connection utility for MongoDB using Mongoose.
- email.template.js: Stores HTML templates for emails used in newsletters and weekly questions.
- markdownToJson.js: Utility to convert Markdown files into JSON format for data processing.
- utils.js: Miscellaneous utility functions used across the project.
- output/: Stores any generated output files, such as exported questions.
-
views/:
- partials/: Contains partial EJS templates used across different views (e.g., header, navigation bar, error pages).
- Main Templates: Templates for the different pages served by the application, such as home.ejs, about-us.ejs, daily-question.ejs, docs.ejs, and more.
-
.env: Environment configuration file. Stores sensitive data like database URI, API keys, Mailchimp key, etc.
-
package.json: Contains metadata about the project and lists its dependencies and scripts.
-
app.js: The entry point of the application, setting up the Express server, middleware, rate limiting, and loading all the required routes.