{"id":31103631,"url":"https://github.com/louisfernando1204/fastbook-backend","last_synced_at":"2026-05-15T01:43:12.650Z","repository":{"id":313960174,"uuid":"1053550866","full_name":"LouisFernando1204/fastbook-backend","owner":"LouisFernando1204","description":"FastBook is my comprehensive project for mastering Python FastAPI development, built with PostgreSQL, Redis, and Celery. It's a modern backend service for a book review platform, featuring a robust async architecture with JWT authentication, email verification, and role-based access control.","archived":false,"fork":false,"pushed_at":"2025-09-09T17:07:32.000Z","size":34,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-17T02:51:46.175Z","etag":null,"topics":["background-tasks","book-management","broker","celery","clean-architecture","email-verification","jwt-authentication","postgresql-database","pytest","python","python-backend","python-fastapi","python-rest-api","redis","redoc","swagger-ui","uvicorn","worker"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LouisFernando1204.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-09T15:48:45.000Z","updated_at":"2025-09-09T17:12:10.000Z","dependencies_parsed_at":"2025-09-10T07:18:13.274Z","dependency_job_id":null,"html_url":"https://github.com/LouisFernando1204/fastbook-backend","commit_stats":null,"previous_names":["louisfernando1204/fastbook-backend"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LouisFernando1204/fastbook-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisFernando1204%2Ffastbook-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisFernando1204%2Ffastbook-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisFernando1204%2Ffastbook-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisFernando1204%2Ffastbook-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LouisFernando1204","download_url":"https://codeload.github.com/LouisFernando1204/fastbook-backend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisFernando1204%2Ffastbook-backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33050704,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["background-tasks","book-management","broker","celery","clean-architecture","email-verification","jwt-authentication","postgresql-database","pytest","python","python-backend","python-fastapi","python-rest-api","redis","redoc","swagger-ui","uvicorn","worker"],"created_at":"2025-09-17T02:46:05.262Z","updated_at":"2026-05-15T01:43:12.643Z","avatar_url":"https://github.com/LouisFernando1204.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FastBook: A RESTful Book Management API 📚⚡\n\n## ✨ Overview\n\nWelcome to **FastBook**, a robust REST API designed for managing a modern book collection and review system. Built with Python, FastAPI, and PostgreSQL, this backend service provides a fast, scalable, and efficient foundation for a book management application. It follows modern API design principles with comprehensive authentication, asynchronous operations, and clean separation of concerns, making it highly maintainable and performant.\n\n## 🔋 Key Features\n\n- 🔐 **JWT Authentication** — Secure endpoints using JSON Web Tokens (JWT) with refresh token support, ensuring that only authenticated users can access protected resources.\n- 🏗️ **Clean Architecture** — Organized into distinct layers (Routes, Services, Models) for a clear separation of concerns, making the codebase easy to understand, test, and scale.\n- 📦 **Full CRUD Operations** — Comprehensive Create, Read, Update, and Delete functionality for all core entities:\n  - **Users**: Complete user management with secure password hashing, email verification, and role-based access control.\n  - **Books**: Manage book catalog with detailed information and user associations.\n  - **Reviews**: Allow users to rate and review books with comment functionality.\n  - **Tags**: Organize books with tagging system for better categorization.\n- 📧 **Email System** — Integrated email functionality with Celery background tasks for:\n  - Account verification emails\n  - Password reset notifications\n  - Welcome messages\n- 🔄 **Background Tasks** — Asynchronous email processing using Celery and Redis for improved performance.\n- 🛡️ **Request Validation** — Built-in validation using Pydantic models to ensure data integrity and type safety.\n- 🐘 **PostgreSQL Integration** — Utilizes PostgreSQL with SQLModel (SQLAlchemy) for robust and reliable async data storage.\n- 🚀 **High Performance** — Built on FastAPI for automatic API documentation, async support, and blazing-fast performance.\n- 🔍 **Token Blacklisting** — Redis-based token blacklisting for secure logout functionality.\n- 📊 **Database Migrations** — Alembic integration for database schema versioning and migrations.\n- ⚙️ **Centralized Configuration** — Manages all environment-specific settings securely through environment variables.\n\n## 🧑‍💻 How It Works\n\n1.  **User registers** by sending their details to the `/signup` endpoint and receives an email verification link.\n2.  **User verifies email** by clicking the verification link and can then **authenticate** via `/login` to receive JWT tokens.\n3.  **The client includes the JWT** as a Bearer Token in the `Authorization` header for all subsequent requests to protected endpoints.\n4.  **JWT Middleware** intercepts and validates tokens, checking against Redis blacklist for revoked tokens.\n5.  **The Routes layer** receives requests, validates data using Pydantic schemas, and calls appropriate **Service layer** methods.\n6.  **The Service layer** executes core business logic, handles exceptions, and coordinates with the **Models layer**.\n7.  **The Models layer** manages database interactions using SQLModel and async SQLAlchemy sessions.\n8.  **Background tasks** handle email sending asynchronously via Celery workers.\n9.  **A structured JSON response** with comprehensive error handling is returned to the client.\n\n## ⚙️ Tech Stack\n\n- 🐍 **Python 3.12+**\n- ⚡ **FastAPI** (Modern Web Framework)\n- 🐘 **PostgreSQL** (Database)\n- 🔗 **SQLModel** (ORM with SQLAlchemy)\n- 🔐 **python-jose** (JWT Implementation)\n- 🛡️ **passlib** (Password Hashing with bcrypt)\n- ✅ **Pydantic** (Data Validation)\n- 📧 **fastapi-mail** (Email Integration)\n- 🔄 **Celery** (Background Task Processing)\n- 🗄️ **Redis** (Token Blacklisting \u0026 Celery Broker)\n- 🗃️ **Alembic** (Database Migrations)\n- 🧪 **pytest** (Testing Framework)\n\n## 📚 FastBook Insights\n\n- 🌐 **Python Backend** : [View Code](https://github.com/LouisFernando1204/fastbook-backend)\n\n## 🚀 Getting Started\n\nFollow these steps to get FastBook up and running on your local machine.\n\n### Prerequisites\n\n- [Python](https://www.python.org/downloads/) (version 3.12 or higher)\n- [PostgreSQL](https://www.postgresql.org/download/)\n- [Redis](https://redis.io/download) (for token blacklisting and Celery)\n- A tool to interact with your database (e.g., TablePlus, DBeaver, or pgAdmin)\n\n### Installation \u0026 Setup\n\n1.  **Clone the repository:**\n\n    ```bash\n    git clone https://github.com/LouisFernando1204/fastbook-backend.git\n    cd fastbook-backend\n    ```\n\n2.  **Create and activate virtual environment:**\n\n    ```bash\n    python -m venv env\n    source env/bin/activate  # On Windows: env\\Scripts\\activate\n    ```\n\n3.  **Install dependencies:**\n\n    ```bash\n    pip install -r requirements.txt\n    ```\n\n4.  **Set up environment variables:**\n\n    - Create a `.env` file in the root directory.\n    - Add the following configuration variables:\n\n    ```env\n    # Database Configuration\n    DATABASE_URL=\"postgresql+asyncpg://username@localhost:5432/fastblog_db\"\n\n    # JWT Configuration\n    JWT_SECRET=\"your_super_secret_jwt_key_here\"\n    JWT_ALGORITHM=\"HS256\"\n\n    # Redis Configuration\n    REDIS_HORT=\"localhost\"\n    REDIS_PORT=6379\n    REDIS_URL=\"redis://localhost:6379/0\"\n\n    # Email Configuration\n    MAIL_USERNAME=your_email@gmail.com\n    MAIL_PASSWORD=your_app_password\n    MAIL_SERVER=smtp.gmail.com\n    MAIL_PORT=587\n    MAIL_FROM=your_email@gmail.com\n    MAIL_FROM_NAME=FastBook Backend\n\n    # Application Configuration\n    DOMAIN=localhost:8000\n\n    # PostgreSQL Configuration (Optional)\n    POSTGRES_USER=\n    POSTGRES_PASSWORD=\n    POSTGRES_DB=\n    ```\n\n5.  **Set up the database:**\n\n    - Start your PostgreSQL server.\n    - Create a new database named `fastbook_db` (or as specified in your DATABASE_URL).\n    - Run database migrations:\n\n    ```bash\n    alembic upgrade head\n    ```\n\n6.  **Start Redis server:**\n\n    ```bash\n    redis-server\n    ```\n\n7.  **Start Celery worker** (in a separate terminal):\n\n    ```bash\n    celery -A src.celery_tasks worker --loglevel=info\n    ```\n\n8.  **Run the application:**\n\n    ```bash\n    fastapi dev src/\n    ```\n\n    The server should now be running on `http://localhost:8000`.\n\n9.  **Access API Documentation:**\n    - Swagger UI: `http://localhost:8000/api/v1/docs`\n    - ReDoc: `http://localhost:8000/api/v1/redoc`\n\n## 📋 API Endpoints\n\n### Authentication\n\n- `POST /api/v1/auth/signup` - Register new user\n- `POST /api/v1/auth/login` - User login\n- `GET /api/v1/auth/verify/{token}` - Verify email\n- `POST /api/v1/auth/refresh-token` - Refresh access token\n- `POST /api/v1/auth/logout` - User logout\n- `GET /api/v1/auth/me` - Get current user profile\n- `POST /api/v1/auth/password-reset-request` - Request password reset\n- `POST /api/v1/auth/password-reset-confirm/{token}` - Confirm password reset\n\n### Books Management\n\n- `GET /api/v1/books/` - Get all books\n- `POST /api/v1/books/` - Create new book\n- `GET /api/v1/books/{book_uid}` - Get book by ID\n- `PATCH /api/v1/books/{book_uid}` - Update book\n- `DELETE /api/v1/books/{book_uid}` - Delete book\n\n### Reviews\n\n- `POST /api/v1/books/{book_uid}/reviews` - Add review to book\n- `DELETE /api/v1/books/{book_uid}/reviews/{review_uid}` - Delete review\n\n### Tags\n\n- `GET /api/v1/tags/` - Get all tags\n- `POST /api/v1/tags/` - Create new tag\n- `POST /api/v1/books/{book_uid}/tags` - Add tags to book\n- `DELETE /api/v1/books/{book_uid}/tags/{tag_uid}` - Remove tag from book\n\n## 🧪 Running Tests\n\n```bash\npytest src/tests/ -v\n```\n\n## 🤝 Contributor\n\n- 🧑‍💻 **Louis Fernando** : [@LouisFernando1204](https://github.com/LouisFernando1204)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flouisfernando1204%2Ffastbook-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flouisfernando1204%2Ffastbook-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flouisfernando1204%2Ffastbook-backend/lists"}