Professional backend Setup :

  1. We commence our project by creating a use model for it. Refer to picture one for a visual representation.

  1. In the model, we observe that we handle images as part of our project.

  2. During this phase, we establish our file and folder structure.

  3. Initially, we initialize an empty Node application.

  4. In our model, we also deal with images. It's crucial to note that when storing images, we utilize third-party services such as Microsoft Azure, Amazon AWS, and Cloudinary.

  5. We narrow our focus when uploading photos or other media from users. We ensure that we store this media on our server to mitigate the impact in case of a sub-connection loss. This guarantees the presence of media on our server.

  6. In the third process, we upload the photos to the third-party platform.

  7. Some companies opt for a directed upload approach, while others use third-party packs. This choice depends on the specific practices of each company.

  8. Concept of GitHub keep files .

    "GitHub .keep files," it's a convention sometimes used to ensure that an otherwise empty directory is tracked by Git. In some cases, Git may ignore directories that do not contain any files. To work around this, you can include a placeholder file, often named .keep (or any other name you prefer), to indicate that the directory should be kept.

  9. Additionally, we consider the concept of GitHub ignore files.

    ".gitignore" file in GitHub, it's a file used to specify intentionally untracked files that Git should ignore. This is useful to avoid committing files or directories that are specific to your local development environment, build output, or other files that shouldn't be part of the version control history.

  10. Create a .env file.

  11. Inside the project's root directory, create a public folder.

  12. Within the public folder, create a temp folder.

  13. Place the .gitkeep file inside the temp folder, allowing it to be pushed to GitHub without having extra files we make files in future initially we upload empty folder.

  14. Create a src folder within the project's root directory.

  15. Inside the src folder, create three files app,js constants.js index.js.

  16. Address the issue of the server restarting repeatedly by exploring different options.

  17. Install the nodemon dev dependency to handle server reloading upon changes.

  18. Use the dev dependency installation process: insert a '-D' between npm and the package name, specifying it as a dev dependency.

  19. Reload the server automatically when changes are made in the source files.

  20. To achieve this, write a script for nodemon to execute.

  21. Formulate the command for the script.

  "scripts": {
    "dev": "nodemon src/index.js"
  },
  1. Create additional folders within our source folder.

  2. Utilize the following folders accordingly:

    • Controllers: Implement the majority of the application's functionality here.

    • Database: Write the connection logic for the database.

    • Middlewares: Implement middleware functions here.

    • Models: Handle data modeling in this folder.

    • Routes: Manage routes in this folder.

    • Utils: Store utility functions in this folder.

  3. Install Prettier plugins so that we can work professionally in a team.

Developers use Prettier and its plugins to ensure a consistent and maintainable codebase, improve collaboration, and save time on manual code formatting. It has become a valuable tool in modern development workflows.

.prettierrc The .prettierrc file is a configuration file used by the Prettier code formatter. It allows you to customize various formatting options to match the coding style preferences of your project. This file typically resides in the root directory of your project.

.prettierignore The .prettierignore file is used to specify files and directories that should be excluded from Prettier formatting. It works similarly to the commonly used .gitignore file but is specific to Prettier.

{
  "singleQuote": false,
  "bracketSpacing": true,
  "tabWidth": 2,
  "trailingComma": "es5",
  "semi": true
}

```

Folder Structure:

Thanks to Hitesh Choudhary Sir, I learned all this stuffs from his YouTube channel: