# omerfarukkanli/rent-a-car-backend architecture

> Architecture diagram of the GitHub repository omerfarukkanli/rent-a-car-backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/omerfarukkanli/rent-a-car-backend
- Repository: https://github.com/omerfarukkanli/rent-a-car-backend

## Overview

##### Main Components Identification

a) Core Application Layer:
- Main NestJS Application Module
- Configuration Module (handling environment and Google configs)
- Generic Response Handlers

b) Authentication Layer:
- Auth Module
- Google Authentication Strategy
- Guards

c) User Management Layer:
- User Module
- Database Layer (MongoDB based on the schema presence)

##### Component Relationships

**┌─────────────────────────────────────────────────────────┐**
- External Services                      │

- ┌─────────────┐                                       │
- Google    │                                       │
- OAuth2    │                                       │
- ┘                                       │
- ┬─────────────────────────────────────────────┘

**┌───────────▼─────────────────────────────────────────────┐**
- NestJS Application                     │
- ┌─────────────┐    ┌─────────────┐    ┌─────────────┐ │
- Auth     │◄──►│    User     │◄──►│   Config    │ │
- Module    │    │   Module    │    │   Module    │ │
- ┘    └─────────────┘    └─────────────┘ │
- ▲                  ▲                            │

- ┌─────────────┐    ┌─────────────┐                    │
- Auth     │    │    User     │                    │
- Guards    │    │   Schema    │                    │
- ┘    └─────────────┘                    │
- ▲                             │
- ┼─────────────────────────────┘

- ┌────────▼────────┐
- MongoDB      │
- Database      │
- ┘

##### Important Elements

a) Request Flow Indicators:
- How requests flow through the Auth Guard
- Authentication process flow
- Database interaction paths

b) Module Relationships:
- How AuthModule depends on UserModule
- Configuration injection points
- Guard implementation points

##### Technical Details to Highlight

- NestJS Modules structure
- DTO flow for requests/responses
- Schema implementation for MongoDB
- Strategy implementation for Google OAuth
- Guard implementation points

##### Deployment Context
- Docker container boundary
- External service connections
- Configuration injection points

Remember to:
- Use consistent styling
- Version information
- Document any assumptions made

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph External
        Google["Google OAuth2"]
    end

    subgraph NestJS["NestJS Application"]
        subgraph Core
            AppModule["Main App Module"]
            ConfigModule["Configuration Module"]
            ConfigMain["Main Config"]
            ConfigGoogle["Google Config"]
            
            ConfigModule --> ConfigMain
            ConfigModule --> ConfigGoogle
        end

        subgraph Auth
            AuthModule["Auth Module"]
            AuthController["Auth Controller"]
            AuthService["Auth Service"]
            GoogleStrategy["Google Strategy"]
            AuthGuard["Auth Guard"]
            LoginDTO["Login DTO"]
            RegisterDTO["Register DTO"]
            
            AuthModule --> AuthController
            AuthController --> AuthService
            AuthService --> GoogleStrategy
            AuthGuard --> AuthService
            AuthController --> LoginDTO
            AuthController --> RegisterDTO
        end

        subgraph User
            UserModule["User Module"]
            UserService["User Service"]
            UserSchema["User Schema"]
            
            UserModule --> UserService
            UserService --> UserSchema
        end

        subgraph Generic
            ErrorDTO["Error Response DTO"]
            SuccessDTO["Success Response DTO"]
        end

        AppModule --> AuthModule
        AppModule --> UserModule
        AppModule --> ConfigModule
        AuthModule --> UserModule
        AuthService --> UserService
    end

    subgraph Database
        MongoDB[(MongoDB)]
    end

    Google --> GoogleStrategy
    UserSchema --> MongoDB

    %% Click Events
    click AppModule "https://github.com/omerfarukkanli/rent-a-car-backend/blob/main/src/domain/app.module.ts"
    click ConfigModule "https://github.com/omerfarukkanli/rent-a-car-backend/tree/main/src/config"
    click ConfigMain "https://github.com/omerfarukkanli/rent-a-car-backend/blob/main/src/config/configuration.ts"
    click ConfigGoogle "https://github.com/omerfarukkanli/rent-a-car-backend/blob/main/src/config/google.config.ts"
    click AuthModule "https://github.com/omerfarukkanli/rent-a-car-backend/blob/main/src/domain/auth/auth.module.ts"
    click AuthController "https://github.com/omerfarukkanli/rent-a-car-backend/blob/main/src/domain/auth/auth.controller.ts"
    click AuthService "https://github.com/omerfarukkanli/rent-a-car-backend/blob/main/src/domain/auth/auth.service.ts"
    click GoogleStrategy "https://github.com/omerfarukkanli/rent-a-car-backend/blob/main/src/domain/auth/strategies/google.strategy.ts"
    click AuthGuard "https://github.com/omerfarukkanli/rent-a-car-backend/blob/main/src/domain/guard/auth.guard.ts"
    click UserModule "https://github.com/omerfarukkanli/rent-a-car-backend/blob/main/src/domain/user/user.module.ts"
    click UserService "https://github.com/omerfarukkanli/rent-a-car-backend/blob/main/src/domain/user/user.service.ts"
    click UserSchema "https://github.com/omerfarukkanli/rent-a-car-backend/blob/main/src/domain/user/schema/user.schema.ts"
    click ErrorDTO "https://github.com/omerfarukkanli/rent-a-car-backend/blob/main/src/generic/dto/ErrorResponseDto.ts"
    click SuccessDTO "https://github.com/omerfarukkanli/rent-a-car-backend/blob/main/src/generic/dto/SuccessResponseDto.ts"
    click LoginDTO "https://github.com/omerfarukkanli/rent-a-car-backend/blob/main/src/domain/auth/dto/loginUserDto.ts"
    click RegisterDTO "https://github.com/omerfarukkanli/rent-a-car-backend/blob/main/src/domain/auth/dto/registerUserDto.ts"

    %% Styling
    classDef external fill:#90EE90
    classDef core fill:#ADD8E6
    classDef auth fill:#FFE4B5
    classDef user fill:#B0C4DE
    classDef database fill:#DCDCDC
    classDef generic fill:#F0F8FF

    class Google external
    class AppModule,ConfigModule,ConfigMain,ConfigGoogle core
    class AuthModule,AuthController,AuthService,GoogleStrategy,AuthGuard,LoginDTO,RegisterDTO auth
    class UserModule,UserService,UserSchema user
    class MongoDB database
    class ErrorDTO,SuccessDTO generic
```
