# yukionishi1129/nestjs-graphql-docker-sample architecture

> Architecture diagram of the GitHub repository yukionishi1129/nestjs-graphql-docker-sample, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yukionishi1129/nestjs-graphql-docker-sample
- Repository: https://github.com/yukionishi1129/nestjs-graphql-docker-sample

## Overview

##### Project type and purpose
- This is a backend-only service sample: a NestJS GraphQL API using TypeORM and MySQL, packaged and orchestrated via Docker Compose. There is no separate frontend; the “client” is any GraphQL client or playground.

##### File structure
- Top-level:
- docker-compose.yml (defines two services: app & db)
- mysql/ (custom MySQL config)
- .env.sample, .dockerignore, .gitignore
- app/ (NestJS application)
- Dockerfile, .env.sample, ESLint/Prettier configs
- nest-cli.json, ormconfig.js(.local)
- src/
– app.controller.ts, app.service.ts, app.module.ts, main.ts
– books/ (GraphQL module: resolver, service, DTOs, entities)
– migrations/ (TypeORM migrations + factories + seeds)
– schema.gql
- test/ (e2e tests)
- tsconfig*.json, package.json
- docker-compose.yml spins up:
- app service (builds app/Dockerfile)
- db service (MySQL with custom config in mysql/mysql.cnf)

##### README insights
- Provides Docker Compose commands for build, up/down, entering containers.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Client
    Client["GraphQL Client"]:::external

    %% Orchestrator
    Orchestrator["Docker Compose Orchestrator"]:::orchestrator
    click Orchestrator "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/docker-compose.yml"

    Client -->|"GraphQL HTTP"| Orchestrator

    %% Containers
    subgraph "app: NestJS GraphQL Server" 
        direction TB
        AppDockerfile["Dockerfile"]:::config
        click AppDockerfile "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/tree/main/app/Dockerfile"
        AppEnvSample[".env.sample"]:::config
        click AppEnvSample "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/.env.sample"

        subgraph "Configuration"
            direction TB
            NestCLI["nest-cli.json"]:::config
            click NestCLI "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/nest-cli.json"
            ORMConfig["ormconfig.js"]:::config
            click ORMConfig "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/ormconfig.js"
            ORMConfigLocal["ormconfig.local.js"]:::config
            click ORMConfigLocal "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/ormconfig.local.js"
        end

        subgraph "Bootstrap"
            direction TB
            Main["main.ts"]:::code
            click Main "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/src/main.ts"
            AppModule["app.module.ts"]:::code
            click AppModule "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/src/app.module.ts"
            AppController["app.controller.ts"]:::code
            click AppController "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/src/app.controller.ts"
            AppService["app.service.ts"]:::code
            click AppService "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/src/app.service.ts"
            Schema["schema.gql"]:::code
            click Schema "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/src/schema.gql"
        end

        subgraph "Books Module" 
            direction TB
            BooksModule["books.module.ts"]:::module
            click BooksModule "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/src/books/books.module.ts"
            BooksResolver["books.resolver.ts"]:::module
            click BooksResolver "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/src/books/books.resolver.ts"
            BooksService["books.service.ts"]:::module
            click BooksService "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/src/books/books.service.ts"
            BooksDTO["newBook.input.ts"]:::module
            click BooksDTO "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/src/books/dto/newBook.input.ts"
            BookEntity["book.entity.ts"]:::module
            click BookEntity "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/src/books/entities/book.entity.ts"
        end

        subgraph "Migrations & Seeds" 
            direction TB
            Migration["1635840288943-CreateBaseTables.ts"]:::data
            click Migration "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/src/migrations/1635840288943-CreateBaseTables.ts"
            Factory["book.factory.ts"]:::data
            click Factory "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/src/migrations/factories/book.factory.ts"
            Seed["20-book.seed.ts"]:::data
            click Seed "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/src/migrations/seeds/20-book.seed.ts"
        end

        Tests["app.e2e-spec.ts"]:::test
        click Tests "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/test/app.e2e-spec.ts"
    end

    subgraph "db: MySQL Database"
        direction TB
        MyCnf["mysql.cnf"]:::config
        click MyCnf "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/mysql/mysql.cnf"
    end

    Orchestrator -->|"build & up"| AppDockerfile
    Orchestrator -->|"build & up"| MyCnf

    AppDockerfile --> Main
    Main --> AppModule
    AppModule --> AppController
    AppController --> AppService
    AppService -->|"calls"| BooksService
    BooksService -->|"uses TypeORM"| BookEntity
    BookEntity -->|"SQL over TCP:3306"| MyCnf

    Migration -->|"runs at startup"| MyCnf
    Factory -->|"runs at startup"| MyCnf
    Seed -->|"runs at startup"| MyCnf

    Client -->|"queries/mutations"| Main

    %% Config Files
    RootEnv["Root .env.sample"]:::config
    click RootEnv "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/.env.sample"
    GitRoot[".gitignore"]:::config
    click GitRoot "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/.gitignore"
    GitApp["app/.gitignore"]:::config
    click GitApp "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/.gitignore"
    ESLint[".eslintrc.js"]:::config
    click ESLint "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/.eslintrc.js"
    Prettier[".prettierrc"]:::config
    click Prettier "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/.prettierrc"
    TSConfig["tsconfig.json"]:::config
    click TSConfig "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/tsconfig.json"
    TSBuild["tsconfig.build.json"]:::config
    click TSBuild "https://github.com/yukionishi1129/nestjs-graphql-docker-sample/blob/main/app/tsconfig.build.json"

    RootEnv --> Orchestrator

    %% Styles
    classDef external fill:#f2f2f2,stroke:#333,stroke-width:1px;
    classDef orchestrator fill:#ffe4b5,stroke:#b36b00,stroke-width:2px,stroke-dasharray: 5 5;
    classDef config fill:#e0e0e0,stroke:#666,stroke-width:1px;
    classDef code fill:#d0e6f8,stroke:#1a73e8,stroke-width:1px;
    classDef module fill:#cfead9,stroke:#2e7d32,stroke-width:1px;
    classDef data fill:#fce8b2,stroke:#f9ab00,stroke-width:1px;
    classDef test fill:#fde2e2,stroke:#d32f2f,stroke-width:1px;
```
