Giter Club home page Giter Club logo

archive-api's Introduction

CSE Archive RESTful API

This is the source code of our REST API backend implemented with the Django framework, which is open source for educational purposes and contributions.

Deployment

The steps described below are suitable for deploying this project in a development environment. If you intend to deploy this to production, you can read this article.

Requirements

It is assumed that Python, PIP tool and PostgreSQL database are installed on your OS.

Setup Database

To deploy the project you need a database, which you can create by entering the following command in the PostgreSQL shell, where <db_name> is the name of the database you want to create. Don't forget to exit the PostgreSQL shell after creating your database.

CREATE DATABASE <db_name>;

Setup Virtual Environment

This project uses pipenv for its virtual environment, if you don't have pipenv already install it with

pip install pipenv

Now at the project root, use pipenv install command to install project dependencies listed in Pipfile. After that, use its shell command to enable the newly created virtual environment

pipenv install
pipenv shell

Environment Configuration

Copy the .env.example file content and paste it to a new file named .env at the project's root. Now fill in the variables values according to the description below.

  • DEBUG: This Boolean variable can be True or False depending on environment. To run the program in the production environment, set the Boolean variable to False.
  • SECRET_KEY: This is used to sign sensitive data, so it is important to generate a strong key. You can generate a key yourself or use the command
    python manage.py generate_secret_key
  • ALLOWED_HOSTS: Specifies the hosts that Django can accept requests from. Separate multiple hosts with commas, or use * to accept all requests.
  • CORS_ALLOWED_ORIGIN_REGEXES: This variable is a string representing regex that matches Origins that are authorized to make cross-site HTTP requests. If the DEBUG setting is True, this value will not be considered and all origins will be allowed.
  • DB_NAME, DB_USER, DB_PASSWORD, DB_HOST, DB_PORT: These variables describe the database you created for this project.

Running the API

Now that everything is ready, you can run the following commands to start the API.

First, we should apply database migrations

python manage.py migrate

To use the sample data, run this command (Optional)

python manage.py loaddata fixtures/admin_interface_theme_uswds.json fixtures/courses.json fixtures/course_relations.json fixtures/chartnodes.json fixtures/professors.json fixtures/tas.json fixtures/classrooms.json fixtures/references.json fixtures/resources.json fixtures/recordings.json

Now use this command to start an instance of API on your local machine

python manage.py runserver 

By default, you can access the project at localhost:8000, the admin panel at /admin route, and the API documentation at /swagger route.

Database Design

To generate a diagram of the models used in the API, make sure you have Graphviz on your OS. Then, run the following commands:

python manage.py graph_models -a -g --dot -o cse_archive_erd.dot
dot -Tpng cse_archive_erd.dot -o cse_archive_erd.png

Contribution

Contributions of any size are welcomed here. You only need to:

  1. Fork the project.
  2. Make your changes in a new branch.
  3. Create a Pull Request with a title that summarizes your changes and a description that explains your changes in more detail.

If you have any enhancement ideas but don't feel like doing it yourself, you can always open a new issue for that.

archive-api's People

Contributors

ar-ekt avatar reza00farjam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.