{"id":19318490,"url":"https://github.com/andreypomortsev/library","last_synced_at":"2026-04-09T16:02:19.002Z","repository":{"id":246387508,"uuid":"820859607","full_name":"andreypomortsev/library","owner":"andreypomortsev","description":"This project provides a simple yet comprehensive system for managing a library, focusing on book management and author tracking. It utilizes FastAPI, Docker, PostgreSQL, and SQLAlchemy to offer a robust framework for creating, updating, and retrieving books and authors through a RESTful API.","archived":false,"fork":false,"pushed_at":"2025-02-12T12:54:34.000Z","size":95,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-12T13:28:44.918Z","etag":null,"topics":["ci","docker","docker-compose","fastapi","postgresql","pydantic","sqlalchemy-python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreypomortsev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-06-27T10:16:55.000Z","updated_at":"2025-02-12T12:54:38.000Z","dependencies_parsed_at":"2024-06-27T18:49:00.991Z","dependency_job_id":"706f1cbb-7c9e-4352-8421-d94b4fd6c43d","html_url":"https://github.com/andreypomortsev/library","commit_stats":null,"previous_names":["andreypomortsev/library"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreypomortsev%2Flibrary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreypomortsev%2Flibrary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreypomortsev%2Flibrary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreypomortsev%2Flibrary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreypomortsev","download_url":"https://codeload.github.com/andreypomortsev/library/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240420982,"owners_count":19798502,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["ci","docker","docker-compose","fastapi","postgresql","pydantic","sqlalchemy-python"],"created_at":"2024-11-10T01:18:46.239Z","updated_at":"2026-04-09T16:02:18.993Z","avatar_url":"https://github.com/andreypomortsev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Static Badge](https://img.shields.io/badge/Python-3.12%2B-blue)\n![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)\n# Library Management System\n\n## The Project Tree\n\n```\nlibrary/\n├── LICENSE\n├── README.md\n├── README.ru.md\n├── app\n│   ├── Dockerfile\n│   ├── main.py\n│   ├── requirements.txt\n│   ├── core\n│   │   └── database.py\n│   ├── models\n│   │   ├── book.py\n│   │   ├── customer.py\n│   │   └── loan.py\n│   ├── routers\n│   │   ├── books.py\n│   │   ├── customers.py\n│   │   └── loans.py\n│   └── schemas\n│   │   ├── book.py\n│   │   ├── customer.py\n│   │   └── loan.py\n│   └── services\n│       ├── book_service.py\n│       ├── customer_service.py\n│       └── loan_service.py\n├── db\n│   ├── Dockerfile\n│   ├── init.sql\n│   └── procedures.sql\n└── docker-compose.yml\n└── docs\n    ├── api.md\n    └── api.ru.md\n```\n\n### 📚 Structure Explanation\n\n- **`LICENSE`**: MIT License for the project.\n- **`README.md`**: Main project documentation in English.\n- **`README.ru.md`**: Project documentation in Russian.\n- **`app/`**: FastAPI application source code.\n  - **`Dockerfile`**: Docker setup for the FastAPI app.\n  - **`main.py`**: Application entry point, includes router registration.\n  - **`requirements.txt`**: Python dependencies list.\n  - **`core/`**: Core utilities and configuration.\n    - **`database.py`**: Database engine and session management.\n  - **`models/`**: SQLAlchemy ORM models that map to database tables.\n    - **`book.py`**, **`customer.py`**, **`loan.py`**: Models for respective entities.\n  - **`routers/`**: Route definitions (API endpoints).\n    - **`books.py`**, **`customers.py`**, **`loans.py`**: Routers for resource-specific operations.\n  - **`schemas/`**: Pydantic schemas for request validation and response serialization.\n    - Mirrors the structure of `models/` for consistency.\n  - **`services/`**: Business logic layer, keeping routes clean and focused.\n    - Service functions for books, customers, and loans.\n- **`db/`**: Database initialization and configuration.\n  - **`Dockerfile`**: PostgreSQL setup inside a container.\n  - **`init.sql`**: SQL script to initialize tables and seed data.\n  - **`procedures.sql`**: Contains stored procedures used by the app.\n- **`docker-compose.yml`**: Orchestration of the FastAPI and PostgreSQL services.\n- **`docs/`**: API documentation in both English and Russian.\n\n### Prerequisites\n\n- Docker\n- Docker Compose\n\n### Run\n\n1. Clone the repo:\n   ```sh\n   git clone https://github.com/andreypomortsev/library.git\n   cd library\n   ```\n\n2. Running the services:\n   ```sh\n   docker compose up --build\n   ```\n\n3. The FastAPI is available at `http://localhost:8000`.\n4. The API documentation is available at `http://localhost:8000/docs`.\n\n## Database Schema\n\n### Here is a representation of the database schema for the project:\n\n#### Table: `customers`\n\n| Column       | Type          | Constraints                    |\n|--------------|---------------|--------------------------------|\n| id           | SERIAL        | PRIMARY KEY                    |\n| name         | VARCHAR(100)  | NOT NULL                       |\n| last_name    | VARCHAR(100)  | NOT NULL                       |\n| middle_name  | VARCHAR(100)  |                                |\n| birth_year   | INTEGER       | NOT NULL                       |\n| is_author    | BOOLEAN       | NOT NULL, DEFAULT FALSE        |\n\n#### Table: `books`\n\n| Column    | Type         | Constraints                         |\n|-----------|--------------|-------------------------------------|\n| id        | SERIAL       | PRIMARY KEY                         |\n| title     | VARCHAR(255) | NOT NULL                            |\n| author_id | INTEGER      | REFERENCES customers(id)            |\n| genre     | VARCHAR(255) | NOT NULL                            |\n| year      | INTEGER      | NOT NULL                            |\n| status    | BOOLEAN      | NOT NULL, DEFAULT TRUE              |\n\n#### Table: `loans`\n\n| Column      | Type    | Constraints                          |\n|-------------|---------|--------------------------------------|\n| id          | SERIAL  | PRIMARY KEY                          |\n| book_id     | INTEGER | REFERENCES books(id), NOT NULL       |\n| user_id     | INTEGER | REFERENCES customers(id), NOT NULL   |\n| loan_date   | DATE    | NOT NULL, DEFAULT CURRENT_DATE       |\n| return_date | DATE    | DEFAULT NULL                         |\n\n## API Documentation\n\nDetailed list of available endpoints:  \n➡️ [See full API list](docs/api.md)\n\n## Contributing\n\nContributions are welcome! Please fork the repo and create a pull request.\n\n## Author\n\n- [Andrei Pomortsev](https://www.linkedin.com/in/andreypomortsev/)\n\n## License\n\nThis project is licensed under the MIT License - see the file for details [LICENSE](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreypomortsev%2Flibrary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreypomortsev%2Flibrary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreypomortsev%2Flibrary/lists"}