# nihat-js/avtobeh architecture

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

- Interactive diagram: https://gitdiagram.com/nihat-js/avtobeh
- Repository: https://github.com/nihat-js/avtobeh

## Overview

##### Main System Components

a) Frontend Layer:
- Next.js Application (app directory structure)
- User Portal ((user) route group)
- Admin Portal (admin route group)
- Component Library (components directory)

b) API Layer:
- REST API endpoints (api directory)
- Authentication System (api/auth)
- Image Handling (api/(image))

c) Database Layer:
- Multiple Database Configurations:
- Prisma ORM (database/prisma)
- Sequelize ORM (database/sequelize)
- Drizzle ORM (indicated by drizzle.config files)

d) External Services:
- File Storage (for image uploads)
- Localization System (public/locales)

**[Client Browsers/Users]**
- ↓
**[Frontend Layer (Next.js)]**
- ↓
**[API Layer (Route Handlers)]**
- ↓
**[Database Layer]**

##### Component Relationships

Key interactions:

a) User Flow:
- Authentication flows (daxil-ol, qeydiyyat)
- Car listing creation (masin-sat)
- Car browsing (masinlar)
- Profile management (profil-melumatlarim)

b) Data Flow:
- Image upload pipeline
- Car listing creation process
- Search and filtering system
- Authentication and authorization

##### Technical Details

Technical specifications:

a) Frontend:
- React/Next.js
- TailwindCSS
- Component hierarchy

b) Backend:
- Next.js API Routes
- Multiple ORM implementations
- Authentication system

c) Storage:
- Database systems
- File storage for images
- Caching mechanisms

##### Implementation Notes

- The modular structure of the application
- Clear separation between user and admin interfaces
- Multiple database ORM support
- RESTful API architecture
- Image handling pipeline
- Internationalization support

Use standardized symbols:
- Rectangles: Components/Services
- Diamonds: Decision points
- Clouds: External services

Remember to maintain a balance between detail and clarity, focusing on the architectural decisions that make this car marketplace unique, such as its multiple ORM support and comprehensive car listing management system.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser[Client Browser]
    end

    subgraph Frontend["Frontend Layer"]
        NextApp[Next.js Application]:::frontend
        UserPortal[User Portal]:::frontend
        AdminPortal[Admin Portal]:::frontend
        CompLib[Component Library]:::frontend

        subgraph UserInterface["User Interface Components"]
            AuthLogin[Login]:::frontend
            AuthRegister[Register]:::frontend
            CarListing[Car Listing]:::frontend
            CarBrowse[Car Browser]:::frontend
            Profile[Profile Management]:::frontend
            CarFilter[Car Filter System]:::frontend
        end

        subgraph Components["Component Categories"]
            CommonComp[Common Components]:::frontend
            UserComp[User Components]:::frontend
            AdminComp[Admin Components]:::frontend
        end
    end

    subgraph APILayer["API Layer"]
        AuthSystem[Authentication System]:::api
        ImageHandler[Image Handler]:::api
        APIEndpoints[REST API Endpoints]:::api
    end

    subgraph DatabaseLayer["Database Layer"]
        PrismaORM[Prisma ORM]:::database
        SequelizeORM[Sequelize ORM]:::database
        DrizzleORM[Drizzle ORM]:::database

        subgraph Models["Database Models"]
            AutoBrand[Auto Brand]:::model
            AutoModel[Auto Model]:::model
            AutoImage[Auto Images]:::model
            UserModel[User Model]:::model
        end
    end

    subgraph ExternalServices["External Services"]
        FileStorage[File Storage]:::external
        LocalizationSystem[Localization System]:::external
    end

    %% Relationships
    Browser --> NextApp
    NextApp --> UserPortal
    NextApp --> AdminPortal
    NextApp --> CompLib

    UserPortal --> AuthLogin
    UserPortal --> AuthRegister
    UserPortal --> CarListing
    UserPortal --> CarBrowse
    UserPortal --> Profile
    UserPortal --> CarFilter

    CompLib --> CommonComp
    CompLib --> UserComp
    CompLib --> AdminComp

    UserInterface --> APIEndpoints
    APIEndpoints --> AuthSystem
    APIEndpoints --> ImageHandler

    ImageHandler --> FileStorage
    AuthSystem --> DatabaseLayer

    APIEndpoints --> PrismaORM
    APIEndpoints --> SequelizeORM
    APIEndpoints --> DrizzleORM

    SequelizeORM --> Models
    NextApp --> LocalizationSystem

    %% Click Events
    click UserPortal "https://github.com/nihat-js/avtobeh/tree/main/app/(user)"
    click AdminPortal "https://github.com/nihat-js/avtobeh/tree/main/app/admin"
    click CompLib "https://github.com/nihat-js/avtobeh/tree/main/app/components"
    click AuthSystem "https://github.com/nihat-js/avtobeh/tree/main/app/api/auth"
    click ImageHandler "https://github.com/nihat-js/avtobeh/tree/main/app/api/(image)"
    click PrismaORM "https://github.com/nihat-js/avtobeh/tree/main/database/prisma"
    click SequelizeORM "https://github.com/nihat-js/avtobeh/tree/main/database/sequelize"
    click Models "https://github.com/nihat-js/avtobeh/tree/main/database/sequelize/models"
    click LocalizationSystem "https://github.com/nihat-js/avtobeh/tree/main/public/locales"
    click FileStorage "https://github.com/nihat-js/avtobeh/tree/main/public/temporary-uploads"
    click CarListing "https://github.com/nihat-js/avtobeh/tree/main/app/(user)/masin-sat"
    click CarBrowse "https://github.com/nihat-js/avtobeh/tree/main/app/(user)/masinlar"
    click Profile "https://github.com/nihat-js/avtobeh/tree/main/app/(user)/profil-melumatlarim"
    click AuthLogin "https://github.com/nihat-js/avtobeh/tree/main/app/(user)/daxil-ol"
    click AuthRegister "https://github.com/nihat-js/avtobeh/tree/main/app/(user)/qeydiyyat"
    click CommonComp "https://github.com/nihat-js/avtobeh/tree/main/app/components/common"
    click UserComp "https://github.com/nihat-js/avtobeh/tree/main/app/components/user"
    click AdminComp "https://github.com/nihat-js/avtobeh/tree/main/app/components/admin"
    click CarFilter "https://github.com/nihat-js/avtobeh/tree/main/app/components/user/CarFilter"
    click AutoBrand "https://github.com/nihat-js/avtobeh/blob/main/database/sequelize/models/AutoBrand.js"
    click AutoModel "https://github.com/nihat-js/avtobeh/blob/main/database/sequelize/models/AutoModel.js"
    click AutoImage "https://github.com/nihat-js/avtobeh/blob/main/database/sequelize/models/AutoImage.js"
    click UserModel "https://github.com/nihat-js/avtobeh/blob/main/database/sequelize/models/user.js"

    %% Styles
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef api fill:#4CAF50,stroke:#2E7D32,color:white
    classDef database fill:#FF9800,stroke:#EF6C00,color:white
    classDef external fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef model fill:#FF5722,stroke:#D84315,color:white
```
