Skip to content

mfafore22/gorestfulapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Full Stack Book Management Application

A modern full-stack application built with React (TypeScript) and Go, demonstrating a simple book management system.

Project Structure

├── frontend/           # React TypeScript frontend
│   ├── src/
│   │   ├── App.tsx    # Main React component
│   │   └── ...
│   ├── index.html
│   └── vite.config.ts
└── go-backend/        # Go backend server
    ├── main.go       # Server implementation
    ├── go.mod
    └── go.sum

Features

Frontend

  • Built with React and TypeScript
  • Vite as build tool and dev server
  • Clean and responsive UI for book management
  • Error handling and loading states
  • Real-time book count display
  • Styled components for consistent UI

Backend

  • RESTful API built with Go
  • Uses Gorilla Mux for routing
  • Persistent storage using JSON file
  • CRUD operations for books
  • Search functionality with pagination
  • Data validation and error handling

API Endpoints

  • GET /books - List all books (supports search and pagination)
  • GET /books/{id} - Get a specific book
  • POST /books - Create a new book
  • PUT /books/{id} - Update a book (full replace)
  • PATCH /books/{id} - Partial update of a book
  • DELETE /books/{id} - Delete a book

Query Parameters for GET /books

  • q - Search term (optional)
  • page - Page number (default: 1)
  • page_size - Items per page (default: 10)

Book Data Structure

type Book = {
  id: string
  title: string
  content: string
}

Getting Started

Backend Setup

  1. Navigate to the backend directory:
    cd go-backend
  2. Run the Go server:
    go run main.go
    The server will start on port 8000.

Frontend Setup

  1. Navigate to the frontend directory:
    cd frontend
  2. Install dependencies:
    npm install
  3. Start the development server:
    npm run dev
    The frontend will be available at http://localhost:5173

Development Notes

  • The backend uses an in-memory store that persists to a books.json file
  • The frontend proxies API requests to the backend during development
  • TypeScript is used for type safety in the frontend
  • The application includes error handling and loading states
  • Backend includes search and pagination functionality

Technologies Used

Frontend

  • React
  • TypeScript
  • Vite
  • CSS Modules

Backend

  • Go
  • Gorilla Mux
  • Standard library JSON encoding/decoding

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors