# mm95w/aws-3tier-infra architecture

> Architecture diagram of the GitHub repository mm95w/aws-3tier-infra, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mm95w/aws-3tier-infra
- Repository: https://github.com/mm95w/aws-3tier-infra

## Overview

StockFlow is an inventory-management application with a React client, Express API and PostgreSQL access through Prisma. Users authenticate, then use dashboard, product and order screens; the API also exposes category, supplier, user and notification capabilities. The graph preserves those documented modules, including areas whose implementation was not excerpted. Edges follow shown imports, calls and route registration; client-to-server HTTP links are dashed because endpoint wiring was not shown.

Main entry points: [`app/server/src/app.ts`](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/app.ts) (API application), [`app/server/src/modules/products/products.routes.ts`](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/products/products.routes.ts) (Product routes), [`app/server/src/modules/orders/orders.routes.ts`](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/orders/orders.routes.ts) (Order routes), [`app/client/src/App.tsx`](https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/App.tsx) (Client routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Client routes<br/>[App.tsx]"]
  node_authui["Session context<br/>[AuthContext.tsx]"]
  node_guard["Route guard<br/>[ProtectedRoute.tsx]"]
  node_layout["App layout<br/>[Layout.tsx]"]
  node_loginpage["Login screen<br/>[LoginPage.tsx]"]
  node_dashboardpage["Dashboard screen<br/>[DashboardPage.tsx]"]
  node_productpage["Products screen<br/>[ProductsPage.tsx]"]
  node_orderpage["Orders screen<br/>[OrdersPage.tsx]"]
  node_resources["API resources<br/>[resources.ts]"]
  node_httpclient["HTTP client<br/>[axiosClient.ts]"]
end

subgraph group_api["API and authentication"]
  node_serverapp["API application<br/>[app.ts]"]
  node_authroutes["Auth routes<br/>[auth.routes.ts]"]
  node_authcontroller["Auth controller<br/>[auth.controller.ts]"]
  node_authservice["Auth service<br/>[auth.service.ts]"]
  node_authschema["Auth validation<br/>[auth.schema.ts]"]
end

subgraph group_operations["Inventory operations"]
  node_productsroutes["Product routes<br/>[products.routes.ts]"]
  node_productscontroller["Product controller"]
  node_productsservice["Product service"]
  node_productsschema["Product validation<br/>[products.schema.ts]"]
  node_ordersroutes["Order routes<br/>[orders.routes.ts]"]
  node_orderscontroller["Order controller"]
  node_ordersservice["Order service<br/>[orders.service.ts]"]
  node_ordersschema["Order validation<br/>[orders.schema.ts]"]
  node_categories["Categories"]
  node_suppliers["Suppliers"]
  node_users["User management<br/>[users.routes.ts]"]
  node_dashboard["Dashboard data"]
  node_dashboardroutes["Dashboard routes"]
  node_notifications["Notifications"]
end

subgraph group_runtime["Runtime and data"]
  node_authmiddleware["Token authentication<br/>[auth.ts]"]
  node_rbac["Role access<br/>[rbac.ts]"]
  node_validation["Request validation<br/>[validate.ts]"]
  node_async["Async handler<br/>[asyncHandler.ts]"]
end

node_user(("User"))

node_user -->|"signs in"| node_loginpage
node_app -->|"routes to"| node_loginpage
node_app -->|"protects pages"| node_guard
node_app -->|"wraps pages"| node_layout
node_app -->|"routes to"| node_dashboardpage
node_app -->|"routes to"| node_productpage
node_app -->|"routes to"| node_orderpage
node_loginpage -->|"uses session"| node_authui
node_guard -->|"checks session"| node_authui
node_layout -->|"uses session"| node_authui
node_authui -->|"calls auth API"| node_resources
node_resources -->|"sends requests"| node_httpclient
node_dashboardpage -->|"fetches data"| node_resources
node_productpage -->|"fetches data"| node_resources
node_orderpage -->|"fetches data"| node_resources
node_httpclient -.->|"HTTP requests"| node_serverapp
node_serverapp -->|"mounts routes"| node_authroutes
node_serverapp -->|"mounts routes"| node_productsroutes
node_serverapp -->|"mounts routes"| node_ordersroutes
node_serverapp -->|"mounts routes"| node_categories
node_serverapp -->|"mounts routes"| node_suppliers
node_serverapp -->|"mounts routes"| node_users
node_serverapp -->|"mounts routes"| node_dashboardroutes
node_serverapp -->|"mounts routes"| node_notifications
node_authroutes -->|"dispatches to"| node_authcontroller
node_authroutes -->|"validates with"| node_authschema
node_authroutes -->|"uses middleware"| node_validation
node_authroutes -->|"uses middleware"| node_authmiddleware
node_authroutes -->|"wraps handlers"| node_async
node_authcontroller -->|"calls"| node_authservice
node_authservice -->|"uses token type"| node_authmiddleware
node_productsroutes -->|"dispatches to"| node_productscontroller
node_productsroutes -->|"validates with"| node_productsschema
node_productsroutes -->|"authenticates"| node_authmiddleware
node_productsroutes -->|"checks roles"| node_rbac
node_productsroutes -->|"uses middleware"| node_validation
node_productsroutes -->|"wraps handlers"| node_async
node_productscontroller -->|"calls"| node_productsservice
node_ordersroutes -->|"dispatches to"| node_orderscontroller
node_ordersroutes -->|"validates with"| node_ordersschema
node_ordersroutes -->|"authenticates"| node_authmiddleware
node_ordersroutes -->|"checks roles"| node_rbac
node_ordersroutes -->|"uses middleware"| node_validation
node_ordersroutes -->|"wraps handlers"| node_async
node_orderscontroller -->|"calls"| node_ordersservice
node_dashboardroutes -->|"authenticates"| node_authmiddleware
node_dashboardroutes -->|"calls"| node_dashboard
node_categories -->|"authenticates"| node_authmiddleware

click node_app "https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/App.tsx"
click node_authui "https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/auth/AuthContext.tsx"
click node_guard "https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/auth/ProtectedRoute.tsx"
click node_layout "https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/components/layout/Layout.tsx"
click node_loginpage "https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/pages/LoginPage.tsx"
click node_dashboardpage "https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/pages/DashboardPage.tsx"
click node_productpage "https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/pages/ProductsPage.tsx"
click node_orderpage "https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/pages/OrdersPage.tsx"
click node_resources "https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/api/resources.ts"
click node_httpclient "https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/api/axiosClient.ts"
click node_serverapp "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/app.ts"
click node_authroutes "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/auth/auth.routes.ts"
click node_authcontroller "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/auth/auth.controller.ts"
click node_authservice "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/auth/auth.service.ts"
click node_authschema "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/auth/auth.schema.ts"
click node_productsroutes "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/products/products.routes.ts"
click node_productscontroller "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/products/products.controller.ts"
click node_productsservice "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/products/products.service.ts"
click node_productsschema "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/products/products.schema.ts"
click node_ordersroutes "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/orders/orders.routes.ts"
click node_orderscontroller "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/orders/orders.controller.ts"
click node_ordersservice "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/orders/orders.service.ts"
click node_ordersschema "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/orders/orders.schema.ts"
click node_categories "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/categories/categories.routes.ts"
click node_suppliers "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/suppliers/suppliers.routes.ts"
click node_users "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/users/users.routes.ts"
click node_dashboard "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/dashboard/dashboard.service.ts"
click node_dashboardroutes "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/dashboard/dashboard.routes.ts"
click node_notifications "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/notifications/notifications.routes.ts"
click node_authmiddleware "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/middleware/auth.ts"
click node_rbac "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/middleware/rbac.ts"
click node_validation "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/middleware/validate.ts"
click node_async "https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/utils/asyncHandler.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_app,node_authui,node_guard,node_layout,node_loginpage,node_dashboardpage,node_productpage,node_orderpage,node_resources,node_httpclient,node_user toneBlue
class node_serverapp,node_authroutes,node_authcontroller,node_authservice,node_authschema toneAmber
class node_productsroutes,node_productscontroller,node_productsservice,node_productsschema,node_ordersroutes,node_orderscontroller,node_ordersservice,node_ordersschema,node_categories,node_suppliers,node_users,node_dashboard,node_dashboardroutes,node_notifications toneMint
class node_authmiddleware,node_rbac,node_validation,node_async toneRose
```

## Components

### Web client

- [Client routes](https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/App.tsx): `app/client/src/App.tsx`
- [Session context](https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/auth/AuthContext.tsx): `app/client/src/auth/AuthContext.tsx`
- [Route guard](https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/auth/ProtectedRoute.tsx): `app/client/src/auth/ProtectedRoute.tsx`
- [App layout](https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/components/layout/Layout.tsx): `app/client/src/components/layout/Layout.tsx`
- [Login screen](https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/pages/LoginPage.tsx): `app/client/src/pages/LoginPage.tsx`
- [Dashboard screen](https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/pages/DashboardPage.tsx): `app/client/src/pages/DashboardPage.tsx`
- [Products screen](https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/pages/ProductsPage.tsx): `app/client/src/pages/ProductsPage.tsx`
- [Orders screen](https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/pages/OrdersPage.tsx): `app/client/src/pages/OrdersPage.tsx`
- [API resources](https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/api/resources.ts): `app/client/src/api/resources.ts`
- [HTTP client](https://github.com/mm95w/aws-3tier-infra/blob/main/app/client/src/api/axiosClient.ts): `app/client/src/api/axiosClient.ts`

### API and authentication

- [API application](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/app.ts): `app/server/src/app.ts`
- [Auth routes](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/auth/auth.routes.ts): `app/server/src/modules/auth/auth.routes.ts`
- [Auth controller](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/auth/auth.controller.ts): `app/server/src/modules/auth/auth.controller.ts`
- [Auth service](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/auth/auth.service.ts): `app/server/src/modules/auth/auth.service.ts`
- [Auth validation](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/auth/auth.schema.ts): `app/server/src/modules/auth/auth.schema.ts`

### Inventory operations

- [Product routes](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/products/products.routes.ts): `app/server/src/modules/products/products.routes.ts`
- [Product controller](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/products/products.controller.ts): `app/server/src/modules/products/products.controller.ts`
- [Product service](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/products/products.service.ts): `app/server/src/modules/products/products.service.ts`
- [Product validation](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/products/products.schema.ts): `app/server/src/modules/products/products.schema.ts`
- [Order routes](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/orders/orders.routes.ts): `app/server/src/modules/orders/orders.routes.ts`
- [Order controller](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/orders/orders.controller.ts): `app/server/src/modules/orders/orders.controller.ts`
- [Order service](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/orders/orders.service.ts): `app/server/src/modules/orders/orders.service.ts`
- [Order validation](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/orders/orders.schema.ts): `app/server/src/modules/orders/orders.schema.ts`
- [Categories](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/categories/categories.routes.ts): `app/server/src/modules/categories/categories.routes.ts`
- [Suppliers](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/suppliers/suppliers.routes.ts): `app/server/src/modules/suppliers/suppliers.routes.ts`
- [User management](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/users/users.routes.ts): `app/server/src/modules/users/users.routes.ts`
- [Dashboard data](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/dashboard/dashboard.service.ts): `app/server/src/modules/dashboard/dashboard.service.ts`
- [Dashboard routes](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/dashboard/dashboard.routes.ts): `app/server/src/modules/dashboard/dashboard.routes.ts`
- [Notifications](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/modules/notifications/notifications.routes.ts): `app/server/src/modules/notifications/notifications.routes.ts`

### Runtime and data

- [Token authentication](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/middleware/auth.ts): `app/server/src/middleware/auth.ts`
- [Role access](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/middleware/rbac.ts): `app/server/src/middleware/rbac.ts`
- [Request validation](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/middleware/validate.ts): `app/server/src/middleware/validate.ts`
- [Async handler](https://github.com/mm95w/aws-3tier-infra/blob/main/app/server/src/utils/asyncHandler.ts): `app/server/src/utils/asyncHandler.ts`

### Other components

- **User**

## Connections

- User → Login screen: signs in
- Client routes → Login screen: routes to (evidence: `app/client/src/App.tsx`)
- Client routes → Route guard: protects pages (evidence: `app/client/src/App.tsx`)
- Client routes → App layout: wraps pages (evidence: `app/client/src/App.tsx`)
- Client routes → Dashboard screen: routes to (evidence: `app/client/src/App.tsx`)
- Client routes → Products screen: routes to (evidence: `app/client/src/App.tsx`)
- Client routes → Orders screen: routes to (evidence: `app/client/src/App.tsx`)
- Login screen → Session context: uses session (evidence: `app/client/src/pages/LoginPage.tsx`)
- Route guard → Session context: checks session (evidence: `app/client/src/auth/ProtectedRoute.tsx`)
- App layout → Session context: uses session (evidence: `app/client/src/components/layout/Layout.tsx`)
- Session context → API resources: calls auth API (evidence: `app/client/src/auth/AuthContext.tsx`)
- API resources → HTTP client: sends requests (evidence: `app/client/src/api/resources.ts`)
- Dashboard screen → API resources: fetches data (evidence: `app/client/src/pages/DashboardPage.tsx`)
- Products screen → API resources: fetches data (evidence: `app/client/src/pages/ProductsPage.tsx`)
- Orders screen → API resources: fetches data (evidence: `app/client/src/pages/OrdersPage.tsx`)
- HTTP client → API application: HTTP requests
- API application → Auth routes: mounts routes (evidence: `app/server/src/app.ts`)
- API application → Product routes: mounts routes (evidence: `app/server/src/app.ts`)
- API application → Order routes: mounts routes (evidence: `app/server/src/app.ts`)
- API application → Categories: mounts routes (evidence: `app/server/src/app.ts`)
- API application → Suppliers: mounts routes (evidence: `app/server/src/app.ts`)
- API application → User management: mounts routes (evidence: `app/server/src/app.ts`)
- API application → Dashboard routes: mounts routes (evidence: `app/server/src/app.ts`)
- API application → Notifications: mounts routes (evidence: `app/server/src/app.ts`)
- Auth routes → Auth controller: dispatches to (evidence: `app/server/src/modules/auth/auth.routes.ts`)
- Auth routes → Auth validation: validates with (evidence: `app/server/src/modules/auth/auth.routes.ts`)
- Auth routes → Request validation: uses middleware (evidence: `app/server/src/modules/auth/auth.routes.ts`)
- Auth routes → Token authentication: uses middleware (evidence: `app/server/src/modules/auth/auth.routes.ts`)
- Auth routes → Async handler: wraps handlers (evidence: `app/server/src/modules/auth/auth.routes.ts`)
- Auth controller → Auth service: calls (evidence: `app/server/src/modules/auth/auth.controller.ts`)
- Auth service → Token authentication: uses token type (evidence: `app/server/src/modules/auth/auth.service.ts`)
- Product routes → Product controller: dispatches to (evidence: `app/server/src/modules/products/products.routes.ts`)
- Product routes → Product validation: validates with (evidence: `app/server/src/modules/products/products.routes.ts`)
- Product routes → Token authentication: authenticates (evidence: `app/server/src/modules/products/products.routes.ts`)
- Product routes → Role access: checks roles (evidence: `app/server/src/modules/products/products.routes.ts`)
- Product routes → Request validation: uses middleware (evidence: `app/server/src/modules/products/products.routes.ts`)
- Product routes → Async handler: wraps handlers (evidence: `app/server/src/modules/products/products.routes.ts`)
- Product controller → Product service: calls (evidence: `app/server/src/modules/products/products.controller.ts`)
- Order routes → Order controller: dispatches to (evidence: `app/server/src/modules/orders/orders.routes.ts`)
- Order routes → Order validation: validates with (evidence: `app/server/src/modules/orders/orders.routes.ts`)
- Order routes → Token authentication: authenticates (evidence: `app/server/src/modules/orders/orders.routes.ts`)
- Order routes → Role access: checks roles (evidence: `app/server/src/modules/orders/orders.routes.ts`)
- Order routes → Request validation: uses middleware (evidence: `app/server/src/modules/orders/orders.routes.ts`)
- Order routes → Async handler: wraps handlers (evidence: `app/server/src/modules/orders/orders.routes.ts`)
- Order controller → Order service: calls (evidence: `app/server/src/modules/orders/orders.controller.ts`)
- Dashboard routes → Token authentication: authenticates (evidence: `app/server/src/modules/dashboard/dashboard.routes.ts`)
- Dashboard routes → Dashboard data: calls (evidence: `app/server/src/modules/dashboard/dashboard.routes.ts`)
- Categories → Token authentication: authenticates (evidence: `app/server/src/modules/categories/categories.routes.ts`)
