# salimsuprayogi/rest_api_testing_in_python architecture

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

- Interactive diagram: https://gitdiagram.com/salimsuprayogi/rest_api_testing_in_python
- Repository: https://github.com/salimsuprayogi/rest_api_testing_in_python

## Overview

##### Project type and purpose
- This is an open-source REST API testing utility written in Python.
- Its sole purpose is to execute HTTP requests (GET, POST, DELETE), read input JSON, parse responses, validate them, and print results.

##### File structure
- Top-level files:
– LICENSE, README.md – documentation and licensing.
– venv/ – isolated Python environment with dependencies (requests, json, jsonpath).
– get_request/ – contains all test scripts and test data.
- Inside get_request/:
– 1_get_request.py, 2_get_fetch_value.py, 3_delete_user.py, 4_post_create_user.py – each script exercises one API scenario.
– data_create_user.json – payload used by the POST script.

##### README for additional insights
- Dependencies: Python 3.8.5, requests, json, jsonpath.
- Described capabilities: get, delete, post, response parsing, validation.
- External test target: likely https://reqres.in/ or any REST endpoint.

a. Main components
1. Virtual Environment (venv)
2. Test Runner Scripts (get_request/*.py)
3. Input Data Store (data_create_user.json)
4. HTTP Client Library (requests module)
5. JSON Processing (built-in json + jsonpath)
6. External REST API Service (e.g. reqres.in)
7. Console/Logger (for output & validation results)
b. Relationships and data flow
– The “Test Runner Scripts” component reads “Input Data Store” when sending POST.
– Scripts invoke “HTTP Client Library” to send requests to “External REST API.”
– Responses flow back into “JSON Processing” for parsing/validation.
– Parsed results and validation outcomes are sent to “Console/Logger.”
c. Architectural patterns / principles
– Single-process, procedural test harness rather than multi-layer web app.
– Separation of concerns: each script handles one HTTP method; JSON input is decoupled.
– Reuse of standard libraries (requests, jsonpath) rather than custom networking or parsing code.
d. Key technologies / libraries
– Python 3.8.5
– requests (HTTP client)
– built-in json module
– jsonpath (for extracting values)
– Virtual environment for dependency isolation

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Environment
    VENV["Virtual Environment<br/>(venv)"]:::env

    %% Scripts
    subgraph "Test Runner Scripts" 
        direction TB
        GET1["1_get_request.py"]:::code
        GET2["2_get_fetch_value.py"]:::code
        DEL3["3_delete_user.py"]:::code
        POST4["4_post_create_user.py"]:::code
    end

    %% Data Store
    DataStore["data_create_user.json"]:::data

    %% Libraries
    subgraph "Libraries" 
        direction TB
        RequestsLib["requests module"]:::lib
        JSONLib["built-in json module"]:::lib
        JSONPathLib["jsonpath module"]:::lib
    end

    %% External Service
    ExternalAPI["External REST API<br/>(e.g. reqres.in)"]:::external

    %% Console Output
    Console["Console / Logger<br/>(print output)"]:::output

    %% Connections
    VENV -->|provides runtime| GET1
    VENV -->|provides runtime| GET2
    VENV -->|provides runtime| DEL3
    VENV -->|provides runtime| POST4

    POST4 -->|reads payload| DataStore

    GET1 -->|uses HTTP client| RequestsLib
    GET2 -->|uses HTTP client| RequestsLib
    DEL3 -->|uses HTTP client| RequestsLib
    POST4 -->|uses HTTP client| RequestsLib

    RequestsLib -->|sends HTTP request| ExternalAPI
    ExternalAPI -->|returns JSON response| JSONLib
    ExternalAPI -->|returns JSON response| JSONPathLib

    JSONLib -->|parses response| Console
    JSONPathLib -->|extracts values| Console

    GET1 -->|logs results| Console
    GET2 -->|logs results| Console
    DEL3 -->|logs results| Console
    POST4 -->|logs results| Console

    %% Click Events
    click VENV "https://github.com/salimsuprayogi/rest_api_testing_in_python/tree/master/venv/"
    click GET1 "https://github.com/salimsuprayogi/rest_api_testing_in_python/blob/master/get_request/1_get_request.py"
    click GET2 "https://github.com/salimsuprayogi/rest_api_testing_in_python/blob/master/get_request/2_get_fetch_value.py"
    click DEL3 "https://github.com/salimsuprayogi/rest_api_testing_in_python/blob/master/get_request/3_delete_user.py"
    click POST4 "https://github.com/salimsuprayogi/rest_api_testing_in_python/blob/master/get_request/4_post_create_user.py"
    click DataStore "https://github.com/salimsuprayogi/rest_api_testing_in_python/blob/master/get_request/data_create_user.json"
    click RequestsLib "https://github.com/salimsuprayogi/rest_api_testing_in_python/tree/master/venv/lib/python3.8/site-packages/requests/"
    click JSONLib "https://github.com/salimsuprayogi/rest_api_testing_in_python/tree/master/venv/lib/python3.8/json/"
    click JSONPathLib "https://github.com/salimsuprayogi/rest_api_testing_in_python/tree/master/venv/lib/python3.8/site-packages/jsonpath/"

    %% Styles
    classDef env fill:#d4f1be,stroke:#4caf50,color:#000;
    classDef code fill:#bbdefb,stroke:#2196f3,color:#000;
    classDef lib fill:#fff9c4,stroke:#fbc02d,color:#000;
    classDef data fill:#ffecb3,stroke:#ffa000,color:#000;
    classDef external fill:#ffcdd2,stroke:#e53935,color:#000;
    classDef output fill:#f8bbd0,stroke:#d81b60,color:#000;
```
