# shpota/skmz architecture

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

- Interactive diagram: https://gitdiagram.com/shpota/skmz
- Repository: https://github.com/shpota/skmz

## Overview

##### Main Components
- Backend Server: This is located in the /server directory. It includes sub-components such as:
‣ GraphQL API (under the gql folder) implemented with gqlgen.
‣ Database access (under the db folder) for MongoDB, with an initialization script (mongo.init).
‣ CORS middleware (under the cors folder) to manage cross-origin requests.
‣ Models and server startup logic (in the model directory and server.go).
- Frontend Application: Found in the /webapp directory, it is a React-based project that includes public HTML files and a source folder (src) with components for programmers, skills, and search functionality.
- Database: MongoDB serves as the backend database, which is initialized with test records via the provided docker-compose-dev configuration.
- Docker Infrastructure: Dockerfile, docker-compose.yml, and docker-compose-dev.yml illustrate that the project is containerized for both production and development modes.

##### Relationships and Interactions
- The Frontend (React UI) communicates with the Backend (GraphQL API) via HTTP (and likely WebSocket if subscriptions are used, though not explicitly mentioned).
- The Backend processes incoming GraphQL queries, performs business logic, and interacts with MongoDB to access or update programmer data.
- External clients (developers) or tools can also interact with the GraphQL Playground (accessible via the backend) to test queries.
- Docker Compose setups tie all these components together, facilitating local development and production deployment.

##### Important Architectural Patterns and Design Principles
- Separation of Concerns: Clear split between frontend and backend codebases.
- API-Driven Architecture: Backend exposes a GraphQL endpoint (with a defined schema in schema.graphql) to serve data requests.
- Containerization: The use of Docker ensures consistent and reproducible environments.
- Modular Design: Inside the server, the code is organized in dedicated folders (for CORS, DB, GraphQL resolvers) indicating adherence to modular coding practices.
- Automated Testing: The presence of *_test.go files suggests an emphasis on code tests for backend logic.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend
    FE["React Frontend (/webapp)"]:::frontend

    %% External components
    GP["GraphQL Playground"]:::external
    DBNode["MongoDB Database"]:::database

    %% Docker Infrastructure Aggregate Node
    DEnv["Docker Environment"]:::docker

    %% Go Backend Subgraph
    subgraph "Go Backend"
        %% GraphQL API Sub-component as Subgraph
        subgraph "GraphQL API"
            GA["GraphQL API (/server/gql)"]:::api
            GS["Schema (/server/gql/schema.graphql)"]:::api
            GC["gqlgen Config (/server/gqlgen.yml)"]:::api
            GG["Generated Code (/server/gql/gen)"]:::api
        end
        DB["Database Access (/server/db)"]:::backend
        CORS["CORS Middleware (/server/cors)"]:::backend
        DM["Domain Models (/server/model)"]:::backend
        Srv["Server Startup (/server/server.go)"]:::backend
    end

    %% Docker Files Subgraph
    subgraph "Docker Infrastructure Files"
        DF["Dockerfile"]:::docker
        DCY["docker-compose.yml"]:::docker
        DCYDEV["docker-compose-dev.yml"]:::docker
    end

    %% Connections
    FE -->|"HTTP"| GA
    GA -->|"DBQuery"| DBNode
    GP -->|"TestQuery"| GA
    DM -->|"initializes"| Srv

    %% Docker Files associate with Docker Environment
    DF --- DEnv
    DCY --- DEnv
    DCYDEV --- DEnv

    %% Docker Environment deploys Frontend and Backend
    DEnv -->|"Deploys"| FE
    DEnv -->|"Deploys"| GA

    %% Class definitions for styling
    classDef frontend fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef backend fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef api fill:#fad7a0,stroke:#e67e22,stroke-width:2px;
    classDef database fill:#abebc6,stroke:#27ae60,stroke-width:2px;
    classDef external fill:#d2b4de,stroke:#8e44ad,stroke-width:2px;
    classDef docker fill:#f5cba7,stroke:#af601a,stroke-width:2px;

    %% Click Events
    click FE "https://github.com/shpota/skmz/tree/master//webapp"
    click GA "https://github.com/shpota/skmz/tree/master//server/gql"
    click GS "https://github.com/shpota/skmz/blob/master//server/gql/schema.graphql"
    click GC "https://github.com/shpota/skmz/blob/master//server/gqlgen.yml"
    click GG "https://github.com/shpota/skmz/tree/master//server/gql/gen"
    click DB "https://github.com/shpota/skmz/tree/master//server/db"
    click CORS "https://github.com/shpota/skmz/blob/master//server/cors/cors.go"
    click DM "https://github.com/shpota/skmz/blob/master//server/model/models.go"
    click Srv "https://github.com/shpota/skmz/blob/master//server/server.go"
    click DF "https://github.com/shpota/skmz/tree/master/Dockerfile"
    click DCY "https://github.com/shpota/skmz/blob/master/docker-compose.yml"
    click DCYDEV "https://github.com/shpota/skmz/blob/master/docker-compose-dev.yml"
```
