Skip to content

Latest commit

 

History

History
116 lines (93 loc) · 4.69 KB

File metadata and controls

116 lines (93 loc) · 4.69 KB

REST API Platform

Overview

This is a comprehensive REST API platform built with a modern full-stack architecture. It provides a complete API documentation and testing interface with support for users, posts, and comments management. The application follows industry best practices with a clean separation between frontend and backend concerns.

System Architecture

Frontend Architecture

  • Framework: React 18 with TypeScript
  • Styling: Tailwind CSS with shadcn/ui component library
  • Routing: Wouter for client-side routing
  • State Management: TanStack Query (React Query) for server state management
  • Build Tool: Vite for fast development and optimized builds
  • UI Components: Comprehensive component library based on Radix UI primitives

Backend Architecture

  • Runtime: Node.js with Express.js framework
  • Language: TypeScript with ES modules
  • Database: PostgreSQL with Drizzle ORM
  • Database Provider: Neon serverless PostgreSQL
  • Validation: Zod schemas for input validation
  • Development: Hot reload with Vite middleware integration

Project Structure

  • client/ - React frontend application
  • server/ - Express.js backend API
  • shared/ - Shared types, schemas, and utilities
  • migrations/ - Database migration files

Key Components

Database Layer

  • ORM: Drizzle ORM with PostgreSQL dialect
  • Schema Location: shared/schema.ts
  • Tables:
    • Users (authentication and profiles)
    • Posts (blog-style content)
    • Comments (nested discussions)
  • Validation: Drizzle-Zod integration for type-safe schemas

API Layer

  • REST Endpoints: Full CRUD operations for all resources
  • Error Handling: Standardized error responses with detailed messages
  • Storage Interface: Abstracted storage layer supporting both in-memory and database implementations
  • Request Validation: Middleware-based validation using Zod schemas

Frontend Features

  • API Documentation: Interactive OpenAPI-style documentation
  • API Testing: Built-in testing interface for all endpoints
  • Postman Export: Generate Postman collections from API specs
  • Real-time Validation: Form validation with react-hook-form
  • Responsive Design: Mobile-first responsive interface

Data Flow

  1. Client Requests: Frontend makes HTTP requests using TanStack Query
  2. Express Middleware: Requests pass through validation and logging middleware
  3. Route Handlers: Business logic processes requests in route handlers
  4. Storage Layer: Data operations through abstracted storage interface
  5. Database Operations: Drizzle ORM handles database interactions
  6. Response Formatting: Standardized JSON responses with error handling

External Dependencies

Core Dependencies

  • @neondatabase/serverless: Serverless PostgreSQL connection
  • drizzle-orm: Type-safe database ORM
  • @tanstack/react-query: Server state management
  • @radix-ui/*: Accessible UI primitives
  • zod: Runtime type validation
  • react-hook-form: Form state management

Development Tools

  • tsx: TypeScript execution for development
  • esbuild: Fast JavaScript bundler for production
  • vite: Development server and build tool
  • tailwindcss: Utility-first CSS framework

Deployment Strategy

Development Environment

  • Command: npm run dev
  • Port: 5000
  • Hot Reload: Vite middleware integration
  • Database: Environment-based PostgreSQL connection

Production Build

  • Frontend Build: Vite builds static assets to dist/public
  • Backend Build: esbuild bundles server code to dist/index.js
  • Deployment Target: Autoscale deployment on Replit
  • Environment Variables: DATABASE_URL required for PostgreSQL connection

Database Management

  • Migrations: Drizzle Kit for schema migrations
  • Push Command: npm run db:push for development schema updates
  • Configuration: drizzle.config.ts defines database connection and migration settings

Changelog

Changelog:

  • June 28, 2025. Project cleanup and documentation
    • Created comprehensive README.md with installation and usage instructions
    • Removed unused api-documentation.tsx page file
    • Cleaned up project structure for better maintainability
  • June 28, 2025. Enhanced RESTful resource naming conventions
    • Added query parameter filtering for posts (authorId, published)
    • Added query parameter filtering for comments (postId, authorId)
    • Improved OpenAPI specification with detailed descriptions
    • Updated frontend documentation to reflect RESTful best practices
    • Maintained backward compatibility with existing nested routes
  • June 26, 2025. Initial setup

User Preferences

Preferred communication style: Simple, everyday language.