Skip to content

[Feature] : Refactor Server Startup Logic into a Dedicated Bootstrap Module #101

Description

@jikrana1

Description

📌 Overview

The current application defines the startServer() function directly in the main server file, where it is responsible for connecting to MongoDB, initializing Redis, and starting the Express server.

As the project grows, keeping all startup responsibilities in a single file makes the entry point harder to read and maintain.

The server initialization logic should be extracted into a dedicated bootstrap module to improve code organization, separation of concerns, and maintainability while preserving the existing application behavior.


✅ Tasks

  • Create a dedicated bootstrap module (e.g. bootstrap/startServer.js).
  • Move the complete startServer() implementation into the new module.
  • Move all database and Redis initialization logic into the bootstrap module.
  • Keep startup logging inside the bootstrap module.
  • Export the startup function from the new module.
  • Update the main server file to simply import and execute the startup function.
  • Ensure there are no functional changes after the refactor.

🎯 Expected Outcome

  • Cleaner and more maintainable server entry point.
  • Startup logic centralized in one location.
  • Easier future extension of the application startup process.
  • No changes to the application's runtime behavior.

📂 Suggested Project Structure

src/
├── bootstrap/
│   └── startServer.js
├── config/
├── middleware/
├── routes/
├── app.js

✅ Acceptance Criteria

  • A dedicated bootstrap module has been created.
  • The startServer() function has been moved completely.
  • MongoDB initialization is handled by the bootstrap module.
  • Redis initialization is handled by the bootstrap module.
  • Express server startup is handled by the bootstrap module.
  • Startup logs remain unchanged.
  • Existing functionality continues to work without modification.

📝 Notes

This is a refactoring task focused on improving project structure and maintainability. No API endpoints, middleware behavior, or business logic should be modified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions