This project is a solution for the Landbot Backend Challenge, implementing an assistance request system using the Outbox pattern for handling third-party integrations asynchronously. The system ensures scalability, reliability, and fault tolerance by leveraging FastAPI, message brokers, and background services.
- FastAPI: Provides a high-performance web API.
- Asynchronous Processing: Uses an event-driven architecture with a message broker.
- Outbox Pattern: Ensures consistency between database transactions and message publishing.
- Scalability: Supports horizontal scaling via containerization.
- Automated Testing: Includes integration tests using pytest and Testcontainers.
- Pre-commit Hooks: Enforces code quality and formatting.
- Development Container (Devcontainer): Supports reproducible development environments.
- FastAPI
- pre-commit
- pytest
- Testcontainers
- Postman for API testing
- MongoDB as NoSQL Database
- RabbitMQ as Message Broker
- Docker
- VS Code with Devcontainers Extension
Ensure you have the following installed:
-
Clone the repository:
git clone <repository-url> cd <repository-folder>
-
Open in VS Code:
code .
-
When prompted, reopen the project in a devcontainer.
-
Once inside the container, install dependencies:
pip install -r requirements.txt
-
Start components from devcontainer terminal:
You can use the launch configurations provided in
.vscode/launch.json
to start the services.or manually unsing the following commands:
- API:
$python dev src/infrastructure/ports/api/main.py --reload --host 0.0.0.0 --port 8000
- DLQ Consumer:
$python -m src.infrastructure.ports.dlq.main
- Publisher:
$python -m src.infrastructure.ports.publisher.main
- Reconcilier:
$python -m src.infrastructure.ports.reconciler.main
- Subscriber:
$python -m src.infrastructure.ports.subscriber.main
- API:
-
Run tests:
pytest
You can run the services using Docker Compose:
-
Build the images:
docker-compose build
-
Start the services:
docker-compose up
-
Use the API:
The API exposes endpoints for assistance requests and it is available at http://localhost:8000. Also, it exposes an OpenAPI documentation at http://localhost:8000/docs. You can interact with it using cURL, importing the Postman Collection from
docs
folder.
This project is licensed under the MIT License.