am-cid / da-project-backend

Data Analytics Project (Backend)
GNU General Public License v3.0
0 stars 0 forks source link

API Propsal #1

Open chaaals opened 5 days ago

chaaals commented 5 days ago

Routes

GET /api/report (lists all reports) ### Parameters > | name | type | data type | description | > |-----------|-----------|-------------------------|-----------------------------------------------------------------------| > | id | required | string | Unique ID of report | ### Responses > | http code | content-type | response | > |---------------|-----------------------------------|---------------------------------------------------------------------| > | `201` | `text/plain;charset=UTF-8` | `Configuration created successfully` | > | `400` | `application/json` | `{"code":"400","message":"Bad Request"}` | ### Returns All Reports in JSON format ```json { "reports": [ { "id": "810beb92-641e-4212-a300-da69db05101d", "report_name": "Report 1" }, { "id": "810beb92-641e-4212-a300-da69db05101d", "report_name": "Report 1" }, ... ] } ```
GET /api/report/:id (views a report) ### Parameters > | name | type | data type | description | > |-----------|-----------|-------------------------|-----------------------------------------------------------------------| > | id | required | string | Unique ID of report | ### Responses > | http code | content-type | response | > |---------------|-----------------------------------|---------------------------------------------------------------------| > | `201` | `text/plain;charset=UTF-8` | `Configuration created successfully` | > | `400` | `application/json` | `{"code":"400","message":"Bad Request"}` | ### Returns Report Details ```json { "report": { "id": "810beb92-641e-4212-a300-da69db05101d", "report_name": "Report 1" "data": [ [ { "cell_id": "1xxxxxx", "value": "", "remarks": "" }, { "cell_id": "1xxxxxx", "value": "", "remarks": "" }, { "cell_id": "1xxxxxx", "value": "", "remarks": "" } ... rest of the cells ], [ { "cell_id": "2xxxxxx", "value": "", "remarks": "" }, { "cell_id": "2xxxxxx", "value": "", "remarks": "" }, { "cell_id": "2xxxxxx", "value": "", "remarks": "" } ... rest of the cells ] ] } } ```
PUT /api/report/:id (update a report) ### Parameters > | name | type | data type | description | > |-----------|-----------|-------------------------|-----------------------------------------------------------------------| > | id | required | string | Unique ID of report | ### Request Body > | name | type | data type | description | > |-----------|-----------|-------------------------|-----------------------------------------------------------------------| > | data | required | object (JSON) | Updated report data | ### Responses > | http code | content-type | response | > |---------------|-----------------------------------|---------------------------------------------------------------------| > | `201` | `text/plain;charset=UTF-8` | `Configuration created successfully` | > | `400` | `application/json` | `{"code":"400","message":"Bad Request"}` | ### Returns Success message and new report details ```json { "message": "Successfully updated report 810beb92-641e-4212-a300-da69db05101d", "report_details": "" } ```
DEL /api/report/:id (delete a reports) ### Parameters > | name | type | data type | description | > |-----------|-----------|-------------------------|-----------------------------------------------------------------------| > | id | required | string | Unique ID of report | ### Responses > | http code | content-type | response | > |---------------|-----------------------------------|---------------------------------------------------------------------| > | `201` | `text/plain;charset=UTF-8` | `Configuration created successfully` | > | `400` | `application/json` | `{"code":"400","message":"Bad Request"}` | ### Returns ```json { "message": "Successfully deleted report 810beb92-641e-4212-a300-da69db05101d", } ```
POST /api/make-report (generate a report) ### Request Body > | name | type | data type | description | > |-----------|-----------|-------------------------|-----------------------------------------------------------------------| > | data | required | object (JSON) | Uncleaned CSV data | ### Responses > | http code | content-type | response | > |---------------|-----------------------------------|---------------------------------------------------------------------| > | `201` | `text/plain;charset=UTF-8` | `Configuration created successfully` | > | `400` | `application/json` | `{"code":"400","message":"Bad Request"}` | ### Returns ```json { "report": { "id": "810beb92-641e-4212-a300-da69db05101d", "report_name": "Report 1" "data": [ [ { "cell_id": "1xxxxxx", "value": "", "remarks": "" }, { "cell_id": "1xxxxxx", "value": "", "remarks": "" }, { "cell_id": "1xxxxxx", "value": "", "remarks": "" } ... rest of the cells ], [ { "cell_id": "2xxxxxx", "value": "", "remarks": "" }, { "cell_id": "2xxxxxx", "value": "", "remarks": "" }, { "cell_id": "2xxxxxx", "value": "", "remarks": "" } ... rest of the cells ] ] } } ```
GET /api/download-report/:id (download a report) ### Parameters > | name | type | data type | description | > |-----------|-----------|-------------------------|-----------------------------------------------------------------------| > | id | required | string | Unique ID of report | ### Responses > | http code | content-type | response | > |---------------|-----------------------------------|---------------------------------------------------------------------| > | `201` | `text/plain;charset=UTF-8` | `Configuration created successfully` | > | `400` | `application/json` | `{"code":"400","message":"Bad Request"}` | ### Implementation Details Pre-requisites: HTML Template of report 1. User fetches this endpoint with a path. 2. Backend retrieves report information from DB 3. Details are inserted to HTML Template 4. Convert HTML to PDF 5. Return the file for download
am-cid commented 4 days ago

API Concerns:

  1. the FE libraries (which idk anything about) might have a different way of displaying data so I'd have to adjust the response/request body models to that (not just assume its a 2d array of cell data). So, I can't definitively say that the models above will be the final.
  2. I'd argue a PUT is not needed since report generation is our goal. I'd need an explanation as to why this was put. Same with DEL. Is this essential to FE functionality?
chaaals commented 4 days ago

API Concerns:

  1. the FE libraries (which idk anything about) might have a different way of displaying data so I'd have to adjust the response/request body models to that (not just assume its a 2d array of cell data). So, I can't definitively say that the models above will be the final.
  2. I'd argue a PUT is not needed since report generation is our goal. I'd need an explanation as to why this was put. Same with DEL. Is this essential to FE functionality?
  1. Hmm, good point. Let's think of a general structure nalang for it containing all important information from the csv processing. You can offload transforming of data for charts/visualization to FE.
  2. You're right, let's change that to GET & POST for remarks (comments)

New endpoints: GET /api/report/:id/comments POST /api/report/:id/comments

Let's add delete later nalang, researched if may delete feature on PowerBI, seems like for owner/admin lang siya.