Skip to content

KatBen-Make/api-docs-to-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

29 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

API Doc to JSON (Gemini AI)

This project is a React + Express + Vite application that lets users paste API documentation and receive structured JSON, powered by Google's Gemini API.


πŸ“¦ Tech Stack


πŸš€ Getting Started

1. Clone the repository

git clone https://github.com/KatBen-Make/api-docs-to-json.git
cd api-docs-to-json

2. Install dependencies

npm install

This installs dependencies for both client and server via root-level package.json.

3. Setup environment variables

Create a .env file in the project root:

# Server Configuration
SESSION_SECRET=your-very-secure-random-string-change-this-in-production
NODE_ENV=development
PORT=8080

# Frontend URL (for CORS in production)
FRONTEND_URL=https://your-frontend-domain.com

# API Keys
API_KEY=your_google_gemini_api_key_here
GEMINI_MODULE=gemini-2.5-flash

πŸ” Security Note: Never commit .env files with secrets to version control. Use strong, random values for SESSION_SECRET in production.

4. Run the app in development

npm run dev

5. Authentication

  • Users must authenticate with a Make.com email and API token
  • Only @make.com email addresses are allowed
  • Sessions are managed securely with HTTP-only cookies
  • Automatic session expiration after 24 hours

6. Docker Deployment

To build and run the application using Docker:

docker build -t api-docs-to-json .
docker run -p 8080:8080 -it api-docs-to-json

The application will be available at http://localhost:8080.

✨ Features

  • πŸ” Secure Authentication: Session-based auth with Make.com email validation
  • πŸ“ API Documentation Processing: Paste unstructured API docs and get structured JSON
  • πŸ€– AI-Powered: Submit prompts to Gemini AI for intelligent processing
  • πŸ’¬ Conversation History: Add comments and maintain context across requests
  • πŸ“‹ Copy-to-Clipboard: Quick export functionality with MUI icons
  • πŸ”„ Loading States: Comprehensive loading spinners and visual feedback
  • πŸ›‘οΈ Security Features:
    • HTTP-only cookies prevent XSS attacks
    • CSRF protection with SameSite cookies
    • Secure session management
    • Input validation and sanitization
  • πŸ“± Responsive Design: Works on desktop and mobile devices
  • 🚫 Input Protection: Prevents modification during API processing

πŸ“ Folder Structure

api-docs-to-json/
β”œβ”€β”€ .env.example                  # Environment variables template
β”œβ”€β”€ .gitignore
β”œβ”€β”€ Dockerfile                    # Docker configuration
β”œβ”€β”€ package.json                  # Root package.json (concurrent setup)
β”œβ”€β”€ package-lock.json
β”œβ”€β”€ README.md                     # This file
β”œβ”€β”€ SECURITY.md                   # Security documentation
β”œβ”€β”€
β”œβ”€β”€ client/                       # React frontend (Vite)
β”‚   β”œβ”€β”€ .dockerignore
β”‚   β”œβ”€β”€ .gitignore
β”‚   β”œβ”€β”€ eslint.config.js
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ package-lock.json
β”‚   β”œβ”€β”€ README.md
β”‚   β”œβ”€β”€ vite.config.js
β”‚   └── src/
β”‚       β”œβ”€β”€ App.css               # Main application styles
β”‚       β”œβ”€β”€ App.jsx               # Main application component
β”‚       β”œβ”€β”€ index.css
β”‚       β”œβ”€β”€ main.jsx
β”‚       β”œβ”€β”€ components/           # Reusable UI components
β”‚       β”‚   └── auth/
β”‚       β”‚       β”œβ”€β”€ AuthModal.jsx      # Login modal component
β”‚       β”‚       β”œβ”€β”€ AuthModal.css      # Login modal styles
β”‚       β”‚       β”œβ”€β”€ UserDropdown.jsx   # User menu component
β”‚       β”‚       └── UserDropdown.css   # User menu styles
β”‚       β”œβ”€β”€ contexts/             # React context providers
β”‚       β”‚   β”œβ”€β”€ ApiContext.jsx          # API state context
β”‚       β”‚   β”œβ”€β”€ ApiProvider.jsx         # API state provider
β”‚       β”‚   β”œβ”€β”€ AuthContext.jsx         # Authentication context
β”‚       β”‚   └── AuthProvider.jsx        # Authentication provider
β”‚       β”œβ”€β”€ hooks/                # Custom React hooks
β”‚       β”‚   β”œβ”€β”€ useApi.js              # API interaction hook
β”‚       β”‚   └── useAuth.js             # Authentication hook
β”‚       └── services/             # API service functions
β”‚           └── authService.js          # Authentication API calls
β”‚
└── server/                       # Express backend
    β”œβ”€β”€ .dockerignore
    β”œβ”€β”€ index.js                  # Main server file
    β”œβ”€β”€ package.json
    β”œβ”€β”€ package-lock.json
    β”œβ”€β”€ data/                     # Markdown prompt templates
    β”‚   β”œβ”€β”€ examples.md                # Example prompts for AI
    β”‚   β”œβ”€β”€ generalPrompt.md           # Base AI instructions
    β”‚   └── internalDocs.md            # Internal documentation
    └── src/
        └── routes/               # API route handlers
            └── auth.js                # Authentication routes

πŸ” Security Features

This application implements enterprise-grade security practices:

  • Session-Based Authentication: No sensitive data stored in localStorage
  • HTTP-Only Cookies: Prevents XSS attacks by making sessions inaccessible to JavaScript
  • CSRF Protection: SameSite cookie policy prevents cross-site request forgery
  • Secure Transport: HTTPS-only cookies in production
  • Make.com Domain Restriction: Only @make.com email addresses allowed
  • Session Expiration: Automatic 24-hour timeout
  • Input Validation: Server-side validation of all inputs

See SECURITY.md for detailed security documentation.


πŸ”„ API Endpoints

Authentication

  • POST /api/auth/login - Authenticate with Make.com token
  • POST /api/auth/logout - Destroy session
  • GET /api/auth/me - Check authentication status

Application

  • POST /api/data - Process API documentation (requires authentication)

πŸ› οΈ Development

Key Files to Edit

  • client/src/App.jsx - Main application component
  • client/src/App.css - Application styling
  • server/index.js - Server configuration and main API endpoint
  • server/src/routes/auth.js - Authentication logic
  • server/data/generalPrompt.md - AI instructions
  • server/data/examples.md - Example prompts for AI
  • server/data/internalDocs.md - Internal documentation context

Dependencies

Client

  • React, Vite, Material-UI
  • Custom hooks and context providers
  • Hot toast notifications

Server

  • Express, cookie-session, axios
  • CORS, dotenv, node-fetch

To Do

  • add option to add successful query to examples

About

Gemini AI to read API docs and convert to MAKE json

Resources

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors