cds-snc / sre-bot

Slack bot for site reliability engineering
MIT License
6 stars 0 forks source link

FEAT: Project Refactoring #357

Open gcharest opened 6 months ago

gcharest commented 6 months ago

In order to make the management of the bot easier and more scalable in terms of feature development, a project refactoring might be beneficial.

Proposed future state:

.
├── api                      # API endpoints
│   ├── __init__.py
│   ├── auth.py              # Authentication and authorization
│   ├── geolocation.py       # Geolocation API
│   ├── utils.py             # Utility functions and classes for APIs
│   └── tests                # Tests for the APIs
│       ├── __init__.py
│       ├── test_auth.py
│       ├── test_geolocation.py
│       └── test_utils.py
├── bot                     # Main bot application
│   ├── __init__.py
│   ├── main.py             # Entry point
│   ├── settings.py         # Configuration settings
│   ├── commands            # Bot commands
│   ├── events              # Event handlers
│   ├── middleware          # Middleware components
│   └── utils               # Utility functions and classes
├── integrations            # Integrations with external services
│   ├── __init__.py
│   ├── service1            # Integration with Service 1
│   │   ├── __init__.py
│   │   ├── auth.py         # Authentication with Service 1
│   │   ├── permissions.py  # Permissions handling for Service 1
│   │   ├── requests.py     # Requests to Service 1
│   │   └── utils.py        # Utility functions and classes for Service 1
│   ├── service2            # Integration with Service 2
│   │   ├── __init__.py
│   │   ├── auth.py         # Authentication with Service 2
│   │   ├── permissions.py  # Permissions handling for Service 2
│   │   ├── requests.py     # Requests to Service 2
│   │   └── utils.py        # Utility functions and classes for Service 2
│   └── ...
├── locales                  # Localization files
│   ├── en                   # English
│   │   └── messages.po      # English translations
│   ├── fr                   # French
│   │   └── messages.po      # French translations
│   ├── de                   # German
│   │   └── messages.po      # German translations
│   └── ...
├── plugins                 # Individual plugins
│   ├── plugin1
│   │   ├── __init__.py
│   │   ├── commands.py
│   │   ├── events.py
│   │   └── utils.py
│   ├── plugin2
│   │   ├── __init__.py
│   │   ├── commands.py
│   │   ├── events.py
│   │   └── utils.py
│   └── ...
├── tests                   # Unit tests
│   ├── __init__.py
│   ├── test_commands.py
│   ├── test_events.py
│   ├── test_middleware.py
│   ├── test_utils.py
│   ├── plugins             # Tests for plugins
│   │   ├── test_plugin1.py
│   │   ├── test_plugin2.py
│   │   └── ...
│   └── integrations        # Tests for integrations
│       ├── test_service1.py
│       ├── test_service2.py
│       └── ...
├── .env                    # Environment variables
├── .gitignore              # Specifies intentionally untracked files to ignore
├── Dockerfile              # Dockerfile
├── Makefile                # Makefile
├── README.md               # Project description
├── requirements.txt        # Python dependencies
└── requirements_dev.txt    # Python dependencies for development
gcharest commented 6 months ago

Actually, this is pretty much the architecture I'd like to be able to achieve:

image

https://backstage.io/docs/backend-system/architecture/index

gcharest commented 6 months ago

Additionally, we could introduce health checks at integration level so that we can more easily manage the possible errors

patheard commented 6 months ago

Had a look and I like the architecture you've proposed! My only comment would be around the test structure. How would you feel about moving the api tests under the root test folder so you ended up with:

├── tests                   # Unit tests
│   ├── __init__.py
│   ├── test_commands.py
│   ├── test_events.py
│   ├── test_middleware.py
│   ├── test_utils.py
│   ├── api                # Tests for the APIs
│   │   ├── __init__.py
│   │   ├── test_auth.py
│   │   ├── test_geolocation.py
│   │   └── test_utils.py
│   ├── plugins             # Tests for plugins
│   │   ├── test_plugin1.py
│   │   ├── test_plugin2.py
│   │   └── ...
│   └── integrations        # Tests for integrations
│       ├── test_service1.py
│       ├── test_service2.py
│       └── ...

Would just keep all the tests nice and grouped in one spot.