mirror of
https://github.com/wowlikon/LibraryAPI.git
synced 2025-12-11 21:30:46 +00:00
add alembic and readme
This commit is contained in:
74
README.md
74
README.md
@@ -1,17 +1,65 @@
|
||||
# Book API
|
||||
|
||||
## Installation
|
||||
1. Clone the repository: `git clone https://github.com/yourusername/bookapi.git`
|
||||
2. Navigate to the project directory: `cd bookapi`
|
||||
3. Copy and configure environment variables: `cp .env.example .env`
|
||||
4. Build docker-compose: `docker-compose build`
|
||||
5. Run the application: `docker-compose up`
|
||||
This project is a test web application built using FastAPI, a modern web framework for creating APIs in Python. It showcases the use of Pydantic for data validation, SQLModel for database interactions, Alembic for migration management, PostgreSQL as the database system, and Docker Compose for easy deployment.
|
||||
|
||||
## Usage
|
||||
### **Key Components:**
|
||||
|
||||
## TODO
|
||||
* Usage instructions
|
||||
* Split models for api and db
|
||||
* Add documentation for API endpoints
|
||||
* Add alembic migrations
|
||||
* Add tests
|
||||
1. FastAPI: Provides high performance and simplicity for developing RESTful APIs, supporting asynchronous operations and automatic documentation generation.
|
||||
2. Pydantic: Used for data validation and serialization, allowing easy definition of data schemas.
|
||||
3. SQLModel: Combines SQLAlchemy and Pydantic, enabling database operations with Python classes.
|
||||
4. Alembic: A tool for managing database migrations, making it easy to track and apply changes to the database schema.
|
||||
5. PostgreSQL: A reliable relational database used for data storage.
|
||||
6. Docker Compose: Simplifies the deployment of the application and its dependencies in containers.
|
||||
|
||||
|
||||
### **Installation Instructions**
|
||||
|
||||
1. Clone the repository:
|
||||
```bash
|
||||
git clone https://github.com/yourusername/bookapi.git
|
||||
```
|
||||
|
||||
2. Navigate to the project directory:
|
||||
```bash
|
||||
cd bookapi
|
||||
```
|
||||
|
||||
3. Copy and configure environment variables:
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
4. Build the Docker containers:
|
||||
```bash
|
||||
docker-compose build
|
||||
```
|
||||
|
||||
5. Run the application:
|
||||
```bash
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
|
||||
### **API Endpoints**
|
||||
|
||||
**Authors**
|
||||
| Method | Endpoint | Description |
|
||||
|--------|-------------------|--------------------------------------|
|
||||
| POST | `/author` | Create a new author |
|
||||
| GET | `/author` | Retrieve a list of all authors |
|
||||
| PUT | `/author/{id}` | Update a specific author by ID |
|
||||
| DELETE | `/author/{id}` | Delete a specific author by ID |
|
||||
|
||||
**Books**
|
||||
| Method | Endpoint | Description |
|
||||
|--------|-------------------|--------------------------------------|
|
||||
| POST | `/books` | Create a new book |
|
||||
| GET | `/books` | Retrieve a list of all books |
|
||||
| PUT | `/books/{id}` | Update a specific book by ID |
|
||||
| DELETE | `/books/{id}` | Delete a specific book by ID |
|
||||
|
||||
|
||||
### **TODO List**
|
||||
|
||||
- Split models for API and database
|
||||
- Implement tests
|
||||
|
||||
Reference in New Issue
Block a user