Skip to content

richardnguyen99/cursus-v1

Repository files navigation

Cursus

Code style: black Python Version from PEP 621 TOML GitHub release (with filter) Docker Image Version (tag latest semver)

An open-source API repository for public universities.

Disclaimer

This API is not affilitated with any universities. The data is collected based on public search engines with public information. Information may be incorrect, unofficial, or outdated. Please use with caution.

The data is a collection of information from universities' public information. If you couldn't find the information you need, or the information is incorrect, please send an email to [email protected] for your request.

Working directory

.
├── cursus              # Core directory
│   ├── app.py          # Main Flask application
│   ├── config.py       # Configuration file
│   ├── __init__.py   
│   ├── apis/           # API endpoints
│   ├── models/         # ORM models for database         
│   ├── schema/         # Pydantic schemas-to-json for APIs
│   ├── static/         # Static files
│   ├── templates/      # HTML pages
│   ├── util/           # Utility functions
│   └── views/          # Flask views and blueprints
├── data/               # Initial data for development
├── migrations/         # Alembic migration folder
├── nginx/              # Nginx configuration (development)
├── sql/                # Backup SQL scripts
├── test/               # Test directory
├── docker-compose.yml  # Docker compose to orchestrate docker containers
├── Dockerfile          # Python Docker image for development
├── Dockerfile.prod     # Python Docker image for production
├── manage.py           # CLI script
└── pyproject.toml      # Core Python configuration

Installation

Pre-requisites

Clone the repository

git clone https://github.com/richardnguyen99/cursus.git

Create an .env file

You need to create an .env file in order to start the application. The .env will be used by Docker Compose to set up and boot up all the docker containers. For example,

APP_SETTINGS="cursus.config.DevConfig"


POSTGRES_USER="postgres"
POSTGRES_PASSWORD="something-secret"
POSTGRES_DB="cursus"
PGPORT=7432
DATABASE_URL="postgresql://postgres:[email protected]:7432/cursus"

PGADMIN_DEFAULT_EMAIL="[email protected]"
PGADMIN_DEFAULT_PASSWORD="pgadmin"
PGADMIN_LISTEN_PORT=5050

Please check .env.example for more details.

DATABASE_URL might be different depending on your docker network. You can check the IP Addres for the postgres container by running docker inspect <container_id> | grep IPAddress.

Run with docker-compose

docker-compose up --build

Docker Compose will boot up everything for you. You can access the application with these following URLs:

  • http://locahost: The main application. NGINX will serve as the reverse proxy for the application. Every request will be redirected to the application.
  • http://localhost:5050: The Flask application.
  • http://admin.localhost: The PGAdmin application.
  • http://localhost:7432: The PostgreSQL database.

Run first migration

First, you need to install alembic to run the migration. I recommend you to install it in a virtual environment with your choice of package manager. After activating the virtual environment, run:

python3 manage.py db upgrade

This will run the first migration to create the database schema for you.

LICENSE

This project is licensed under the terms of the MIT license.