|
| 1 | +# SwiftComp-API |
| 2 | + |
| 3 | +**SwiftComp-API** is a FastAPI-based backend designed to perform calculations related to composite laminate materials. It exposes various endpoints for computing engineering constants, plate properties, 3D laminate properties, and more. This API is suitable for researchers, engineers, and developers working in composite materials and structural analysis. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Features](#features) |
| 8 | +- [Technologies](#technologies) |
| 9 | +- [Installation](#installation) |
| 10 | +- [API Documentation](#api-documentation) |
| 11 | +- [Testing](#testing) |
| 12 | +- [Contributing](#contributing) |
| 13 | +- [License](#license) |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## Features |
| 18 | + |
| 19 | +- **Versioned API:** Support for multiple versions of the API, with versioning (v1, v2) for backward compatibility. |
| 20 | +- **Material Property Calculations:** Endpoints to calculate various laminate engineering constants and composite properties. |
| 21 | +- **Lightweight & Fast:** Built using FastAPI, ensuring high performance and minimal latency. |
| 22 | +- **Modular Architecture:** Separation of concerns using routers, services, and utility functions for better maintainability. |
| 23 | +- **Extensible:** Easy to add new endpoints and services for additional material computations. |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## Technologies |
| 28 | + |
| 29 | +- **FastAPI**: A modern, fast (high-performance) web framework for building APIs with Python 3.7+ based on standard Python-type hints. |
| 30 | +- **Python 3.7**: Programming language used to implement the logic. |
| 31 | +- **Pytest**: A robust testing framework for Python. |
| 32 | +- **Uvicorn**: ASGI server used for serving FastAPI applications. |
| 33 | +- **Virtual Environment (venv)**: For dependency isolation. |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## Installation |
| 38 | + |
| 39 | +To set up the project locally, follow these steps: |
| 40 | + |
| 41 | +### Prerequisites |
| 42 | +- Python 3.7 or higher. |
| 43 | +- Git installed on your system. |
| 44 | + |
| 45 | +### Step-by-Step Guide |
| 46 | + |
| 47 | +1. **Clone the repository**: |
| 48 | +```bash |
| 49 | +git clone https://github.com/wenbinyugroup/swiftcomp-api.git |
| 50 | +cd swiftcomp-api |
| 51 | +``` |
| 52 | + |
| 53 | +2. **Create and activate a virtual environment**: |
| 54 | +```bash |
| 55 | +python -m venv venv |
| 56 | +source venv/bin/activate # On Windows: venv\Scripts\activate |
| 57 | +``` |
| 58 | + |
| 59 | +3. **Install the dependencies**: |
| 60 | +```bash |
| 61 | +pip install -r requirements.txt |
| 62 | +``` |
| 63 | + |
| 64 | +4. **Run the FastAPI application locally**: |
| 65 | +```bash |
| 66 | +uvicorn app.main:app --reload |
| 67 | +``` |
| 68 | + |
| 69 | +This will start the SwiftComp API server at http://127.0.0.1:8000. |
| 70 | + |
| 71 | +## API Documentation |
| 72 | +FastAPI automatically generates interactive API documentation using **Swagger** and **Redoc**. Once the server is running, you can access the documentation at: |
| 73 | + |
| 74 | +* Swagger UI: http://127.0.0.1:8000/docs |
| 75 | +* ReDoc: http://127.0.0.1:8000/redoc |
| 76 | + |
| 77 | +## Sample Endpoints |
| 78 | +* **GET /**: Root endpoint, returns a welcome message. |
| 79 | +* **POST /api/v1/lamina_engineering_constants**: Calculates the lamina engineering constants based on the provided material properties. |
| 80 | +* **POST /api/v1/laminate_plate_properties**: Calculates the laminate plate properties. |
| 81 | +* **POST /api/v1/laminate_3d_properties**: Computes the 3D properties of laminate. |
| 82 | +* **POST /api/v1/udfrc_properties**: Calculates UDFRC properties. |
| 83 | + |
| 84 | +## Testing |
| 85 | +The repository includes unit tests using `pytest`. To run the tests: |
| 86 | + |
| 87 | +1. Ensure you are in the virtual environment. |
| 88 | +2. Run the following command: |
| 89 | +```bash |
| 90 | +PYTHONPATH=./ pytest |
| 91 | +``` |
| 92 | + |
| 93 | +## Contributing |
| 94 | +We welcome contributions to **SwiftComp-API**! Here's how you can help: |
| 95 | + |
| 96 | +1. **Fork the repository**. |
| 97 | +2. **Create a new feature branch**: |
| 98 | +```bash |
| 99 | +git checkout -b feature/your-feature-name |
| 100 | +``` |
| 101 | +3. **Commit your changes**: |
| 102 | +```bash |
| 103 | +git commit -m "Add your message" |
| 104 | +``` |
| 105 | +4. **Push to the branch**: |
| 106 | +```bash |
| 107 | +git push origin feature/your-feature-name |
| 108 | +``` |
| 109 | +5. **Create a pull request**: Describe the changes you’ve made. |
| 110 | + |
| 111 | + |
| 112 | +## License |
| 113 | +This project is licensed under the MIT License. See the LICENSE file for more details. |
0 commit comments