Coder Social home page Coder Social logo

avr2002 / backend-library-management-sys Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 37 KB

Backend for simple Library Management System using FastAPI. Deployed on GCP Cloud Run as Docker Image.

Home Page: https://fastapi-app-e6gqne432q-el.a.run.app/docs

Python 82.95% Dockerfile 17.05%
fastapi monogodb pydantic-v2 pymongo python python3 docker docker-compose docker-image gcp

backend-library-management-sys's Introduction

Library Management System API

This project implements a RESTful API for a Library Management System using FastAPI with MongoDB Atlas as the database.

API Endpoints

  • POST /students: Create a new student record.
  • GET /students: Retrieve a list of students. Optional query parameters:
    • country: Filter students by country (string).
    • age: Filter students by age (integer).
  • GET /students/{id}: Retrieve details of a specific student by ID.
  • PATCH /students/{id}: Update details of a specific student by ID.
  • DELETE /students/{id}: Delete a specific student by ID.

Folder Structure

.
|__config
|   |__config.py        # Configuration settings
|__models
|   |__students.py      # MongoDB models for students
|__routes
|   |__route.py         # FastAPI route definitions
|__schema
|   |__schemas.py       # Pydantic schemas for request/response data
|__.env                 # Environment variable configuration
|__.gitignore           # Gitignore file
|__docker-compose.yml   # Docker Compose configuration
|__Dockerfile           # Dockerfile for building the Docker image
|__main.py              # Main FastAPI application entry point
|__README.md            # Project README file
|__requirements.txt     # Python dependencies file

Prerequisites

  • Python 3.9 or higher
  • Docker
  • MongoDB Atlas account

Setup Instructions

  1. Clone the Repository:

    git clone https://github.com/yourusername/library-management-api.git
    cd library-management-api
  2. Install Dependencies:

    pip install -r requirements.txt
  3. Set Environment Variables: Create a .env file in the project root directory with the following content:

    MONGO_URI=mongodb+srv://yourusername:[email protected]/yourdatabase?retryWrites=true&w=majority
    MONGO_DB_NAME=yourdatabase
    MONGO_COLLECTION_NAME=students
    
  4. Run the Application:

    uvicorn main:app --host 0.0.0.0 --port 8000

Docker Deployment

To deploy the application using Docker, follow these steps:

  1. Build the Docker Image:

    docker build -t library-management-api .
  2. Run the Docker Container:

    docker run -d --name library-api-container -p 8000:8000 library-management-api

Docker Hub Image

docker pull avr2002/fastapi-app:latest
docker run -d --name fastapi-app-container -p 8000:8000 avr2002/fastapi-app:latest

Improvements

  • Implement CI/CD using GitHub Actions
  • Write unit tests

backend-library-management-sys's People

Contributors

avr2002 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.