Skip to content

Secure gadget management API for IMF, built with TypeScript, Node.js, Express.js PostgreSQL, and Redis. Features JWT authentication, CRUD operations, caching, self-destruct functionality, and gadget tracking πŸš€

Notifications You must be signed in to change notification settings

Rushhaabhhh/IMF-Gadget-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

IMF Gadget API Documentation

πŸ“– Overview

The IMF Gadget API is a sophisticated, secure system designed for managing high-tech gadgets used by the Impossible Missions Force. This comprehensive API provides robust functionality for tracking, maintaining, and controlling mission-critical equipment with enterprise-grade security features.


Links

https://www.loom.com/share/fef202af89364bd1a0873eabe559829d


🚨 Important Authentication Note

  • Bearer tokens are REQUIRED for ALL API endpoints EXCEPT GET All Gadgets route to retrieve gadgets so always include the bearer token in your request headers.
  • To obtain a bearer token, send a POST gadget request to the authentication endpoint.
  • Bearer Token Generation : The token will be generated and must be included in the Authorization header for subsequent requests.
  • Watch the authentication video tutorial for detailed guidance and refer to the Postman collection for example request configurations

πŸš€ Key Features

Gadget Management

  • Complete inventory tracking with dynamic mission success probability
  • Unique codename generation for each gadget
  • Comprehensive status tracking (Available, Deployed, Decommissioned)
  • Detailed gadget information management

Security Features

  • JWT-based authentication
  • Secure self-destruct sequence with confirmation protocols
  • Soft deletion mechanism to preserve historical records

πŸ’» Technical Architecture

Technology Stack

  • Backend: Node.js with Express.js (TypeScript)
  • Database: PostgreSQL
  • ORM: Sequelize
  • Authentication: JSON Web Tokens (JWT)
  • Caching: Redis
  • Deployment: Render
  • Containerization: Docker

Project Structure

IMF-Gadget-API/
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ libs/
β”‚   β”‚   β”œβ”€β”€ database.ts       # Postgres database configuration
β”‚   β”‚   β”œβ”€β”€ helper.ts         # Utility functions
β”‚   β”‚   β”œβ”€β”€ middleware.ts     # Authentication middleware
β”‚   β”‚   └── redis.ts          # Redis cache client
β”‚   β”‚
β”‚   β”œβ”€β”€ gadgetController.ts   # Business logic
β”‚   β”œβ”€β”€ gadgetModels.ts       # Data models
β”‚   β”œβ”€β”€ gadgetRoutes.ts       # API route definitions
β”‚   └── index.ts              # Application entry point
β”‚
β”œβ”€β”€ Dockerfile                # Docker configuration
└── docker-compose.yml        # Multi-container orchestration

🌐 API Endpoints

  1. Get All Gadgets
  • Endpoint : GET /gadgets
  • Description : Retrieves all gadgets with randomly generated mission success probability
  • Response Example:
    [
        {
        "id": "fd5bad1d-ac65-4c57-9ade-6e6b3521de86",
        "name": "Superhero",
        "codename": "Operation Kraken",
        "status": "Available",
        "missionSuccessProbability": 87,
        "decommissionedAt": null,
        "createdAt": "2025-01-26T12:46:57.570Z",
        "updatedAt": "2025-01-26T12:46:57.570Z"
        },
    ]
  1. Filter Gadgets by Status

    • Endpoint : GET /gadgets?status=Available
    • Description : Retrieves gadgets filtered by specific status
    • Supported Statuses : Available, Deployed, Decommissioned
  2. Get Gadget by ID

    • Endpoint : GET /gadgets/:id
    • Description : Retrieves a single gadget by its unique identifier
  3. Create Gadget

    • Endpoint : POST /gadgets
    • Description: Adds a new gadget to inventory
    • Request Payload:
      {
      "name": "Advanced Tracking Device"
      }
    • Features :
      • Automatically generates unique codename
      • Assigns default "Available" status
      • Generates random mission success probability
  4. Update Gadget

    • Endpoint : PATCH /gadgets/:id
    • Description : Modify existing gadget information
    • Request Payload :
      {
      "name": "Enhanced Tracking Device",
      "status": "Deployed"
      }
  5. Decommission Gadget

    • Endpoint : DELETE /gadgets/:id
    • Description : Marks gadget as "Decommissioned"
    • Action :
      • Sets status to Decommissioned
      • Records decommission timestamp
      • Prevents permanent data deletion
  6. Self-Destruct Sequence

    • Endpoint : POST /gadgets/:id/self-destruct

    • Description : Initiates gadget self-destruction protocol

    • Response Example :

      {
      "message": "Self-destruct sequence initiated.",
      "confirmationCode": "ABCD1234"
      }

πŸ”§ Local Development Setup

Prerequisites

  • Node.js (v14+)
  • PostgreSQL
  • Redis
  • Docker & Docker Compose

Installation Steps

  1. Clone the repository :
git clone https://github.com/Rushhaabhhh/IMF-Gadget-API.git
cd IMF-Gadget-API
  1. Create the Environment File : Copy the contents of the .env.example file in .env for Environment Configuration
cp en.example .env
  1. Start containers
docker-compose up 

About

Secure gadget management API for IMF, built with TypeScript, Node.js, Express.js PostgreSQL, and Redis. Features JWT authentication, CRUD operations, caching, self-destruct functionality, and gadget tracking πŸš€

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published