# huyhieu19/carsties_car_auction architecture

> Architecture diagram of the GitHub repository huyhieu19/carsties_car_auction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/huyhieu19/carsties_car_auction
- Repository: https://github.com/huyhieu19/carsties_car_auction

## Overview

##### Project type and purpose
- This is a full-stack, microservices-based auction/web-app learning project.
- Frontend: Next.js (React) web application.
- Backend: .NET Core microservices (AuctionService, BiddingService, NotificationService, SearchService, IdentityService, GatewayService) communicating via RabbitMQ and gRPC.
- Purpose: Learn end-to-end microservices, event-driven communication, auth (IdentityServer), real-time updates (SignalR), search, Docker/Kubernetes.

##### File structure
- Top-level:
- fontend/web-app – Next.js app with pages, API routes (NextAuth), components, styling, fetch wrapper.
- src – multiple .NET Core services, each in its own folder with Dockerfile, csproj, Program.cs, controllers, services, data, migrations, protos (for gRPC), consumers (RabbitMQ).
- src/Contracts – shared event contracts (AuctionCreated, BidPlaced…).
- docker-compose.yml – orchestration of all services and RabbitMQ.
- Patterns:
- API Gateway (GatewayService) fronts all microservices.
- IdentityServer (IdentityService) for authentication/authorization.
- Event-driven communication via RabbitMQ: services publish domain events, other services consume.
- gRPC between BiddingService and AuctionService for direct auction lookups.
- SignalR hub (NotificationService) to push real-time notifications to frontend.

##### README insights
- Describes Docker Compose for running backend, Next.js for frontend.
- Mentions key technologies: .NET Core, EF Core, SignalR, RabbitMQ, Kubernetes, NextJS.

##### Final advice
- Be exhaustive: break out each microservice and its DB, show the Contracts library as a shared component.
- Token flow: client obtains JWT from IdentityService, includes it in calls to GatewayService.
- RabbitMQ at the center of the event-driven part.
- Don’t over-aggregate: treat each background consumer as part of its parent service.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        Browser["Browser/Client (Next.js)"]:::ui
    end

    %% Edge Layer
    subgraph "Edge Layer"
        Gateway["API Gateway (GatewayService)"]:::edge
        Identity["IdentityService (Auth)"]:::edge
    end

    %% Domain Services
    subgraph "Domain Services"
        subgraph "AuctionService"
            AuctionCore["AuctionService"]:::core
            AuctionController["AuctionController.cs"]:::core
            AuctionDbContext["AuctionDbContext.cs"]:::core
            AuctionsProto["auctions.proto"]:::core
        end
        subgraph "BiddingService"
            BiddingCore["BiddingService"]:::core
            BidsController["BidsController.cs"]:::core
            GrpcAuctionClient["GrpcAuctionClient.cs"]:::core
            BiddingProto["auctions.proto"]:::core
        end
        subgraph "NotificationService"
            NotificationCore["NotificationService"]:::core
            NotificationHub["NotificationHub.cs"]:::core
            NotificationConsumers["Consumers"]:::core
        end
        subgraph "SearchService"
            SearchCore["SearchService"]:::core
            SearchController["SearchController.cs"]:::core
            SearchConsumers["Consumers"]:::core
        end
        Contracts["Shared Contracts"]:::core
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        RabbitMQ["RabbitMQ"]:::infra
        AuctionDB["AuctionDb"]:::infra
        BiddingDB["BiddingDb"]:::infra
        IdentityDB["IdentityDb"]:::infra
        SearchIndex["Search Index"]:::infra
    end

    %% Connections - Authentication & API calls
    Browser -->|"Auth Request (OAuth/OIDC)"| Identity
    Identity -->|"JWT Token"| Browser
    Browser -->|"REST API (HTTP + JWT)"| Gateway
    Gateway -->|"Token Validation"| Identity

    %% Synchronous service calls
    Gateway -->|"REST/gRPC"| AuctionCore
    Gateway -->|"REST/gRPC"| BiddingCore
    Gateway -->|"REST"| SearchCore

    BiddingCore -->|"gRPC"| AuctionCore

    %% Databases
    AuctionCore -->|SQL| AuctionDB
    BiddingCore -->|SQL| BiddingDB
    Identity -->|SQL| IdentityDB
    SearchCore -->|Index Update| SearchIndex

    %% Event-driven (RabbitMQ)
    AuctionCore ---|"AuctionCreated"| RabbitMQ
    BiddingCore ---|"BidPlaced"| RabbitMQ

    RabbitMQ ---|"AuctionCreated, BidPlaced"| NotificationConsumers
    RabbitMQ ---|"AuctionCreated, BidPlaced"| SearchConsumers

    %% Real-time notifications
    NotificationCore -->|"WebSocket (SignalR)"| Browser

    %% Shared contracts usage
    Contracts -.-> AuctionCore
    Contracts -.-> BiddingCore
    Contracts -.-> NotificationCore
    Contracts -.-> SearchCore

    %% Click Events
    click Browser "https://github.com/huyhieu19/carsties_car_auction/tree/main/fontend/web-app"
    click Gateway "https://github.com/huyhieu19/carsties_car_auction/tree/main/src/GatewayService"
    click Identity "https://github.com/huyhieu19/carsties_car_auction/tree/main/src/IdentityService"
    click AuctionCore "https://github.com/huyhieu19/carsties_car_auction/tree/main/src/AuctionService"
    click AuctionController "https://github.com/huyhieu19/carsties_car_auction/blob/main/src/AuctionService/Controllers.cs/AuctionController.cs"
    click AuctionDbContext "https://github.com/huyhieu19/carsties_car_auction/blob/main/src/AuctionService/Data/AuctionDbContext.cs"
    click AuctionsProto "https://github.com/huyhieu19/carsties_car_auction/blob/main/src/AuctionService/protos/auctions.proto"
    click BiddingCore "https://github.com/huyhieu19/carsties_car_auction/tree/main/src/BiddingService"
    click BidsController "https://github.com/huyhieu19/carsties_car_auction/blob/main/src/BiddingService/Controller/BidsController.cs"
    click GrpcAuctionClient "https://github.com/huyhieu19/carsties_car_auction/blob/main/src/BiddingService/Services/GrpcAuctionClient.cs"
    click BiddingProto "https://github.com/huyhieu19/carsties_car_auction/blob/main/src/BiddingService/protos/auctions.proto"
    click NotificationCore "https://github.com/huyhieu19/carsties_car_auction/tree/main/src/NotificationService"
    click NotificationHub "https://github.com/huyhieu19/carsties_car_auction/blob/main/src/NotificationService/Hubs/NotificationHub.cs"
    click NotificationConsumers "https://github.com/huyhieu19/carsties_car_auction/tree/main/src/NotificationService/Consumers"
    click SearchCore "https://github.com/huyhieu19/carsties_car_auction/tree/main/src/SearchService"
    click SearchController "https://github.com/huyhieu19/carsties_car_auction/blob/main/src/SearchService/Controllers/SearchController.cs"
    click SearchConsumers "https://github.com/huyhieu19/carsties_car_auction/tree/main/src/SearchService/Consumers"
    click Contracts "https://github.com/huyhieu19/carsties_car_auction/tree/main/src/Contracts"
    click RabbitMQ "https://github.com/huyhieu19/carsties_car_auction/blob/main/docker-compose.yml"

    %% Styles
    classDef ui fill:#f9c74f,stroke:#000,stroke-width:1px
    classDef edge fill:#90be6d,stroke:#000,stroke-width:1px
    classDef core fill:#577590,stroke:#000,stroke-width:1px
    classDef infra fill:#43aa8b,stroke:#000,stroke-width:1px
```
