How darylfernandes99/healthcare-plan-management-api works
Main components
• API Server: The primary application entry point is app.py, which wires up routes (defined in src/routes.py) and ties in controllers (located in src/controllers) to handle business logic.
• Controllers & Middlewares: Controllers (e.g., plans_controller.py) process requests, while middlewares (e.g., auth_middleware.py) handle tasks such as authentication.
• Data Models: Under src/models, there are several modules representing integration points with external systems (e.g., elastic_search_model.py for Elasticsearch, redis_model.py for Redis, and etag_model.py).
• Queue Consumer: The src/consumer.py likely listens to RabbitMQ queues to handle asynchronous processing (for operations like create, update, or delete) without blocking the main thread.
• Configurations: The src/config directory contains configurations and environment-specific setups (development vs. production) along with log formatting and other settings.
• Static Assets: Contains swagger.json files which can provide API documentation and possibly aid in understanding the API’s interactions.
External systems and their roles
• Redis: Serves as the quick key-value store for caching or transient storage of healthcare plans.
• Elasticsearch: Provides indexing and full-text search for healthcare plans and related data.
• RabbitMQ: Manages asynchronous task queues to handle background processing (ensuring that operations like plan creation, updating, and deletion don’t block API responses).
Relationships and interactions
• The API server handles incoming HTTP requests which are passed through the authentication middleware.
• The controllers interpret the requests and hand off operations to the appropriate data models.
• For synchronization, data is written to both Redis and Elasticsearch or read from them as needed.
• For asynchronous processing, operations (create, update, delete) are queued in RabbitMQ and later processed by the consumer.
• Utilize configuration files to adjust behavior between development and production environments.
Architectural patterns and design principles
• The project follows a separation of concerns where each module (controllers, models, middlewares) has a specific role.
• MVC-like pattern emerges as routes in app.py delegate to controllers, which in turn interact with models.
• There’s an emphasis on asynchronous processing via RabbitMQ to keep the API responsive.
• External services (Redis, Elasticsearch) are abstracted in separate model modules, promoting modularity and easier maintenance.