MangaDB Tutorial

Getting Started

Getting Started with MangaDB

This section will guide you through installing MangaDB, setting up your environment, and running your first MangaDB application.

Prerequisites

Before you begin, make sure you have the following installed:

  • Python 3.7 or higher
  • pip (Python package installer)
  • Git (optional, for cloning the repository)

Installation

Follow these steps to install MangaDB:

1. Clone or download the repository

git clone https://github.com/jared201/MangaDb.git cd MangaDb

2. Install dependencies

pip install -r requirements.txt

Note: It's recommended to use a virtual environment to avoid conflicts with other Python packages.

python -m venv .venv # On Windows .venv\Scripts\activate # On macOS/Linux source .venv/bin/activate pip install -r requirements.txt

Running MangaDB

MangaDB can be run in different modes:

API Mode (Default)

This starts the MangaDB service and a FastAPI web server:

python main.py

Access the API at http://localhost:8000 and the API documentation at http://localhost:8000/docs.

Text-based UI Mode

This starts the MangaDB service with a text-based user interface:

python main.py --tui

The TUI provides a command-line interface for interacting with MangaDB.

Project Structure

Understanding the project structure will help you navigate the codebase:

  • main.py: The main entry point for the application
  • mongo_db_service.py: The server component that handles storage and retrieval
  • mongo_db_client.py: The client library for communicating with the service
  • data/: Directory where collections are stored as .dat files
  • templates/: HTML templates for the web interface
  • static/: Static files like images and CSS

Verifying Your Installation

Let's verify that MangaDB is working correctly by creating a simple test:

python -c "from mongo_db_client import MongoDBClient; client = MongoDBClient(); client.connect(); print('Connected:', client.insert('test_collection', {'test': 'Hello MangaDB!'})); print(client.find_one('test_collection', {'test': 'Hello MangaDB!'})); client.disconnect()"

If everything is working correctly, you should see output similar to:

Connected: some-uuid-string {'test': 'Hello MangaDB!', '_id': 'some-uuid-string'}

Congratulations! You've successfully installed and run MangaDB. In the next section, we'll explore basic operations like creating, reading, updating, and deleting documents.