Initial commit: setup FastAPI microservice order_service#1
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a comprehensive event-driven microservices platform called AsyncFlow, built with FastAPI, RabbitMQ, and PostgreSQL. The system implements an asynchronous order processing workflow with multiple backend services coordinated through message queuing.
Key Changes
- Implements four core services: Order Service, Billing Service, Auth Service, and API Gateway
- Establishes RabbitMQ-based event-driven communication between services
- Sets up containerized deployment with Docker Compose and multi-stage builds
- Adds comprehensive test suite with async fixtures and mocked dependencies
Reviewed Changes
Copilot reviewed 76 out of 82 changed files in this pull request and generated 19 comments.
Show a summary per file
| File | Description |
|---|---|
| order_service/* | FastAPI service for order management with SQLAlchemy models, event publishing, and async tests |
| billing_service/* | Consumer service that processes order events and handles payment logic |
| auth_service/* | JWT-based authentication service with user management and Alembic migrations |
| api_gateway/* | Unified API gateway with request forwarding, rate limiting, and metrics collection |
| frontend/* | React/Vite frontend with Nginx serving and API proxying |
| docker-compose.yml | Multi-container orchestration with service health checks and networking |
| pyproject.toml files | Dependency management using uv with strict linting and type checking |
| .github/workflows/tests.yml | CI/CD pipeline for automated testing |
Comments suppressed due to low confidence (1)
api_gateway/src/middleware/init.py:10
- The name 'LoggingMiddleware' is exported by all but is not defined.
"LoggingMiddleware",
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| module = "tests.*" | ||
| strict = false | ||
| minversion = "8.0" | ||
| addopts = "-ra -q --strict-markers --disable-warnings --cov=src --cov-report=term-missing" | ||
| testpaths = ["tests"] | ||
| pythonpath = ["src"] | ||
| asyncio_mode = "auto" |
There was a problem hiding this comment.
Duplicate pytest configuration detected. Lines 136-140 appear to be pytest settings placed inside the [[tool.mypy.overrides]] section, but they should be under [tool.pytest.ini_options] (which already exists at lines 62-68). Remove these duplicate pytest settings from the mypy overrides section.
| db_user: str = Field("postgres", description="Database username") | ||
| db_pass: SecretStr = Field("postgres", description="Database password") | ||
| db_host: str = Field("db", description="Database hostname") | ||
| db_port: int = Field(5434, ge=1, le=65535, description="Database port") |
There was a problem hiding this comment.
Incorrect default database port. The billing service is configured with port 5434, but PostgreSQL's standard port is 5432. This mismatch with the actual database port (as seen in docker-compose.yml line 21 where PostgreSQL runs on 5432) will cause connection failures. Change the default to 5432.
| POSTGRES_USER: str = "postgres" | ||
| POSTGRES_PASSWORD: str = "postgres" | ||
| POSTGRES_HOST: str = "postgres" | ||
| POSTGRES_PORT: int = 5434 # Using a different port to avoid conflicts |
There was a problem hiding this comment.
Incorrect database port configuration. The auth service is set to use port 5434, but according to docker-compose.yml (line 21), PostgreSQL runs on the standard port 5432. This will cause database connection failures. Change to 5432 and remove the misleading comment about avoiding conflicts.
| "MetricsMiddleware", | ||
| "get_metrics", | ||
| "rate_limit_middleware", | ||
| "LoggingMiddleware", |
There was a problem hiding this comment.
LoggingMiddleware is exported in __all__ but is never imported or defined in this module. This will cause an AttributeError when attempting to import it. Either remove LoggingMiddleware from __all__ or add the corresponding import statement.
| "LoggingMiddleware", |
| # 🚫 ОТКЛЮЧАЕМ LIFESPAN/СТАРТОВЫЕ КОННЕКТЫ | ||
| # ============================== | ||
| # Вариант 1: полностью выключим lifespan у httpx-транспорта (см. fixture client) | ||
| # Вариант 2 (доп): перестраховка — заменим lifespan контекст на пустой |
There was a problem hiding this comment.
Comments are written in Russian (Cyrillic characters) while the rest of the codebase uses English. For consistency and broader team accessibility, translate these comments to English.
|
|
||
| import aio_pika | ||
| from aio_pika import IncomingMessage | ||
| from sqlalchemy.ext.asyncio import AsyncSession |
There was a problem hiding this comment.
Import of 'AsyncSession' is not used.
| @@ -0,0 +1,14 @@ | |||
| from sqlalchemy import Column, Integer, Float, DateTime, func, String, ForeignKey | |||
There was a problem hiding this comment.
Import of 'ForeignKey' is not used.
| @@ -0,0 +1,71 @@ | |||
| from pydantic import Field, validator, SecretStr | |||
There was a problem hiding this comment.
Import of 'validator' is not used.
| @@ -0,0 +1,71 @@ | |||
| from pydantic import Field, validator, SecretStr | |||
| from pydantic_settings import BaseSettings | |||
| from typing import List, Optional | |||
There was a problem hiding this comment.
Import of 'List' is not used.
Import of 'Optional' is not used.
| from fastapi.responses import JSONResponse | ||
|
|
||
| return JSONResponse( | ||
| status_code=201, | ||
| content={"message": "User registered successfully"} | ||
| ) | ||
| # return await ServiceClient.forward_request("auth", "register", "POST", user_data.dict()) | ||
|
|
||
|
|
There was a problem hiding this comment.
This statement is unreachable.
| from fastapi.responses import JSONResponse | |
| return JSONResponse( | |
| status_code=201, | |
| content={"message": "User registered successfully"} | |
| ) | |
| # return await ServiceClient.forward_request("auth", "register", "POST", user_data.dict()) |
No description provided.