It is a seashell management app built using Python. CRUD operations are implemented following clean-architecture. Here, FastAPI, SQLalchemy, and SQLite is used for the execution of the app.
Follow the following steps to start the web application.
- Clone the repository to your destination.
- Use
pipenvto install necessary packages and set up a virtual environment. - Run
source venv/bin/activeto activate the virtual environment - Run
python main.pyto start the server. - Run
pytestto run the test cases
- POST
-
Method: POST
-
NOTE: Only
descriptionis optional -
Example Payload:
{
"name": "Seashell_1",
"collection_at": "2025-01-30T15:00:00",
"description": "This is collected from cox'z bazar",
"species": "snail",
"image": "seashell.png"
}- Response:
201
{
"message": "Seashell created successfully",
"data": {
"id": 126,
"created_at": "2025-02-01T13:07:03",
"updated_at": "2025-02-01T13:07:03",
"collected_at": "2025-01-30T15:00:00",
"name": "Seashell_1",
"species": "snail",
"description": "This is collected from cox'z bazar",
"image_url": "static/images/seashell_images/seashell.png"
}
}- Example Payload:
{
"collection_at": "2025-01-30T15:00:00",
"description": "This is collected from cox'z bazar",
"species": "snail",
"image": "seashell.png"
}- Response:
422
{
"detail": [
{
"type": "missing",
"loc": [
"body",
"name"
],
"msg": "Field required",
"input": null
}
]
}- PATCH
- Path: http://127.0.0.1:7777/v1/seashell/{seashell_id}
- Method: PATCH
- NOTE: Every input is optional
- Example Payload:
{
"name": "Seashell_updated",
"collection_at": "2025-01-30T15:00:00",
"description": "This is collected from cox'z bazar",
"species": "snail",
"image": "seashell.png"
}- Responses:
200
{
"message": "Seashell updated successfully",
"data": {
"id": 127,
"created_at": "2025-02-01T13:08:14",
"updated_at": "2025-02-01T13:08:45",
"collected_at": "2025-01-30T15:00:00",
"name": "Seashell_updated",
"species": "snail",
"description": "This is collected from cox'z bazar",
"image_url": "static/images/seashell_images/seashell.png"
}
}404
{
"detail": "Seashell not found"
}- GET
- Path: http://127.0.0.1:7777/v1/seashell/{seashell_id}
- Method: GET
- Responses:
200
{
"message": "Seashell retrived successfully",
"data": {
"id": 127,
"created_at": "2025-02-01T13:08:14",
"updated_at": "2025-02-01T13:08:45",
"collected_at": "2025-01-30T15:00:00",
"name": "Seashell_updated",
"species": "snail",
"description": "This is collected from cox'z bazar",
"image_url": "static/images/seashell_images/seashell.png"
}
}404
{
"detail": "Seashell not found"
}- GET
- Path: http://127.0.0.1:7777/v1/seashell
- Method: GET
- NOTE: Pagination limit is 10
- Response:
200
{
"message": "Seashells retrived successfully",
"data": [
{
"id": 1,
"created_at": "2025-02-01T00:54:51",
"updated_at": "2025-02-01T10:18:23",
"collected_at": "2024-02-01T14:30:45",
"name": "Updated_Seashell",
"species": "snail",
"description": "This is collected from cox'z bazar",
"image_url": "static/images/seashell_images/seashell.png"
},
{
"id": 2,
"created_at": "2025-02-01T09:40:19",
"updated_at": "2025-02-01T09:40:19",
"collected_at": "2024-02-01T14:30:45",
"name": "Test Seashell",
"species": "snail",
"description": "This is collected from cox'z bazar",
"image_url": "static/images/seashell_images/seashell.png"
},
{
"id": 3,
"created_at": "2025-02-01T09:56:07",
"updated_at": "2025-02-01T09:56:07",
"collected_at": "2024-02-01T14:30:45",
"name": "Test Seashell",
"species": "snail",
"description": "This is collected from cox'z bazar",
"image_url": "static/images/seashell_images/image.png"
},
......
]
}- DELETE
- Path: http://127.0.0.1:7777/v1/seashell/{seashell_id}
- Method: DELETE
- Responses:
200
{
"message": "Seashell deleted successfully",
"data": {
"id": 127,
"created_at": "2025-02-01T13:08:14",
"updated_at": "2025-02-01T13:08:45",
"collected_at": "2025-01-30T15:00:00",
"name": "Seashell_updated",
"species": "snail",
"description": "This is collected from cox'z bazar",
"image_url": "static/images/seashell_images/seashell.png"
}
}404
{
"detail": "Seashell not found"
}