# m-cmp/mc-web-console architecture

> Architecture diagram of the GitHub repository m-cmp/mc-web-console, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/m-cmp/mc-web-console
- Repository: https://github.com/m-cmp/mc-web-console

## Overview

##### Project Type and Purpose
- This is a full-stack web application (“M-CMP WEB Console”) built with Go/Buffalo for both frontend and backend, designed to provide multi-cloud management portals (user and admin) and open APIs.
- Key external integrations: MC-INFRA-MANAGER and MC-IAM-MANAGER services.
- Persistence: PostgreSQL database for session, user, and portal data.

##### Main Components
a. Frontend Service
- Located under `/front`
- Buffalo web server serving HTML templates, static assets (JS/CSS/images)
- Proxying API calls to the backend
- Built with Go, yarn/npm, SCSS, Tabler UI
b. Backend API Service
- Located under `/api`
- Buffalo web server exposing RESTful JSON endpoints
- Business logic in `actions/` and HTTP handlers in `handler/`
- Data models in `models/` and migrations in `migrations/`
- Integrates with external services (IAM and Infra managers)
c. Database
- PostgreSQL (container `mcwebconsole-postgresdb`)
- Schema managed via Buffalo migrations (`.fizz` files)
- Connection configured via environment (DEV/PROD_DATABASE_URL)
d. External Services
1. MC-IAM-MANAGER (Identity and Access Management)
2. MC-INFRA-MANAGER (Multi-Cloud Infrastructure Manager)
e. Orchestration & Deployment
- Docker Compose (`scripts/docker-compose.yml`)
- CI/CD pipelines (`.github/workflows`)
- Environment configuration in `/conf`

##### Relationships and Data Flows
- End user’s browser → Frontend Buffalo app (port 3000)
- Serves UI pages
- API calls go: Frontend → Backend API (port 3001) via proxy
- Backend API ↔ PostgreSQL
- CRUD operations for sessions, roles, menus, workspace-project mapping
- Backend API ↔ External Services (HTTP REST)
- AuthN/Z via IAM
- Infrastructure operations via Infra manager

##### Architectural Patterns & Principles
- Layered MVC (Buffalo’s “actions” for controllers, “models” for data, “templates” for views)
- Separation of concerns: frontend app solely handles UI/templates, backend app solely handles data/API
- Twelve-factor app principles via environment configs
- Dockerized microservices communicating over a dedicated Docker network

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User and External
    User["End User's Browser"]:::external
    IAM["MC-IAM-MANAGER"]:::externalService
    INFRA["MC-INFRA-MANAGER"]:::externalService

    %% Internal Services
    FEApp["Front-end Buffalo App\nPort 3000"]:::frontend
    BEApp["Back-end Buffalo API\nPort 3001"]:::backend

    %% Database
    DB["PostgreSQL 14\nPort 5432"]:::database

    %% Code Structure - Frontend
    subgraph "Front-end Buffalo App"
        direction TB
        FECMD["Main Entry Point\nfront/cmd/app/main.go"]:::frontend
        FEProxy["Proxy Mechanism\nfront/actions/proxy.go"]:::frontend
        FEAssets["Assets (JS/CSS/Images)\nfront/assets/"]:::frontend
        FETemplates["Templates (Views)\nfront/templates/"]:::frontend
        FEConfig["Configuration\nfront/config/\npackage.json/.babelrc/webpack.config.js"]:::frontend
    end

    %% Code Structure - Backend
    subgraph "Back-end Buffalo API"
        direction TB
        BECMD["Main Entry Point\napi/cmd/app/main.go"]:::backend
        BEActions["Controllers (actions)\napi/actions/"]:::backend
        BEHandlers["HTTP Handlers\napi/handler/"]:::backend
        BEIAMMid["IAM Middleware\napi/handler/mciammanager/middleware.go"]:::backend
        BESelf["Self-service Handlers\napi/handler/self/"]:::backend
        BEModels["Data Models\napi/models/"]:::backend
        BEMigrations["Migrations\napi/migrations/"]:::backend
        BEConfig["Configuration\napi/config/buffalo-app.toml\nbuffalo-plugins.toml\ndatabase.yml"]:::backend
    end

    %% Orchestration & CI/CD
    Orchestration["Docker Compose\nscripts/docker-compose.yml"]:::orchestration
    CICD["CI/CD Workflows\n.github/workflows/continuous-integration.yaml\n.github/workflows/continuous-delivery.yaml"]:::orchestration
    EnvConfig["Environment Samples\nconf/.env.sample\nconf/api.yaml\nconf/selfiamauthsetting.sample.yaml\nconf/webconsole_menu_permissions.csv"]:::orchestration

    %% Connections
    User -->|"HTTP/HTTPS"| FEApp
    FEApp -->|"GET/POST /api (Proxy)"| BEApp
    BEApp -->|"SQL queries"| DB
    BEApp -->|"REST calls AuthZ/AuthN"| IAM
    BEApp -->|"REST calls Infra ops"| INFRA
    Orchestration --- FEApp
    Orchestration --- BEApp
    Orchestration --- DB
    CICD --- Orchestration

    %% Click Events
    click FEApp "https://github.com/m-cmp/mc-web-console/tree/main/front/"
    click FECMD "https://github.com/m-cmp/mc-web-console/blob/main/front/cmd/app/main.go"
    click FEProxy "https://github.com/m-cmp/mc-web-console/blob/main/front/actions/proxy.go"
    click FEAssets "https://github.com/m-cmp/mc-web-console/tree/main/front/assets/"
    click FETemplates "https://github.com/m-cmp/mc-web-console/tree/main/front/templates/"
    click FEConfig "https://github.com/m-cmp/mc-web-console/tree/main/front/config/"
    click BEApp "https://github.com/m-cmp/mc-web-console/tree/main/api/"
    click BECMD "https://github.com/m-cmp/mc-web-console/blob/main/api/cmd/app/main.go"
    click BEActions "https://github.com/m-cmp/mc-web-console/tree/main/api/actions/"
    click BEHandlers "https://github.com/m-cmp/mc-web-console/tree/main/api/handler/"
    click BEIAMMid "https://github.com/m-cmp/mc-web-console/blob/main/api/handler/mciammanager/middleware.go"
    click BESelf "https://github.com/m-cmp/mc-web-console/tree/main/api/handler/self/"
    click BEModels "https://github.com/m-cmp/mc-web-console/tree/main/api/models/"
    click BEMigrations "https://github.com/m-cmp/mc-web-console/tree/main/api/migrations/"
    click BEConfig "https://github.com/m-cmp/mc-web-console/blob/main/api/config/buffalo-app.toml"
    click Orchestration "https://github.com/m-cmp/mc-web-console/blob/main/scripts/docker-compose.yml"
    click CICD "https://github.com/m-cmp/mc-web-console/blob/main/.github/workflows/continuous-integration.yaml"
    click CICD "https://github.com/m-cmp/mc-web-console/blob/main/.github/workflows/continuous-delivery.yaml"
    click EnvConfig "https://github.com/m-cmp/mc-web-console/blob/main/conf/.env.sample"

    %% Styles
    classDef frontend fill:#CCE5FF,stroke:#004085,color:#004085
    classDef backend fill:#D4EDDA,stroke:#155724,color:#155724
    classDef database fill:#D1ECF1,stroke:#0C5460,color:#0C5460
    classDef external fill:#FFF3CD,stroke:#856404,color:#856404
    classDef externalService fill:#FFE5CC,stroke:#E65C00,color:#E65C00
    classDef orchestration fill:#E2E3E5,stroke:#6C757D,color:#6C757D
```
