Thanks to visit codestin.com
Credit goes to github.com

Skip to content

zorky/library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Library Management System

A full-stack application for managing a library, built with Django, Django REST Framework, and Angular.

Articles

This project was developed as part of a tutorial series:

Technologies Used

  • Backend: Django, Django REST Framework
  • Frontend: Angular, Angular CLI
  • Database: SQLite (default, configurable)
  • Containerization: Docker, Docker Compose
  • API Documentation: Swagger (auto-generated by drf-yasg)

Setup Instructions

This project uses Docker to simplify setup. Ensure you have Docker and Docker Compose installed.

Backend Setup

The backend is a Django application.

  1. Navigate to the docker directory:

    cd docker
  2. Build and run the containers: This will build the api-plateform image if it doesn't exist and start the backend API service along with Nginx.

    docker-compose up --build -d

    The backend API will be accessible at http://localhost:8110 (or http://localhost if accessed through Nginx as configured in docker-compose.yml).

    Alternatively, for local development without Docker (ensure Python and pip are installed):

  3. Create and activate a virtual environment (optional but recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  4. Navigate to the backend directory:

    cd backend
  5. Install dependencies:

    pip install -r ../requirements.txt

    (Note: The requirements.txt in the root seems to be the one used by Docker for the backend. If there's a specific one inside ./backend, adjust accordingly.)

  6. Run database migrations:

    python manage.py migrate
  7. Start the development server:

    python manage.py runserver 8110

Frontend Setup

The frontend is an Angular application.

  1. Navigate to the frontend/library directory:

    cd frontend/library
  2. Install dependencies:

    npm install

    Note: If you encounter issues with npm install due to version conflicts (e.g., with @angular/cli), you might need to use a specific Node.js version or update/downgrade packages as necessary. The project was generated with Angular CLI 9.1.0.

Running the Application

Backend

  • If using Docker: The backend service (api-plateform) and Nginx (nginx-plateform) should already be running if you followed the Docker setup instructions (docker-compose up -d). You can check the status of the containers:

    cd docker
    docker-compose ps

    To view logs:

    docker-compose logs api-plateform
    docker-compose logs nginx-plateform

    The API should be accessible at http://localhost:8110 directly or http://localhost/ via Nginx.

  • If running locally (without Docker): Ensure you are in the backend directory and your virtual environment is activated.

    python manage.py runserver 8110

    The API will be available at http://localhost:8110.

Frontend

  1. Navigate to the frontend/library directory:
    cd frontend/library
  2. Start the Angular development server:
    ng serve
    Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

API Documentation

This project uses drf-yasg to generate API documentation with Swagger/OpenAPI.

Once the backend is running (either via Docker or locally), you can access the API documentation at the following endpoints:

  • Swagger UI: http://localhost:8110/swagger/
  • ReDoc UI: http://localhost:8110/redoc/
  • JSON Schema: http://localhost:8110/swagger.json
  • YAML Schema: http://localhost:8110/swagger.yaml

If you are accessing the backend via Nginx through Docker (at http://localhost/), the paths for API documentation are directly at the root:

  • Swagger UI: http://localhost/
  • ReDoc UI: http://localhost/redoc/
  • JSON Schema: http://localhost/swagger.json (The schema is typically available at swagger.json relative to the Swagger UI path)
  • YAML Schema: http://localhost/swagger.yaml (The schema is typically available at swagger.yaml relative to the Swagger UI path)

(Note: The Django application serves Swagger UI at its root (/) and ReDoc at /redoc/. Nginx proxies requests directly to the Django application.)

Frontend Development

The frontend application is built with Angular. The source code is located in frontend/library/.

Development server

Run ng serve (from the frontend/library directory) for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Code scaffolding

Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.

Build

Run ng build to build the project. The build artifacts will be stored in the dist/ directory (within frontend/library). Use the --prod flag for a production build.

Running unit tests

Run ng test to execute the unit tests via Karma.

Running end-to-end tests

Run ng e2e to execute the end-to-end tests via Protractor.

Further help with Angular CLI

To get more help on the Angular CLI use ng help or go check out the Angular CLI README.

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •