# shohan-nub/sql-warehouse architecture

> Architecture diagram of the GitHub repository shohan-nub/sql-warehouse, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shohan-nub/sql-warehouse
- Repository: https://github.com/shohan-nub/sql-warehouse

## Overview

1. This repository is a small full-stack-style TypeScript application centered on warehouse/inventory data. The main application lives in `backend/`, while the repo root contains Docker orchestration and the top-level README.

2. The runtime framework is Next.js (`backend/next.config.ts`, `backend/src/app/*`). That means the app is organized around a server-rendered React frontend plus server-capable app routes, rather than a separate frontend/backend split.

3. The presentation layer is very thin in the tree: `backend/src/app/page.tsx`, `layout.tsx`, and global/page CSS files. This suggests the UI is mostly a shell around a data-driven warehouse domain rather than a large client-side SPA.

4. The data layer is explicit and centralized under `backend/src/db/`. This is where the repository’s core domain model lives, using Drizzle ORM-style schema definitions and migrations.

5. The domain tables are split into separate schemas for `product`, `category`, `inventory`, `purchase`, `sales`, `warehouse`, and `relation`. Architecturally, this indicates the system models warehouse stock, product cataloging, movement of goods, and relationships between entities as first-class concepts.

6. `backend/src/db/schema/index.ts` likely acts as the composition point for all table definitions, while the individual schema files define the boundaries of each business entity. For an architecture diagram, this is the main domain boundary to draw between UI and persistence.

7. Database evolution is managed through migrations in `backend/src/db/migrations/`, with a generated snapshot/journal structure. That means schema changes are tracked and applied explicitly rather than inferred at runtime.

8. `backend/src/db/seed.ts` indicates there is seeded reference/demo data, which is important if the app expects baseline categories, warehouses, or sample inventory records for local setup.

9. `backend/drizzle.config.ts` is the database tooling configuration point, linking the TypeScript schema layer to the underlying SQL database workflow. This is the repository’s main infrastructure bridge between code and storage.

10. The `docker-compose.yml` at the repository root likely provides the supporting services needed to run the system locally, most likely the database. For an architecture diagram, treat Docker Compose as the local infrastructure layer beneath the Next.js app and DB layer.

11. There are no obvious separate service directories, message queues, or external API integrations in the tree. So the architecture appears to be a single application codebase with a local SQL persistence tier, not a distributed microservice system.

12. In short, the key flow is: user interacts with the Next.js app UI, the app reads/writes through the DB schema layer, migrations/seed manage the SQL structure and initial data, and Docker Compose supports local infrastructure. The most important diagram boundary is between the app layer and the warehouse/inventory database model.

Main entry points: [`backend/src/db/schema/index.ts`](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/schema/index.ts) (Schema index), [`backend/drizzle.config.ts`](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/drizzle.config.ts) (Drizzle config), [`backend/src/app/layout.tsx`](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/app/layout.tsx) (Layout), [`backend/src/app/page.tsx`](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/app/page.tsx) (Home page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_root["Repository"]
  node_root_readme["README<br/>repo guide<br/>[README.md]"]
  node_backend_readme["Backend README<br/>app guide<br/>[README.md]"]
end

subgraph group_app["Next.js App"]
  node_next_config["Next config<br/>framework cfg<br/>[next.config.ts]"]
  node_layout["Layout<br/>app shell<br/>[layout.tsx]"]
  node_page["Home page<br/>route page<br/>[page.tsx]"]
  node_globals_css["Global CSS<br/>styles<br/>[globals.css]"]
  node_page_css["Page CSS<br/>styles<br/>[page.module.css]"]
end

subgraph group_db["Database Layer"]
  node_drizzle_cfg["Drizzle config<br/>db tooling<br/>[drizzle.config.ts]"]
  node_schema_index["Schema index<br/>schema compose<br/>[index.ts]"]
  node_product_schema["Product<br/>domain table<br/>[product.ts]"]
  node_category_schema["Category<br/>domain table<br/>[category.ts]"]
  node_inventory_schema["Inventory<br/>domain table<br/>[inventory.ts]"]
  node_warehouse_schema["Warehouse<br/>domain table<br/>[warehouse.ts]"]
  node_purchase_schema["Purchase<br/>domain table<br/>[purchase.ts]"]
  node_sales_schema["Sales<br/>domain table<br/>[sales.ts]"]
  node_relation_schema["Relation<br/>domain table<br/>[relation.ts]"]
  node_migrations["Migrations<br/>db evolution"]
  node_seed["Seed data<br/>db seed<br/>[seed.ts]"]
end

subgraph group_infra["Local Infra"]
  node_compose["Compose<br/>local infra<br/>[docker-compose.yml]"]
end

node_root_readme -->|"documents"| node_backend_readme
node_compose -->|"supports runtime"| node_next_config
node_next_config -->|"boots"| node_layout
node_layout -->|"renders"| node_page
node_layout -->|"uses"| node_globals_css
node_page -->|"styles"| node_page_css
node_page -->|"reads data"| node_schema_index
node_drizzle_cfg -->|"binds"| node_schema_index
node_drizzle_cfg -->|"manages"| node_migrations
node_drizzle_cfg -->|"loads"| node_seed
node_schema_index -->|"includes"| node_product_schema
node_schema_index -->|"includes"| node_category_schema
node_schema_index -->|"includes"| node_inventory_schema
node_schema_index -->|"includes"| node_warehouse_schema
node_schema_index -->|"includes"| node_purchase_schema
node_schema_index -->|"includes"| node_sales_schema
node_schema_index -->|"includes"| node_relation_schema
node_migrations -->|"tracks"| node_schema_index
node_seed -->|"populates"| node_schema_index

click node_root_readme "https://github.com/shohan-nub/sql-warehouse/blob/main/README.md"
click node_backend_readme "https://github.com/shohan-nub/sql-warehouse/blob/main/backend/README.md"
click node_compose "https://github.com/shohan-nub/sql-warehouse/blob/main/docker-compose.yml"
click node_next_config "https://github.com/shohan-nub/sql-warehouse/blob/main/backend/next.config.ts"
click node_layout "https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/app/layout.tsx"
click node_page "https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/app/page.tsx"
click node_globals_css "https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/app/globals.css"
click node_page_css "https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/app/page.module.css"
click node_drizzle_cfg "https://github.com/shohan-nub/sql-warehouse/blob/main/backend/drizzle.config.ts"
click node_schema_index "https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/schema/index.ts"
click node_product_schema "https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/schema/product.ts"
click node_category_schema "https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/schema/category.ts"
click node_inventory_schema "https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/schema/inventory.ts"
click node_warehouse_schema "https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/schema/warehouse.ts"
click node_purchase_schema "https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/schema/purchase.ts"
click node_sales_schema "https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/schema/sales.ts"
click node_relation_schema "https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/schema/relation.ts"
click node_migrations "https://github.com/shohan-nub/sql-warehouse/tree/main/backend/src/db/migrations"
click node_seed "https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/seed.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_root_readme,node_backend_readme toneBlue
class node_next_config,node_layout,node_page,node_globals_css,node_page_css toneAmber
class node_drizzle_cfg,node_schema_index,node_product_schema,node_category_schema,node_inventory_schema,node_warehouse_schema,node_purchase_schema,node_sales_schema,node_relation_schema,node_migrations,node_seed toneMint
class node_compose toneRose
```

## Components

### Repository

Top-level repo orchestration and documentation

- [README](https://github.com/shohan-nub/sql-warehouse/blob/main/README.md): repo guide · Top-level repository overview and setup notes · `README.md`
- [Backend README](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/README.md): app guide · Backend-specific usage and development notes · `backend/README.md`

### Next.js App

Server-rendered application shell and route layer

- [Next config](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/next.config.ts): framework cfg · Next.js runtime and build configuration · `backend/next.config.ts`
- [Layout](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/app/layout.tsx): app shell · Root application layout and shared UI structure · `backend/src/app/layout.tsx`
- [Home page](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/app/page.tsx): route page · Primary UI entry point for the app · `backend/src/app/page.tsx`
- [Global CSS](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/app/globals.css): styles · Global styling for the app shell · `backend/src/app/globals.css`
- [Page CSS](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/app/page.module.css): styles · Scoped styling for the home page · `backend/src/app/page.module.css`

### Database Layer

Schema, migrations, seeding, and DB tooling

- [Drizzle config](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/drizzle.config.ts): db tooling · Links TypeScript schema to database tooling · `backend/drizzle.config.ts`
- [Schema index](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/schema/index.ts): schema compose · Aggregates the domain table definitions · `backend/src/db/schema/index.ts`
- [Product](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/schema/product.ts): domain table · Product catalog and item identity · `backend/src/db/schema/product.ts`
- [Category](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/schema/category.ts): domain table · Product grouping and classification · `backend/src/db/schema/category.ts`
- [Inventory](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/schema/inventory.ts): domain table · Stock quantities and availability records · `backend/src/db/schema/inventory.ts`
- [Warehouse](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/schema/warehouse.ts): domain table · Physical storage locations · `backend/src/db/schema/warehouse.ts`
- [Purchase](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/schema/purchase.ts): domain table · Inbound procurement and stock intake · `backend/src/db/schema/purchase.ts`
- [Sales](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/schema/sales.ts): domain table · Outbound sales and stock depletion · `backend/src/db/schema/sales.ts`
- [Relation](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/schema/relation.ts): domain table · Cross-entity links and associations · `backend/src/db/schema/relation.ts`
- [Migrations](https://github.com/shohan-nub/sql-warehouse/tree/main/backend/src/db/migrations): db evolution · Versioned schema changes and migration state · `backend/src/db/migrations`
- [Seed data](https://github.com/shohan-nub/sql-warehouse/blob/main/backend/src/db/seed.ts): db seed · Baseline and demo data loader · `backend/src/db/seed.ts`

### Local Infra

Docker-based local runtime support

- [Compose](https://github.com/shohan-nub/sql-warehouse/blob/main/docker-compose.yml): local infra · Docker Compose entrypoint for local services · `docker-compose.yml`

## Connections

- README → Backend README: documents · Repository documentation points to backend-specific guidance
- Compose → Next config: supports runtime · Local infrastructure supports the Next.js application
- Next config → Layout: boots · Next.js configuration drives the app shell
- Layout → Home page: renders · Shared layout wraps the home route
- Layout → Global CSS: uses · Layout imports global styling
- Home page → Page CSS: styles · Home page uses scoped CSS module styling
- Home page → Schema index: reads data · UI relies on the warehouse domain model
- Drizzle config → Schema index: binds · DB tooling consumes the composed schema
- Drizzle config → Migrations: manages · Tooling targets the migration workflow
- Drizzle config → Seed data: loads · Tooling connects schema to seed data
- Schema index → Product: includes · Composed domain schema includes product definitions
- Schema index → Category: includes · Composed domain schema includes category definitions
- Schema index → Inventory: includes · Composed domain schema includes inventory definitions
- Schema index → Warehouse: includes · Composed domain schema includes warehouse definitions
- Schema index → Purchase: includes · Composed domain schema includes purchase definitions
- Schema index → Sales: includes · Composed domain schema includes sales definitions
- Schema index → Relation: includes · Composed domain schema includes relation definitions
- Migrations → Schema index: tracks · Migration history evolves the composed schema
- Seed data → Schema index: populates · Seed data is shaped by the domain schema
