# systemconsultantgroup/s-top-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/systemconsultantgroup/s-top-frontend
- Repository: https://github.com/systemconsultantgroup/s-top-frontend

## Overview

Based on your provided file tree and the README, this project is clearly a Next.js–based frontend application that supports two major areas: an “admin” side and a “user” side. The app uses the latest Next.js File-based Routing with folders such as src/app/(admin) and src/app/(user) to separate concerns. It also leverages Storybook for component development/testing and includes comprehensive directories for components, hooks, utilities, constants, types, and theming. The primary purpose seems to be to drive a complex UI that handles events, notices, galleries, projects, and more for different user roles.

##### Main Components
- Frontend Application – Represented by the Next.js framework. This component encapsulates the entire code under the “src” directory (e.g., src/app, src/components, src/hooks, etc.).
- Admin Interface – The “admin” area (src/app/(admin) and corresponding admin subdirectories) which includes pages for boards, events, notices, projects, statistics, and content management.
- User Interface – The “user” area (src/app/(user)) with routes for authentication, events, jobfairs, galleries, notices, and the user dashboard.
- Shared/Global Components – A separate library for common UI elements such as Buttons, Cards, Sidebars, Headers, Footers, and other common elements located under src/components/common.
- Data Fetching & State Management – Custom hooks (found under src/hooks and src/hooks/swr) that handle API calls and state management (e.g., fetching notices, projects, etc.).
- Styling/Theming – Modules such as the theme settings, fonts, CSS modules, and global styles (in src/theme and src/styles), ensuring a consistent UI.
- Utility Functions & Constants – Utility folders (src/utils) and definitions (src/constants, src/types) that manage business logic, API configurations, and type safety.
- Configuration & Deployment – Files such as next.config.mjs, Dockerfile, GitHub workflows, and eslint/prettier configurations that support the development lifecycle.

##### Relationships and Interactions
- The Next.js framework acts as the core container which routes requests to either the admin or user modules.
- Both admin and user modules interact with shared components when rendering reusable UI elements.
- Specific hooks / data fetching functions (using SWR and custom hooks) retrieve data from backend (or external APIs) and feed it into pages and components.
- Utilities and constants provide cross-cutting support for data formatting, sort operations, and static content definitions.
- The theming module governs global styles that apply across all components and pages.
- Storybook and CI/CD configuration files integrate with the development process to support testing, development, and deployment.

##### Architectural Patterns and Design Principles
- Modular Separation: A very clear separation of concerns between admin and user areas.
- Component-Based Architecture: Centralized, reusable components are found in the common directory.
- Layered Approach: Distinct layers for UI (pages, components), business logic (hooks, utils), and configuration (constants, types).
- Reusability and Maintainability: Extensive use of shared modules (UI components, hooks) improves maintainability.
- CI/CD Integration: GitHub workflows and Docker configurations indicate an automated deployment/production process.

- “Next.js Host” as the overarching container.
- “Admin Module” and “User Module” for each routing area.
- “Shared Components Library” for common UI elements.
- “Hooks & Data Layer” for fetching and state management components.
- “Utilities & Constants” to indicate support functions, types, and configuration.
- “Styling/Theme” for global CSS, fonts, and style modules.
- Data flow: from hooks to pages/components.
- Dependency flow: from pages to shared components and utilities.
- Configuration link: showing that the entire application is configured via files like next.config.mjs, Dockerfile, and CI/CD workflows.
- Optionally, show external integrations like Storybook for component visualization and GitHub Actions for CI/CD even if they are not runtime components—they reflect the development pipeline.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Routing Layer
    A["Next.js Host"]:::host
    click A "https://github.com/systemconsultantgroup/s-top-frontend/tree/develop/src/"

    %% Modules Subgraph
    subgraph "Modules"
        B["Admin Module"]:::admin
        click B "https://github.com/systemconsultantgroup/s-top-frontend/tree/develop/src/app/(admin)"
        C["User Module"]:::user
        click C "https://github.com/systemconsultantgroup/s-top-frontend/tree/develop/src/app/(user)"
    end

    %% Shared Functionality Subgraph
    subgraph "Shared Functionality"
        D["Shared Components Library"]:::components
        click D "https://github.com/systemconsultantgroup/s-top-frontend/tree/develop/src/components/common"
        
        subgraph "Hooks & Data Layer"
            E["Custom Hooks"]:::hooks
            click E "https://github.com/systemconsultantgroup/s-top-frontend/tree/develop/src/hooks"
            F["SWR Hooks"]:::hooks
            click F "https://github.com/systemconsultantgroup/s-top-frontend/tree/develop/src/hooks/swr"
        end

        subgraph "Utilities & Constants"
            G["Utils"]:::utils
            click G "https://github.com/systemconsultantgroup/s-top-frontend/tree/develop/src/utils"
            H["Constants"]:::utils
            click H "https://github.com/systemconsultantgroup/s-top-frontend/tree/develop/src/constants"
            I["Types"]:::utils
            click I "https://github.com/systemconsultantgroup/s-top-frontend/tree/develop/src/types"
        end
    end

    %% Styling & Theming Subgraph
    subgraph "Styling & Theming"
        J["Theme"]:::styling
        click J "https://github.com/systemconsultantgroup/s-top-frontend/tree/develop/src/theme"
        K["Styles"]:::styling
        click K "https://github.com/systemconsultantgroup/s-top-frontend/tree/develop/src/styles"
    end

    %% Configuration & Deployment Subgraph
    subgraph "Configuration & Deployment"
        L["next.config.mjs"]:::config
        click L "https://github.com/systemconsultantgroup/s-top-frontend/blob/develop/next.config.mjs"
        M["Dockerfile"]:::config
        click M "https://github.com/systemconsultantgroup/s-top-frontend/tree/develop/Dockerfile"
        N[".github/workflows"]:::config
        click N "https://github.com/systemconsultantgroup/s-top-frontend/tree/develop/.github/workflows"
    end

    %% External Integration: Storybook (Optional)
    O["Storybook"]:::external

    %% Connections
    A -->|"routes to"| B
    A -->|"routes to"| C

    B -->|"uses"| D
    C -->|"uses"| D

    B -->|"fetches data via"| E
    B -->|"fetches data via"| F
    C -->|"fetches data via"| E
    C -->|"fetches data via"| F

    B -->|"depends on"| G
    B -->|"depends on"| H
    B -->|"depends on"| I
    C -->|"depends on"| G
    C -->|"depends on"| H
    C -->|"depends on"| I

    A -->|"applies"| J
    A -->|"applies"| K

    L -->|"configures"| A
    M -->|"configures"| A
    N -->|"configures"| A

    D -->|"visualized in"| O

    %% Styles
    classDef host fill:#f9f,stroke:#333,stroke-width:2px;
    classDef admin fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef user fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef components fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef hooks fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef utils fill:#ffffcc,stroke:#333,stroke-width:2px;
    classDef styling fill:#e6ccff,stroke:#333,stroke-width:2px;
    classDef config fill:#d9d9d9,stroke:#333,stroke-width:2px;
    classDef external fill:#ffefcc,stroke:#333,stroke-width:2px;
```
