# andersonlima12/nlw-esports architecture

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

- Interactive diagram: https://gitdiagram.com/andersonlima12/nlw-esports
- Repository: https://github.com/andersonlima12/nlw-esports

## Overview

##### Project type and purpose
- This is a full-stack “NLW-eSports” matchmaking app.
- It ships three client‐side apps (web, React Native mobile) and one backend service.
- Purpose: let gamers find partners for their favorite games, record ads in a database, and send push notifications.

##### File structure
- Top level:
- mobile/ – React Native (Expo) app
- web/ – ReactJS app (Vite + Tailwind)
- server/ – Node.js + TypeScript service using Express (server.ts) and Prisma + SQLite
- server/prisma – DB schema and migration files
- mobile/src/service – push‐notification token retrieval and config
- web/src/components – UI for browsing games, creating ads
- Each client has tsconfig, package.json, assets folder.

##### Additional insights from README
- Stack: TypeScript, React, React Native, SQLite, Prisma
- Features: list games, create ads (with weekDays, hours), match partners, trigger Expo push notifications.

##### Main components
a. Clients:
- Web app (React + Vite)
- Mobile app (React Native + Expo)
b. Backend API:
- Express server (server.ts)
- Prisma ORM layer
- SQLite database
- Utility modules (hour conversion, etc.)
c. External service:
- Expo Push Notification service
- Migration pipeline (prisma migrations)

##### Relationships and data flows
- Web/Mobile → HTTP REST API → Node/Express
- Express controllers → Prisma → SQLite
- After ad creation or match event, Express calls Expo Push API
- Responses flow back to clients

##### Architectural patterns and key design principles
- Layered architecture:
- Presentation (clients)
- API layer (routes/controllers in server)
- Business logic & utilities (utils/convert-hour/minutes)
- Data access (Prisma)
- Persistence (SQLite)
- Clear separation of concerns between frontends and backend
- Type‐safe contracts via TypeScript on all layers

##### Technologies & frameworks
- React, React Native, Expo, Vite, Tailwind CSS
- Node.js, Express, TypeScript
- Prisma ORM, SQLite
- Expo Push Notifications

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients Layer
    subgraph "Clients"
        direction TB
        subgraph "Web App"
            direction TB
            WebApp["Web App\n(React + Vite)"]:::frontendWeb
            CADB["CreateAdBanner"]:::frontendWeb
            CADM["CreateAdModal"]:::frontendWeb
            GB["GameBanner"]:::frontendWeb
            FI["Form Input"]:::frontendWeb
        end
        subgraph "Mobile App"
            direction TB
            MobileApp["Mobile App\n(React Native + Expo)"]:::frontendMobile
            GPN["getPushNotificationToken"]:::frontendMobile
            NCFG["notificationConfigs"]:::frontendMobile
            subgraph "Mobile UI Components"
                direction TB
                MC1["GameCard"]:::frontendMobile
                MC2["DuoCard"]:::frontendMobile
                MC3["DuoInfo"]:::frontendMobile
                MC4["DuoMatch"]:::frontendMobile
                MC5["Background"]:::frontendMobile
            end
            Routes["app.routes.tsx"]:::frontendMobile
        end
    end

    %% API Server Layer
    subgraph "API Server"
        direction TB
        Server["Express Server\n(server.ts)"]:::backend
        Env[".env"]:::backend
        subgraph "Utils / Business Logic"
            direction TB
            U1["convert-hour-string-to-minutes"]:::backend
            U2["convert-minutes-to-hour-string"]:::backend
        end
        ORM["Prisma Client"]:::backend
    end

    %% Database Layer
    subgraph "Database"
        direction TB
        DB["SQLite Database"]:::database
        Schema["schema.prisma"]:::database
        MIG["Prisma Migrations"]:::database
    end

    %% External Services
    External["Expo Push Service"]:::external

    %% Data Flows
    WebApp -->|GET /games| Server
    WebApp -->|POST /ads| Server
    MobileApp -->|GET /games| Server
    MobileApp -->|POST /ads| Server
    Server -->|uses| U1
    Server -->|uses| U2
    Server -->|queries| ORM
    ORM -->|reads/writes| DB
    ORM -->|schema| Schema
    ORM -->|migrations| MIG
    Server -->|POST push notification| External

    %% Click Events
    click WebApp "https://github.com/andersonlima12/nlw-esports/tree/master/web/"
    click CADB "https://github.com/andersonlima12/nlw-esports/blob/master/web/src/components/CreateAdBanner.tsx"
    click CADM "https://github.com/andersonlima12/nlw-esports/blob/master/web/src/components/CreateAdModal.tsx"
    click GB "https://github.com/andersonlima12/nlw-esports/blob/master/web/src/components/GameBanner.tsx"
    click FI "https://github.com/andersonlima12/nlw-esports/blob/master/web/src/components/Form/Input.tsx"
    click MobileApp "https://github.com/andersonlima12/nlw-esports/tree/master/mobile/"
    click GPN "https://github.com/andersonlima12/nlw-esports/blob/master/mobile/src/service/getPushNotificationToken.ts"
    click NCFG "https://github.com/andersonlima12/nlw-esports/blob/master/mobile/src/service/notificationConfigs.ts"
    click MC1 "https://github.com/andersonlima12/nlw-esports/blob/master/mobile/src/components/GameCard.tsx"
    click MC2 "https://github.com/andersonlima12/nlw-esports/blob/master/mobile/src/components/DuoCard.tsx"
    click MC3 "https://github.com/andersonlima12/nlw-esports/blob/master/mobile/src/components/DuoInfo.tsx"
    click MC4 "https://github.com/andersonlima12/nlw-esports/blob/master/mobile/src/components/DuoMatch.tsx"
    click MC5 "https://github.com/andersonlima12/nlw-esports/blob/master/mobile/src/components/Background.tsx"
    click Routes "https://github.com/andersonlima12/nlw-esports/blob/master/mobile/src/routes/app.routes.tsx"
    click Server "https://github.com/andersonlima12/nlw-esports/blob/master/server/src/server.ts"
    click Schema "https://github.com/andersonlima12/nlw-esports/blob/master/server/prisma/schema.prisma"
    click MIG "https://github.com/andersonlima12/nlw-esports/tree/master/server/prisma/migrations/"
    click DB "https://github.com/andersonlima12/nlw-esports/blob/master/server/src/database/db.sqlite"
    click U1 "https://github.com/andersonlima12/nlw-esports/blob/master/server/src/utils/convert-hour-string-to-minutes.ts"
    click U2 "https://github.com/andersonlima12/nlw-esports/blob/master/server/src/utils/convert-minutes-to-hour-string.ts"
    click Env "https://github.com/andersonlima12/nlw-esports/blob/master/server/.env"

    %% Styling
    classDef frontendWeb fill:#D0E8FF,stroke:#037DFC,color:#000
    classDef frontendMobile fill:#DFFFE0,stroke:#28A745,color:#000
    classDef backend fill:#FFE5B4,stroke:#FF8C00,color:#000
    classDef database fill:#E0E0E0,stroke:#808080,color:#000
    classDef external fill:#F3D1FF,stroke:#800080,color:#000
```
