# crepe-party/just_bi_api architecture

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

- Interactive diagram: https://gitdiagram.com/crepe-party/just_bi_api
- Repository: https://github.com/crepe-party/just_bi_api

## Overview

##### Project type and purpose
- just_BI_api is a lightweight Node.js backend API built to manage AWS S3 buckets/objects and perform AWS Rekognition face‐detection operations.
- There is no frontend; it exposes HTTP endpoints (via server.js) that wrap the AWS S3 and Rekognition APIs, driven by a set of abstract manager classes.

##### File structure
- Top-level files:
- server.js – entry point, HTTP server + route wiring
- package.json, jest.config.js – dependencies & test setup
- config.json.example – runtime configuration (AWS creds, region, bucket names)
- databaseModelRIA2.sql – (present but not wired into code)
- deployement_script/deploy.sh – automates git pull & pm2 deployment
- class/ directory:
- AbstractBucketManager.js, Bucket.js – encapsulate S3 bucket operations
- AbstractDetectingFacesManager.js, DetectingFaces.js – encapsulate Rekognition calls
- test/ directory:
- Bucket.test.js, DetectingFaces.test.js – TDD unit tests using Jest/Mocha

##### README for additional insights
- Describes installation, configuration, test commands, start/stop scripts.
- Mentions AWS CLI commands for bucket & face detection, implying the API mirrors these operations.
- Mentions deploy.sh requirements (node, npm, git, pm2).

- Blue for application components
- Green for AWS external services
- Orange for operational/deployment tools
- Gray for configuration/test artifacts

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Client["Client"]:::external

    %% Application Layer
    subgraph "Application Layer"
        Server["HTTP Server (server.js)"]:::app
        AbstractBucket["AbstractBucketManager"]:::app
        BucketMgr["Bucket Manager"]:::app
        AbstractDetectFaces["AbstractDetectingFacesManager"]:::app
        DetectFacesMgr["DetectingFaces Manager"]:::app
        Config["config.json"]:::config
        PackageJson["package.json"]:::config
    end

    %% AWS Services
    subgraph "AWS Services"
        S3["AWS S3"]:::external
        Rekognition["AWS Rekognition"]:::external
    end

    %% Deployment Pipeline
    subgraph "Deployment Pipeline"
        Git["Git Repository"]:::ops
        DeployScript["deploy.sh"]:::ops
        PM2["PM2 Process Manager"]:::ops
    end

    %% Testing Pipeline
    subgraph "Testing Pipeline"
        TestRunner["Test Runner (Jest)"]:::ops
        BucketTest["Bucket.test.js"]:::ops
        DetectFacesTest["DetectingFaces.test.js"]:::ops
        jestConfig["jest.config.js"]:::config
    end

    %% Interactions
    Client -->|"REST request"| Server
    Server -->|"invoke bucket operation"| BucketMgr
    Server -->|"invoke face-detection"| DetectFacesMgr
    BucketMgr -->|"implements"| AbstractBucket
    DetectFacesMgr -->|"implements"| AbstractDetectFaces
    Config -->|"load credentials & config"| Server
    PackageJson -->|"startup config & deps"| Server

    BucketMgr -->|"calls S3 API"| S3
    DetectFacesMgr -->|"calls Rekognition API"| Rekognition

    Git -->|"push code"| DeployScript
    DeployScript -->|"deploy via PM2"| PM2
    PM2 -->|"manages process"| Server

    TestRunner -->|"runs tests"| BucketTest
    TestRunner -->|"runs tests"| DetectFacesTest
    jestConfig -->|"test config"| TestRunner
    BucketTest -->|"tests logic of"| AbstractBucket
    DetectFacesTest -->|"tests logic of"| AbstractDetectFaces

    %% Click Events
    click Server "https://github.com/crepe-party/just_bi_api/blob/main/server.js"
    click AbstractBucket "https://github.com/crepe-party/just_bi_api/blob/main/class/AbstractBucketManager.js"
    click BucketMgr "https://github.com/crepe-party/just_bi_api/blob/main/class/Bucket.js"
    click AbstractDetectFaces "https://github.com/crepe-party/just_bi_api/blob/main/class/AbstractDetectingFacesManager.js"
    click DetectFacesMgr "https://github.com/crepe-party/just_bi_api/blob/main/class/DetectingFaces.js"
    click Config "https://github.com/crepe-party/just_bi_api/blob/main/config.json.example"
    click PackageJson "https://github.com/crepe-party/just_bi_api/blob/main/package.json"
    click DeployScript "https://github.com/crepe-party/just_bi_api/blob/main/deployement_script/deploy.sh"
    click BucketTest "https://github.com/crepe-party/just_bi_api/blob/main/test/Bucket.test.js"
    click DetectFacesTest "https://github.com/crepe-party/just_bi_api/blob/main/test/DetectingFaces.test.js"
    click jestConfig "https://github.com/crepe-party/just_bi_api/blob/main/jest.config.js"

    %% Styles
    classDef app fill:#b3d9ff,stroke:#0366d6,color:#000
    classDef external fill:#d2f8d2,stroke:#28a745,color:#000
    classDef ops fill:#ffe0b3,stroke:#cc7a00,color:#000
    classDef config fill:#e0e0e0,stroke:#6a6a6a,color:#000
```
