# morris3979/instai_web_server architecture

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

- Interactive diagram: https://gitdiagram.com/morris3979/instai_web_server
- Repository: https://github.com/morris3979/instai_web_server

## Overview

##### Project type and purpose
- This is a full-stack web application for managing organizations, projects, users, devices, data annotation, and model inference using a React/Redux frontend and a Node.js/Express backend. It integrates with AWS IoT and S3 and persists metadata in a database (via ORM models in src/server/database).

##### File structure
- Top-level:
- Dockerfile, .env, build/config files → Dockerized deployment and environment configuration
- public/ and webpack.config.js → React single-page app entry served by Webpack
- src/client/ → React components, pages, Redux store
- src/server/ → Express server code, controllers, routes, middleware, protocol adapters and database models
- Notice MVC-style separation in backend (routes → controllers → database models) and Redux pattern in frontend (components → actions → reducers → store).
- Protocol support for HTTP, HTTPS, TCP under src/server/protocol.
- AWS integrations under src/server/controllers/cloud service.

##### Detail
- Subsystem: protocol adapters, routing layer, controller modules (data, device, model, label, organization, user), AWS service controllers, ORM models.
- Don’t oversimplify: capture how annotation page interacts with TF-YOLO web model assets loaded from public/static or S3.
- How Dockerfile and scripts integrate into deployment pipeline.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        Browser["User Browser"]:::client
        Webpack["Webpack Dev/Static Server"]:::client
        ReactApp["React/Redux Frontend"]:::client
        Entry["React Entry (index.js)"]:::client
        MainApp["Main App Component (App.js)"]:::client
        Annotation["Annotation Page Component"]:::client
        TFYolo["TF-YOLO Project Page Component"]:::client
        Store["Redux Store"]:::client
        ActionsReducers["Actions & Reducers"]:::client
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        ServerBootstrap["Express Server Bootstrap (server.js)"]:::backend

        subgraph "Protocol Adapters"
            direction TB
            HTTP["HTTP Adapter"]:::backend
            HTTPS["HTTPS Adapter"]:::backend
            TCP["TCP Adapter"]:::backend
        end

        AuthMiddleware["Auth Middleware"]:::backend

        subgraph "Routing Layer"
            direction TB
            RoutesIndex["Routes Index"]:::backend
            APIRoutes["API Routing Layer"]:::backend
        end

        subgraph "Controllers"
            direction TB
            UserCtrl["User Controller"]:::backend
            OrgCtrl["Organization Controller"]:::backend
            ProjectCtrl["Project Controller"]:::backend
            DeviceCtrl["Device Controller"]:::backend
            DataCtrl["Data Controller"]:::backend
            LabelCtrl["Label Controller"]:::backend
            ModelCtrl["Model Controller"]:::backend
            AWSIoTCtrl["AWS IoT Controller"]:::backend
            AWSS3Ctrl["AWS S3 Controller"]:::backend
        end

        subgraph "Database Layer"
            direction TB
            DBInit["Database Init"]:::backend
            ORMModels["ORM Models"]:::backend
            UserModel["User.model.js"]:::backend
            ProjectModel["Project.model.js"]:::backend
            DeviceModel["Device.model.js"]:::backend
        end
    end

    %% External Services
    subgraph "External Services"
        direction TB
        AWSIoT["AWS IoT"]:::external
        AWSS3["AWS S3"]:::external
        DB["Database"]:::db
    end

    %% Deployment & CI/CD
    subgraph "Deployment & CI/CD"
        direction TB
        DockerfileNode["Dockerfile & Config"]:::deployment
        CIWorkflow["CI/CD Workflow"]:::deployment
    end

    %% Connections
    Browser -->|"loads SPA"| Webpack
    Webpack -->|serves| ReactApp
    ReactApp -->|imports| Entry
    ReactApp -->|uses| MainApp
    MainApp -->|renders| Annotation
    MainApp -->|renders| TFYolo
    ReactApp -->|connects to| Store
    Store -->|uses| ActionsReducers

    ReactApp -->|"HTTPS JSON"| HTTP
    ReactApp -->|"HTTPS JSON"| HTTPS

    HTTP -->|forwards| ServerBootstrap
    HTTPS -->|forwards| ServerBootstrap
    TCP -->|device messages| ServerBootstrap

    ServerBootstrap -->|uses| AuthMiddleware
    ServerBootstrap -->|loads| RoutesIndex
    RoutesIndex -->|includes| APIRoutes
    APIRoutes -->|uses| AuthMiddleware
    APIRoutes -->|routes to| UserCtrl
    APIRoutes -->|routes to| OrgCtrl
    APIRoutes -->|routes to| ProjectCtrl
    APIRoutes -->|routes to| DeviceCtrl
    APIRoutes -->|routes to| DataCtrl
    APIRoutes -->|routes to| LabelCtrl
    APIRoutes -->|routes to| ModelCtrl
    APIRoutes -->|routes to| AWSIoTCtrl
    APIRoutes -->|routes to| AWSS3Ctrl

    UserCtrl -->|CRUD| DBInit
    OrgCtrl -->|CRUD| DBInit
    ProjectCtrl -->|CRUD| DBInit
    DeviceCtrl -->|CRUD| DBInit
    DataCtrl -->|CRUD| DBInit
    LabelCtrl -->|CRUD| DBInit
    ModelCtrl -->|CRUD| DBInit

    AWSIoTCtrl -->|MQTT/TCP| AWSIoT
    AWSIoTCtrl -->|metadata| DBInit
    AWSS3Ctrl -->|storage| AWSS3

    DBInit -->|manages| ORMModels
    ORMModels -->|contains| UserModel
    ORMModels -->|contains| ProjectModel
    ORMModels -->|contains| DeviceModel

    DockerfileNode -->|packages| ReactApp
    DockerfileNode -->|packages| ServerBootstrap
    CIWorkflow -->|deploys| DockerfileNode

    %% Click events
    click ReactApp "https://github.com/morris3979/instai_web_server/tree/main/src/client"
    click Entry "https://github.com/morris3979/instai_web_server/blob/main/src/client/index.js"
    click MainApp "https://github.com/morris3979/instai_web_server/blob/main/src/client/App.js"
    click Annotation "https://github.com/morris3979/instai_web_server/tree/main/src/client/component/annotationPage"
    click TFYolo "https://github.com/morris3979/instai_web_server/tree/main/src/client/component/projectPage/TFYolo"
    click Store "https://github.com/morris3979/instai_web_server/blob/main/src/client/store/store.js"
    click ActionsReducers "https://github.com/morris3979/instai_web_server/blob/main/src/client/store/actionCreater.js"
    click ActionsReducers "https://github.com/morris3979/instai_web_server/blob/main/src/client/store/reducer.js"
    click ActionsReducers "https://github.com/morris3979/instai_web_server/blob/main/src/client/store/actionType.js"
    click Webpack "https://github.com/morris3979/instai_web_server/blob/main/webpack.config.js"
    click Webpack "https://github.com/morris3979/instai_web_server/tree/main/public/"
    click ServerBootstrap "https://github.com/morris3979/instai_web_server/blob/main/src/server/server.js"
    click HTTP "https://github.com/morris3979/instai_web_server/blob/main/src/server/protocol/http/index.js"
    click HTTPS "https://github.com/morris3979/instai_web_server/blob/main/src/server/protocol/https/index.js"
    click TCP "https://github.com/morris3979/instai_web_server/blob/main/src/server/protocol/tcp/index.js"
    click APIRoutes "https://github.com/morris3979/instai_web_server/tree/main/src/server/routes/api"
    click RoutesIndex "https://github.com/morris3979/instai_web_server/blob/main/src/server/routes/index.js"
    click AuthMiddleware "https://github.com/morris3979/instai_web_server/blob/main/src/server/middleware/auth.js"
    click Controllers "https://github.com/morris3979/instai_web_server/tree/main/src/server/controllers"
    click AWSIoTCtrl "https://github.com/morris3979/instai_web_server/blob/main/src/server/controllers/cloud service/aws.iot.controller.js"
    click AWSS3Ctrl "https://github.com/morris3979/instai_web_server/blob/main/src/server/controllers/cloud service/aws.s3.controller.js"
    click UserCtrl "https://github.com/morris3979/instai_web_server/blob/main/src/server/controllers/user.controller.js"
    click OrgCtrl "https://github.com/morris3979/instai_web_server/blob/main/src/server/controllers/organization.controller.js"
    click ProjectCtrl "https://github.com/morris3979/instai_web_server/blob/main/src/server/controllers/project.controller.js"
    click DeviceCtrl "https://github.com/morris3979/instai_web_server/blob/main/src/server/controllers/device.controller.js"
    click DataCtrl "https://github.com/morris3979/instai_web_server/blob/main/src/server/controllers/data.controller.js"
    click LabelCtrl "https://github.com/morris3979/instai_web_server/blob/main/src/server/controllers/label.controller.js"
    click ModelCtrl "https://github.com/morris3979/instai_web_server/blob/main/src/server/controllers/model.controller.js"
    click DBInit "https://github.com/morris3979/instai_web_server/blob/main/src/server/database/index.js"
    click ORMModels "https://github.com/morris3979/instai_web_server/tree/main/src/server/database/model"
    click UserModel "https://github.com/morris3979/instai_web_server/blob/main/src/server/database/model/User.model.js"
    click ProjectModel "https://github.com/morris3979/instai_web_server/blob/main/src/server/database/model/Project.model.js"
    click DeviceModel "https://github.com/morris3979/instai_web_server/blob/main/src/server/database/model/Device.model.js"
    click DockerfileNode "https://github.com/morris3979/instai_web_server/tree/main/Dockerfile"
    click DockerfileNode "https://github.com/morris3979/instai_web_server/blob/main/.dockerignore"
    click DockerfileNode "https://github.com/morris3979/instai_web_server/blob/main/.env"
    click DockerfileNode "https://github.com/morris3979/instai_web_server/blob/main/appspec.yml"
    click CIWorkflow "https://github.com/morris3979/instai_web_server/blob/main/.github/workflows/codesee-arch-diagram.yml"

    %% Styles
    classDef client fill:#D0E6FF,stroke:#4A90E2,color:#000
    classDef backend fill:#DFF2D8,stroke:#3C763D,color:#000
    classDef external fill:#EEEEEE,stroke:#AAAAAA,color:#000
    classDef db fill:#FFEFD5,stroke:#E67E22,color:#000
    classDef deployment fill:#F5F5F5,stroke:#7F8C8D,color:#000
```
