# kirin97cesar/mi-ecommerce architecture

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

- Interactive diagram: https://gitdiagram.com/kirin97cesar/mi-ecommerce
- Repository: https://github.com/kirin97cesar/mi-ecommerce

## Overview

##### Project type and purpose
- This is a backend-only e-commerce service written in TypeScript.
- It follows a clean/hexagonal architecture:
- domain (core entities & repository interfaces)
- application (use-cases and port definitions)
- infrastructure (adapters: HTTP server, database, external services)

##### File structure
- src/index.ts: application entry point
- src/infrastructure/http/server.ts: configures and starts the HTTP server (e.g., Express)
- routes/auth.routes.ts, user.routes.ts define REST endpoints
- src/application/ports: interfaces for Auth and User repositories/services
- src/application/use-cases: business logic (AuthUseCases, GetUsers)
- src/domain/entities: core User and Auth models
- src/domain/repositories: repository interfaces for persistence
- src/infrastructure/db: DB config + Postgres repository implementations
- src/infrastructure/auth/authServiceImpl.ts: concrete implementation of Auth port
- test/: unit tests for use-cases

##### Key insights from README
- Project name “MI ECOMMERCE TYPESCRIPT” confirms its e-commerce backend nature.

## Diagram (Mermaid)

```mermaid
flowchart TB
    Client["API Client"]:::external
    Index["src/index.ts\n(Application Entry Point)"]:::external
    HttpServer["HTTP Server (Express)"]:::http
    AuthRoutes["Auth Routes"]:::http
    UserRoutes["User Routes"]:::http

    subgraph "Application Layer"
        AuthUseCases["AuthUseCases"]:::application
        GetUsers["GetUsers Use-Case"]:::application
        AuthPort["Auth Port (interface)"]:::application
    end

    subgraph "Domain Layer"
        AuthEntity["Auth Entity"]:::domain
        UserEntity["User Entity"]:::domain
        AuthRepoInterface["AuthRepository Interface"]:::domain
        UserRepoInterface["UserRepository Interface"]:::domain
    end

    subgraph "Infrastructure Adapters"
        AuthServiceImpl["AuthServiceImpl"]:::infrastructure
        DBConfig["DB Configuration"]:::infrastructure
        PostgresAuthRepo["PostgresAuthRepository"]:::infrastructure
        PostgresUserRepo["PostgresUserRepository"]:::infrastructure
        DB["PostgreSQL DB"]:::external
    end

    subgraph "Tests"
        AuthUseCasesTests["AuthUseCases Tests"]:::external
        GetUsersTests["GetUsers Tests"]:::external
    end

    %% Flows
    Client -->|HTTP Request| HttpServer
    HttpServer -->|routes to| AuthRoutes
    HttpServer -->|routes to| UserRoutes
    AuthRoutes -->|calls| AuthUseCases
    UserRoutes -->|calls| GetUsers
    AuthUseCases -->|uses| AuthPort
    AuthUseCases -->|manipulates| AuthEntity
    GetUsers -->|uses| UserRepoInterface
    GetUsers -->|manipulates| UserEntity
    AuthPort <-->|implemented by| AuthServiceImpl
    AuthPort -->|defines| AuthRepoInterface
    AuthServiceImpl -->|reads/writes| PostgresAuthRepo
    GetUsers -->|uses| UserRepoInterface
    PostgresUserRepo -->|reads/writes| DB
    PostgresAuthRepo -->|reads/writes| DB
    DBConfig -->|configures| PostgresUserRepo
    DBConfig -->|configures| PostgresAuthRepo

    %% Tests
    AuthUseCasesTests -->|tests| AuthUseCases
    GetUsersTests -->|tests| GetUsers

    %% Click Events
    click Index "https://github.com/kirin97cesar/mi-ecommerce/blob/main/src/index.ts"
    click HttpServer "https://github.com/kirin97cesar/mi-ecommerce/blob/main/src/infrastructure/http/server.ts"
    click AuthRoutes "https://github.com/kirin97cesar/mi-ecommerce/blob/main/src/infrastructure/http/routes/auth.routes.ts"
    click UserRoutes "https://github.com/kirin97cesar/mi-ecommerce/blob/main/src/infrastructure/http/routes/user.routes.ts"
    click AuthPort "https://github.com/kirin97cesar/mi-ecommerce/blob/main/src/application/ports/auth.ts"
    click AuthUseCases "https://github.com/kirin97cesar/mi-ecommerce/blob/main/src/application/use-cases/AuthUseCases.ts"
    click GetUsers "https://github.com/kirin97cesar/mi-ecommerce/blob/main/src/application/use-cases/GetUsers.ts"
    click AuthEntity "https://github.com/kirin97cesar/mi-ecommerce/blob/main/src/domain/entities/Auth.ts"
    click UserEntity "https://github.com/kirin97cesar/mi-ecommerce/blob/main/src/domain/entities/User.ts"
    click AuthRepoInterface "https://github.com/kirin97cesar/mi-ecommerce/blob/main/src/domain/repositories/AuthRepository.ts"
    click UserRepoInterface "https://github.com/kirin97cesar/mi-ecommerce/blob/main/src/domain/repositories/UserRepository.ts"
    click AuthServiceImpl "https://github.com/kirin97cesar/mi-ecommerce/blob/main/src/infrastructure/auth/authServiceImpl.ts"
    click DBConfig "https://github.com/kirin97cesar/mi-ecommerce/blob/main/src/infrastructure/db/db.config.ts"
    click PostgresAuthRepo "https://github.com/kirin97cesar/mi-ecommerce/blob/main/src/infrastructure/db/repositories/PostgresAuthRepository.ts"
    click PostgresUserRepo "https://github.com/kirin97cesar/mi-ecommerce/blob/main/src/infrastructure/db/repositories/PostgresUserRepository.ts"
    click AuthUseCasesTests "https://github.com/kirin97cesar/mi-ecommerce/blob/main/test/application/use-cases/authUseCases.test.ts"
    click GetUsersTests "https://github.com/kirin97cesar/mi-ecommerce/blob/main/test/application/use-cases/GetUsers.test.ts"

    %% Styles
    classDef http fill:#D0E6FF,stroke:#003366,color:#003366
    classDef application fill:#DFF5D0,stroke:#336600,color:#336600
    classDef domain fill:#FFF5B1,stroke:#998833,color:#998833
    classDef infrastructure fill:#FFDAB9,stroke:#CC6600,color:#CC6600
    classDef external fill:#EEEEEE,stroke:#888888,color:#888888
```
