Skip to content

deliagorgan/REST-Library-CLI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REST-Library-CLI | C HTTP Network Client

A command-line interface (CLI) written in C designed to interact with a RESTful web server. This project implements the HTTP protocol using Socket API, managing authentication, session persistence, and complex data orchestration.

Overview

This application serves as a bridge between a terminal interface and a virtual library server. It handles everything from low-level network communication (TCP sockets) to high-level application logic like JWT authorization and JSON data parsing.

Note on Server Availability: This client was developed to interact with a specific REST API server. As the hosting for that server is no longer active, the application currently serves as a code-base showcase for network programming, manual HTTP packet construction, and security flow implementation.

Technical Architecture

  • Low-Level Networking: Built using the standard Linux Sockets API (sys/socket.h).
  • Manual HTTP Implementation: Requests (GET, POST, PUT, DELETE) are constructed manually, including headers for Cookies, Content-Type, and Authorization.
  • Session Management: Implements a dual-state security model using Session Cookies for initial authentication and JWT (JSON Web Tokens) for restricted library access.

Key Features & Functionalities

Advanced Authentication Flow

  • Admin & User Roles: Separate access levels for library management and regular content consumption.
  • State Persistence: The client tracks session cookies and JWT tokens, automatically attaching them to the required HTTP headers for subsequent requests.

Virtual Library Management (CRUD)

  • Content Control: Full ability to add, view, update, and delete movies.
  • Collection Orchestration: The add_collection command implements a complex multi-step logic, sending sequential API calls to register a title and link multiple movie IDs in a single user action.

Robust Error Handling

  • Translates raw HTTP status codes (400, 401, 403, 404, 500) into meaningful, user-friendly error messages.
  • Client-side validation for numeric inputs (ratings, release years) to ensure data integrity before sending requests.

Available Commands

Category Commands
Identity login, login_admin, logout, logout_admin, add_user, exit
Access get_access (Requests the JWT for library operations)
Movies get_movies, get_movie, add_movie, delete_movie, update_movie
Collections get_collections, add_collection, delete_collection, add_movie_to_collection

Installation & Setup

Prerequisites

  • GCC Compiler
  • Linux/Unix environment (or WSL for Windows)

Build

To compile the project using the provided Makefile:

make build

Run

./client

About

C/C++ CLI client that interacts with a REST API library. Implements the HTTP protocol using sockets, featuring session management with Cookies and JWT, and JSON data parsing.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors