Skip to content

Instantly share code, notes, and snippets.

@shri-kanth
Created January 29, 2025 05:16
Show Gist options
  • Save shri-kanth/391d7a6befd3846bbcbb88a34a2a583d to your computer and use it in GitHub Desktop.
Save shri-kanth/391d7a6befd3846bbcbb88a34a2a583d to your computer and use it in GitHub Desktop.
Task 3

Task Description:

Create an application that allows users to manage a digital library of books. Users will be able to register, log in, manage their book collections, categorize them, track reading progress, and view reading activity reports. The application will include a RESTful API, a database schema, and a user interface.

Frontend Requirements:

  1. Set up a React project using TypeScript.
  2. Implement user authentication:
    • Develop registration and login pages where users can authenticate using an email and password.
    • Use JWT tokens to manage and secure endpoints.
  3. Develop a user interface with the following functionalities for authenticated users:
    • Manage a personal library of books with details such as:
      • Book ID: Unique identifier for each book.
      • Title: The title of the book.
      • Author: The author of the book.
      • Category: Genre or category of the book (e.g., Fiction, Non-Fiction, Mystery).
      • Status: Reading status (e.g., Not Started, In Progress, Completed).
      • Rating: An optional value between 1 to 5.
    • Add book details, as per the above.
    • Update book details, including status and rating.
    • Delete books from the library.
    • Search for books by title, author or rating.
    • Sort books by title, author, category, rating or reading status.
  4. Develop a report view to display reading activity, such as:
    • Total books read during a time period.
    • Most frequently read category during a time period.
    • Total time spent reading during a time period.
    • Support the following time periods
      • 1w (1 week)
      • 1m (1 month)
      • 1y (1 year)
  5. Implement error handling and validation for all input fields and authentication processes.

Backend Requirements:

  1. Set up a Node.js project with Express.js and TypeScript.
  2. Implement authentication using JWT to secure the endpoints:
    • POST /auth/register: Register new users with email and hashed password.
    • POST /auth/login: Authenticate users and return an access token.
    • Middleware to protect routes and verify user tokens.
  3. Implement the following RESTful API endpoints for authenticated users:
    • GET /books: Retrieve a list of books in the user's library, optionally filtered by search query.
    • POST /books: Add a new book to the user's library.
    • PUT /books/:id: Update details of an existing book.
    • DELETE /books/:id: Remove a book from the library.
    • GET /reports/activity: Generate a report summarizing the user's reading activity.
  4. Use MySQL with TypeORM to create database schemas for storing user and book information.
  5. Implement validations to ensure data integrity, particularly for book details, reading status updates, and user authentication.

Database Requirements:

  1. Set up a MySQL database and configure a connection using TypeORM.
  2. Create tables for Users and Books with appropriate columns and data types:
    • Users table should store user credentials securely.
    • Books table should store book details, including reading status and associated user IDs.
    • Feel free to create more tables that meet the requirements

Acceptance Criteria:

  1. The React application securely handles user registration and authentication effectively.
  2. Library management functions are available only to authenticated users, involving adding, updating, and deleting books.
  3. Reports accurately reflect reading activity, including total books read, categories, and reading time.
  4. Proper database setup includes Users and Books tables with accurate, retrievable, and consistent data.
  5. The frontend is responsive and user-friendly, supporting all specified operations efficiently.
  6. Code should be well-organized, readable, and conform to best practices in TypeScript and security standards.

Expectations:

  • Emphasis will be placed on secure authentication, efficient book and category management, and accurate data reporting.
  • If there are any gaps or assumptions needed within the task, developers are encouraged to make reasonable assumptions and document these assumptions clearly in their code or accompanying documentation.
  • The developer should be able to explain their design and implementation decisions if asked.

Developers are encouraged to reach out for any clarifications during the task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment