Skip to content

cirostackdev/RESTAPI

Repository files navigation

REST API Platform

Live on: https://restapi-wyej.onrender.com/

A comprehensive REST API platform built with modern full-stack architecture, featuring interactive documentation, API testing capabilities, and Postman collection export functionality.

Platform Preview TypeScript React Node.js

Overview

This platform provides a complete API management solution with support for users, posts, and comments. It follows RESTful conventions and includes comprehensive documentation, interactive testing, and export capabilities for popular API testing tools.

Features

🚀 Core Functionality

  • RESTful API Design - Clean, intuitive endpoints following industry standards
  • Interactive Documentation - Built-in API explorer with real-time testing
  • Postman Integration - One-click export of complete API collections
  • Real-time Validation - Input validation with detailed error handling
  • Responsive Design - Works seamlessly across all devices

📊 Resource Management

  • Users - Complete user management with profiles and authentication data
  • Posts - Blog-style content management with authorship tracking
  • Comments - Nested discussion system with post associations
  • Query Filtering - Advanced filtering options for all resources

🛠 Developer Tools

  • TypeScript Support - Full type safety across frontend and backend
  • Hot Reload - Fast development with instant updates
  • Error Handling - Comprehensive error responses with debugging info
  • API Testing - Built-in testing interface for all endpoints

Quick Start

Prerequisites

  • Node.js 18+
  • PostgreSQL (for production) or use included in-memory storage

Installation

  1. Clone and Install

    git clone <repository-url>
    cd rest-api-platform
    npm install
  2. Environment Setup

    # For PostgreSQL (optional)
    export DATABASE_URL="postgresql://username:password@localhost:5432/dbname"
  3. Start Development Server

    npm run dev
  4. Access the Platform

API Documentation

Base URL

http://localhost:5000/api/v1

Authentication

Currently uses session-based authentication. API keys and OAuth support planned for future releases.

Available Endpoints

Users

  • GET /users - List all users with pagination
  • GET /users/:id - Get specific user details
  • POST /users - Create new user
  • PUT /users/:id - Update user information
  • DELETE /users/:id - Remove user

Posts

  • GET /posts - List all posts with filtering options
  • GET /posts/:id - Get specific post details
  • POST /posts - Create new post
  • PUT /posts/:id - Update post content
  • DELETE /posts/:id - Remove post
  • GET /posts?authorId=:userId - Filter posts by author

Comments

  • GET /comments - List all comments with pagination
  • GET /comments/:id - Get specific comment details
  • POST /comments - Create new comment
  • PUT /comments/:id - Update comment content
  • DELETE /comments/:id - Remove comment
  • GET /comments?postId=:postId - Filter comments by post

Query Parameters

All list endpoints support:

  • page - Page number (default: 1)
  • limit - Items per page (default: 10)
  • sort - Sort field and direction (e.g., createdAt:desc)

Project Structure

├── client/                 # React frontend application
│   ├── src/
│   │   ├── components/     # Reusable UI components
│   │   ├── pages/          # Page components
│   │   ├── lib/            # Utilities and configurations
│   │   └── hooks/          # Custom React hooks
├── server/                 # Express.js backend API
│   ├── index.ts           # Server entry point
│   ├── routes.ts          # API route definitions
│   ├── storage.ts         # Data storage interface
│   └── vite.ts            # Development server setup
├── shared/                 # Shared types and schemas
│   └── schema.ts          # Database schema and validations
└── migrations/            # Database migration files

Technology Stack

Frontend

  • React 18 - Modern UI library with hooks
  • TypeScript - Type-safe development
  • Tailwind CSS - Utility-first styling framework
  • shadcn/ui - High-quality component library
  • TanStack Query - Server state management
  • Wouter - Lightweight client-side routing

Backend

  • Node.js - JavaScript runtime
  • Express.js - Web application framework
  • TypeScript - Type-safe server development
  • Drizzle ORM - Type-safe database operations
  • Zod - Runtime type validation
  • PostgreSQL - Production database (optional)

Development Tools

  • Vite - Fast build tool and dev server
  • esbuild - JavaScript bundler for production
  • tsx - TypeScript execution for development

API Testing

Using the Built-in Tester

  1. Navigate to the main documentation page
  2. Select an endpoint from the sidebar
  3. Choose HTTP method and configure parameters
  4. Click "Test API" to execute requests
  5. View real-time responses and status codes

Postman Integration

  1. Click "Export Postman" button in the header
  2. Import the downloaded collection into Postman
  3. Set base URL variable to your server address
  4. Start testing all endpoints immediately

Example Requests

Create a User:

POST /api/v1/users
{
  "name": "John Doe",
  "email": "john@example.com",
  "password": "securepassword"
}

Create a Post:

POST /api/v1/posts
{
  "title": "Sample Post",
  "content": "This is sample content.",
  "authorId": 1,
  "published": true
}

Filter Posts by Author:

GET /api/v1/posts?authorId=1&published=true

Database Configuration

Using In-Memory Storage (Default)

No setup required. Data resets on server restart.

Using PostgreSQL (Production)

  1. Install PostgreSQL
  2. Create database
  3. Set DATABASE_URL environment variable
  4. Run migrations: npm run db:push

Schema Migration

# Push schema changes to database
npm run db:push

# Generate migration files
npm run db:generate

# Apply migrations
npm run db:migrate

Development Workflow

Running in Development

npm run dev
  • Backend runs on port 5000
  • Frontend served via Vite middleware
  • Hot reload enabled for both frontend and backend

Building for Production

npm run build
  • Frontend builds to dist/public
  • Backend builds to dist/index.js
  • Ready for deployment

Code Quality

# Type checking
npm run type-check

# Linting (if configured)
npm run lint

Error Handling

The API provides consistent error responses:

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid input data",
    "details": {
      "field": "email",
      "issue": "Invalid email format"
    },
    "resource": "users",
    "request_id": "req_123456789"
  },
  "timestamp": "2025-06-28T16:30:00.000Z"
}

Common error codes:

  • VALIDATION_ERROR - Input validation failed
  • RESOURCE_NOT_FOUND - Requested resource doesn't exist
  • DUPLICATE_RESOURCE - Resource already exists
  • INTERNAL_ERROR - Server error occurred

Contributing

Getting Started

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

Code Style

  • Use TypeScript for type safety
  • Follow existing naming conventions
  • Add JSDoc comments for public APIs
  • Ensure responsive design for UI changes

Testing

  • Test all API endpoints using the built-in tester
  • Verify Postman collection exports work correctly
  • Check responsive design on multiple screen sizes

Deployment

Replit Deployment (Recommended)

  1. Connect repository to Replit
  2. Set environment variables if using PostgreSQL
  3. Click Deploy button
  4. Application automatically scales and manages hosting

Manual Deployment

  1. Build the application: npm run build
  2. Set production environment variables
  3. Start with: node dist/index.js
  4. Ensure PostgreSQL connection for production data

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For questions, issues, or feature requests:

  1. Check the interactive documentation at the root URL
  2. Use the built-in API tester for debugging
  3. Export Postman collections for external testing
  4. Review error responses for debugging information

Built with ❤️ using modern web technologies

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages