# eerie-cson/pcp-project architecture

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

- Interactive diagram: https://gitdiagram.com/eerie-cson/pcp-project
- Repository: https://github.com/eerie-cson/pcp-project

## Overview

##### Main Components Identification
- API Backend (apps/api): This is the core of the application. Note the multiple domain modules (accounts, auth, builds, components) implemented as separate subdirectories. Within these, you see resolvers, modules, services, and libraries (for example, error handling and tokens).
- Frontend Web (apps/web): This component serves as the user interface. It’s built with modern frontend tech (React components, Tailwind CSS, etc.) and communicates with the backend via GraphQL queries and mutations.
- Testing Environments (apps/test and apps/web-e2e): Represented by dedicated directories for unit and end-to-end tests. They are linked to the API and web apps respectively.
- Shared Packages (packages/*): These include utilities like auth, object-id, repository, and types. They contain shared logic (such as middleware, decorators, and type definitions) that the API and other modules depend on.
- Development & Build Tools: Additional scripts (Nx configuration like nx.json, tsconfig files, Docker, Helm charts, etc.) that are used for building, testing, and deploying the system.

##### Relationships and Interactions
- Frontend (apps/web) makes GraphQL requests to the API backend.
- The API backend is organized into multiple domain modules. Each module (e.g., accounts, auth) adheres to a layered design – starting from request resolvers/controllers, passing data to services, and finally to repository operations that might interact with data storage (as indicated by repositories under features).
- The shared packages serve as common libraries leveraged across these modules––for instance, the auth package aids in authentication middleware, while the repository package abstracts data access.
- Testing applications invoke the API and frontend code, ensuring that system behaviors are validated from unit to end-to-end testing.

##### Architectural Patterns and Principles
- Modular Monolith: Although all components reside in a single repository, there is a clear modular separation (using feature-based directories) for maintainability.
- Shared Library / Package Pattern: The use of packages across auth, object-id, repository, and types shows a focus on code reuse and decoupling.
- DevOps and Deployment: The presence of Docker, Helm charts, and Nx’s built-in CI/CD task planning indicate that the deployment is containerized and orchestrated.

##### Detailed Elements
- Clear Labels: Mark each component (e.g., “Frontend (apps/web)”, “API Backend – Accounts Module”, “Shared Auth Package”).
- Additional Annotations: If needed, briefly annotate key technologies such as GraphQL, React, Node.js, Docker, and Nx.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Components
    FE("Frontend (apps/web)"):::frontend
    BE("API Backend (apps/api)"):::backend
    TEST_SUITE("Testing Suite"):::testing
    DEVOPS("DevOps & Build Tools"):::tools

    %% Testing Subcomponents
    APITEST("API Testing (apps/api/test)"):::testing
    E2ETEST("End-to-End Testing (apps/web-e2e)"):::testing

    %% Shared Packages
    SH_AUTH("Auth Package"):::sharedpkg
    SH_OBJID("Object-ID Package"):::sharedpkg
    SH_REPO("Repository Package"):::sharedpkg
    SH_TYPES("Types Package"):::sharedpkg

    %% API Domain Modules - Accounts Module
    ACC_MOD("Accounts Module"):::module
    ACC_RES("Accounts Resolver"):::module
    ACC_SRV("Accounts Service"):::module
    ACC_REP("Accounts Repository"):::module

    %% API Domain Modules - Auth Module
    AUTH_MOD("Auth Module"):::module
    AUTH_RES("Auth Resolver"):::module
    AUTH_SRV("Auth Service"):::module
    AUTH_REP("Auth Repository"):::module

    %% API Domain Modules - Builds Module
    BUILDS_MOD("Builds Module"):::module
    BUILDS_RES("Builds Resolver"):::module
    BUILDS_SRV("Builds Service"):::module
    BUILDS_REP("Builds Repository"):::module

    %% API Domain Modules - Components Module
    COMPS_MOD("Components Module"):::module
    COMPS_RES("Components Resolver"):::module
    COMPS_SRV("Components Service"):::module
    COMPS_REP("Components Repository"):::module

    %% Relationships Between Main Components
    FE -->|"GraphQL"| BE
    TEST_SUITE --> APITEST
    TEST_SUITE --> E2ETEST
    APITEST -->|"tests"| BE
    E2ETEST -->|"tests"| FE

    %% API Backend to Domain Modules
    BE --> ACC_MOD
    BE --> AUTH_MOD
    BE --> BUILDS_MOD
    BE --> COMPS_MOD

    %% Accounts Module Layered Architecture
    ACC_MOD --> ACC_RES
    ACC_RES --> ACC_SRV
    ACC_SRV --> ACC_REP
    ACC_REP -->|"uses"| SH_REPO
    ACC_SRV -->|"types"| SH_TYPES

    %% Auth Module Layered Architecture
    AUTH_MOD --> AUTH_RES
    AUTH_RES --> AUTH_SRV
    AUTH_SRV --> AUTH_REP
    AUTH_REP -->|"uses"| SH_REPO
    AUTH_SRV -->|"auth"| SH_AUTH
    AUTH_SRV -->|"types"| SH_TYPES

    %% Builds Module Layered Architecture
    BUILDS_MOD --> BUILDS_RES
    BUILDS_RES --> BUILDS_SRV
    BUILDS_SRV --> BUILDS_REP
    BUILDS_REP -->|"uses"| SH_REPO
    BUILDS_SRV -->|"types"| SH_TYPES

    %% Components Module Layered Architecture
    COMPS_MOD --> COMPS_RES
    COMPS_RES --> COMPS_SRV
    COMPS_SRV --> COMPS_REP
    COMPS_REP -->|"uses"| SH_REPO
    COMPS_SRV -->|"types"| SH_TYPES

    %% Styling: Group Shared Packages together visually by aligning them vertically (though not in a subgraph for click events)
    SH_AUTH --- SH_OBJID
    SH_OBJID --- SH_REPO
    SH_REPO --- SH_TYPES

    %% Click Events
    click FE "https://github.com/eerie-cson/pcp-project/tree/main/apps/web"
    click BE "https://github.com/eerie-cson/pcp-project/tree/main/apps/api"
    click APITEST "https://github.com/eerie-cson/pcp-project/tree/main/apps/api/test"
    click E2ETEST "https://github.com/eerie-cson/pcp-project/tree/main/apps/web-e2e"
    click ACC_MOD "https://github.com/eerie-cson/pcp-project/tree/main/apps/api/src/apps/accounts"
    click AUTH_MOD "https://github.com/eerie-cson/pcp-project/tree/main/apps/api/src/apps/auth"
    click SH_AUTH "https://github.com/eerie-cson/pcp-project/tree/main/packages/auth"
    click SH_OBJID "https://github.com/eerie-cson/pcp-project/tree/main/packages/object-id"
    click SH_REPO "https://github.com/eerie-cson/pcp-project/tree/main/packages/repository"
    click SH_TYPES "https://github.com/eerie-cson/pcp-project/tree/main/packages/types"

    %% Class Definitions
    classDef frontend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef backend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef module fill:#b8daff,stroke:#004085,stroke-width:2px;
    classDef testing fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef sharedpkg fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef tools fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
```
