From f139cb4714b976ae0f0cd5ca0cc181013ab4c2ee Mon Sep 17 00:00:00 2001 From: Kartik Mehta Date: Wed, 30 Oct 2024 14:56:57 +0530 Subject: [PATCH] Update Folder Structure Docs --- docs/folder-structure.md | 82 +++++++++++++++++++ docs/middlewares/_category_.json | 8 ++ .../markdown-features.mdx | 2 +- 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 docs/folder-structure.md create mode 100644 docs/middlewares/_category_.json rename docs/{tutorial-extras => middlewares}/markdown-features.mdx (99%) diff --git a/docs/folder-structure.md b/docs/folder-structure.md new file mode 100644 index 0000000..4949c1f --- /dev/null +++ b/docs/folder-structure.md @@ -0,0 +1,82 @@ +--- +sidebar_position: 3 +--- + +# Folder Structure + +The Orion project is organized into a well-defined folder structure to maintain modularity, scalability, and clear separation of concerns. + +```bash +orion +├── cli +├── src +│ ├── config +│ ├── constants +│ ├── controllers +│ ├── interfaces +│ ├── middlewares +│ ├── models +│ ├── routes +│ ├── utils +│ └── visualization +└── templates + └── databases +``` + +### **config** + Contains configuration scripts for connecting to various databases (`MySQL`, `MongoDB`, `Redis`). + - **Example File:** `mongoConfig.js`, `mysqlConfig.js` + - **Purpose:** Ensures database configuration is separated from other logic and can be easily managed and modified. + +### **constants** + This folder holds constant values such as HTTP status codes, error messages, and API-related configurations. + - **Example File:** `httpStatusCodes.js`, `errors.js` + - **Purpose:** Centralizes all constant values to avoid "magic numbers" or strings and to promote consistency. + +### **controllers** + Houses the controller classes that define the business logic for each API endpoint. + - **Example File:** `UserController.js` + - **Purpose:** Manages the core business logic for various API endpoints. + +### **interfaces** + Contains abstract classes and interfaces that enforce a consistent structure throughout the project. + - **Example File:** `IDatabase.js`, `IMiddleware.js` + - **Purpose:** Provides a standardized way to define classes, ensuring they adhere to a common structure or pattern. + +### **middlewares** + Stores middleware classes that handle various tasks such as logging, security, and body parsing. + - **Example File:** `bodyParserMiddleware.js`, `corsMiddleware.js` + - **Purpose:** Manages cross-cutting concerns such as request validation, security & rate-limiting. + +### **models** + Placeholder for future database models. This folder can be used to define data structures and schema logic if an ORM is used. + - **Example File:** `userModel.js` + - **Purpose:** Provides a dedicated space to define database models when required. + +### **routes** + Contains route definitions that map URL paths to specific controller actions. +- **Example File:** `UserRoutes.js` +- **Purpose:** Separates route definitions from business logic to keep the code organized and modular. + +### **utils** + Contains utility classes and helper functions used across the project. + - **Example File:** `Logger.js`, `Singleton.js` + - **Purpose:** Manages common functions and utilities that are used in multiple places throughout the codebase. + +### **templates** + Holds template files that the CLI uses to generate new routes, controllers, and database connection scripts. + - **Example Files:** `controller.js`, `route.js` + - **Purpose:** Provides predefined templates that ensure consistency in generated files. + +### **visualization** + Stores files related to the route visualization feature. + +### **cli** + This folder contains the command-line interface (CLI) scripts for generating routes, controllers, and other components, as well as configuring databases. + +### **Project Root Files** + - **`app.js`**: The main application file that initializes and starts the Express server. It loads configurations, routes, middlewares, and manages the lifecycle of the server. + - **`index.js`**: The entry point that creates an instance of the app and starts the server. + - **`.prettierrc`**: Configures Prettier for code formatting standards. + - **`package.json`** and **`package-lock.json`**: Contain metadata about the project, including dependencies, scripts, and configurations. + - **`.env.sample`** serves as a reference for developers to create their own `.env` file. \ No newline at end of file diff --git a/docs/middlewares/_category_.json b/docs/middlewares/_category_.json new file mode 100644 index 0000000..7764e09 --- /dev/null +++ b/docs/middlewares/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "Middlewares", + "position": 3, + "link": { + "type": "generated-index", + "description": "Orion Middleware Guide" + } +} diff --git a/docs/tutorial-extras/markdown-features.mdx b/docs/middlewares/markdown-features.mdx similarity index 99% rename from docs/tutorial-extras/markdown-features.mdx rename to docs/middlewares/markdown-features.mdx index 35e0082..d9e5662 100644 --- a/docs/tutorial-extras/markdown-features.mdx +++ b/docs/middlewares/markdown-features.mdx @@ -1,5 +1,5 @@ --- -sidebar_position: 4 +sidebar_position: 1 --- # Markdown Features