How go-park-mail-ru/2024_2_bettercallfirewall works
Main Components
• Service Components: The project is divided into several distinct service domains. Create separate blocks/rectangles for each of the primary services:
• Auth Service (located in cmd/auth and internal/auth)
• Chat Service (cmd/chat and internal/chat)
• Community Service (cmd/community and internal/community)
• File Service (cmd/file and internal/fileService)
• Post Service (cmd/post and internal/post)
• Profile Service (cmd/profile and internal/profile)
• API Gateways / Adapters: There are internal/api/grpc components for each respective service as well as an ext_grpc layer. These indicate that the system exposes gRPC endpoints along with possible HTTP routers (under internal/router).
• Infrastructure Components:
• Database layer: DB migrations, normalized documents (ERdiagram.md and relations.md) indicate the presence of a relational database (likely PostgreSQL).
• Cache/Session Management: The presence of Redis repository implementations under internal/auth/repository/redis.
• Metrics: The internal/metrics directory and prometheus.yml demonstrate monitoring and instrumentation.
• Infrastructure tooling: Dockerfiles per service (e.g., Dockerfileauth, Dockerfilepostgrpc, etc.) coupled with docker-compose.yml to manage containerized deployments.
Relationships and Interactions
• Data Flow and Service Communication:
• How frontend requests (although frontend is a separate repository) target the backend API layer. The backend is designed with HTTP endpoints (routers) and gRPC endpoints (internal/api/grpc) that serve business logic.
• Internal interactions; for example, some services might communicate with each other (e.g., auth for managing sessions and user validations), and several services interact with the database and external adapters.
• A connection between the gRPC adapter (internal/ext_grpc) and its respective port receiving requests from external services.
• Request Processing Layers:
• Use distinct layers representing the layers in the application: API/Router layer, Controller layer (e.g., inside internal/*/controller), Service/Application layer (inside internal/app/* or internal/*/service), and persistence (repository patterns under postgres directories).
• Middleware components (internal/middleware) that intercept and log or monitor requests (access log, metrics, auth).
Architectural Patterns & Design Principles
• Microservices/Fine-grained Componentization (even if services run within one codebase, the “cmd” structure suggests multiple executables, potentially deployed as separate containers). Emphasize this by drawing each service as an independent deployable component.
• Use of gRPC and REST: Since there are dedicated packages for gRPC, include distinct representations for endpoints providing remote procedure calls (using different Dockerfiles for gRPC) as well as HTTP endpoints.
• Observability: Clearly indicate components for metrics collection (Prometheus) and logging through the middleware.
Additional Notes
• That each service contains its own sublayers (control, service, repository) and that there are testing files (app_test.go, router_test.go) emphasizing testability.
• Mention the distinct Dockerfiles; these imply that each service may be deployed as its own container. Represent them within the infrastructure layer and show deployment relations via docker-compose.
• Including the “proto” files indicates that the overall system design should capture how APIs are defined for gRPC communication.