Skip to content

API Documentation

Tang ZhaoSheng edited this page Nov 8, 2024 · 7 revisions

Pioneer API Documentation

Table of Contents

  1. Overview
  2. System Architecture
  3. Authentication
  4. Python Backend API (Port 5106)
  5. Node.js Backend API (Port 5105)
  6. Data Models
  7. Error Handling

Overview

The Pioneer system provides ESG (Environmental, Social, and Governance) analysis and scoring capabilities through two backend servers:

Server Port Primary Functions
Python Backend (FastAPI) 5106 Report processing, ESG calculations
Node.js Backend (Express) 5105 Authentication, Data retrieval

System Architecture

graph TD
    Client[Frontend Client]
    PY[Python Backend :5106]
    NODE[Node.js Backend :5105]
    DB[(MySQL Database)]
    FB[Firebase Auth]
    S3[AWS S3 Storage]

    Client --> PY
    Client --> NODE
    PY --> DB
    NODE --> DB
    NODE --> FB
    PY --> S3
Loading

Python Backend API

Report Processing

Process Report

POST /reports/fetch/{file_name}

Extract Report Text

POST /reports/extract/text/{report_name}

Update Report Data

POST /reports/extract/update/data/{report_name}

ESG Calculations

Calculate ESG Scores

POST /calculate-esg

Generate Predictions

POST /predict

Analysis

Get Company Analysis

GET /dashboard/analysis/{company_id}

Storage Management

Storage Status

GET /storage-status

Manual Cleanup

POST /cleanup

Force Cleanup

POST /cleanup/force

Node.js Backend API

Authentication Endpoints

Login

POST /api/login

Logout

POST /api/logout

Data Retrieval

Company Information

GET /api/table/company

Social Data

GET /api/table/social

Environmental Score

GET /api/score/environment

Governance Data

GET /api/table/governance

ESG Dashboard Data

GET /api/dashboard/esg

ESG Predictions

GET /api/score/predict

File Management

List Storage Files

GET /api/s3/storage/files

Upload Report

POST /api/firebase/upload

Data Models

Company Object

interface Company {
    CompanyID: number;
    CompanyName: string;
    Industry: string;
    Country: string;
}

ESG Score Object

interface ESGScore {
    CompanyName: string;
    CompanyID: number;
    ReportYear: number;
    Environmental_Score: number;
    Social_Score: number;
    Governance_Score: number;
    Final_ESG_score: number;
}

ESG Prediction Object

interface ESGPrediction {
    CompanyName: string;
    CompanyID: number;
    Year: number;
    Environmental_Score: number;
    Social_Score: number;
    Governance_Score: number;
    ESG_score: number;
    Data_Type: string;
}

Error Handling

HTTP Status Codes

Code Description Example
200 Success Request completed successfully
400 Bad Request Invalid parameters
401 Unauthorized Invalid or missing token
404 Not Found Resource doesn't exist
500 Server Error Internal processing error

Error Response Format

{
    "status": "error",
    "code": "number",
    "detail": "string",
    "timestamp": "string"
}