/project_coding_latam_api

A JSON API created for the Coding Latam community

Primary LanguagePythonMIT LicenseMIT

Coding Latam API

The JSON used as the database is located in app/data/db.py

Requirements

  • Python 3.8+

Installation

Clone the repository and navigate to the project directory:

git clone git@github.com:tyronejosee/project_coding_latam_api.git

Virtual Environment Setup

It is recommended to create a virtual environment to isolate all the project dependencies:

# Linux
python3 -m venv env

# Windows
python -m venv env

Activate the virtual environment:

# Linux
source venv/bin/activate

# Windows
venv\Scripts\activate

Installing Dependencies

You can install the dependencies using pip or Poetry.

pip

pip install -r requirements.txt

Poetry

poetry install

Create a copy of the .env.example file and rename it to .env.

cp .env.example .env

Update the values of the environment variables (Important).

Running the Application

To run the application in development mode, use:

uvicorn app.main:app --reload

This will start the server at http://127.0.0.1:8000.

API Documentation

Once the application is running, you can access the interactive documentation at:

  • Swagger UI: http://127.0.0.1:8000/docs
  • Redoc: http://127.0.0.1:8000/redoc

Deploy

Example with Railway

Log in or sign up at railway.app.

Select New on your dashboard and Deploy from GitHub repo:

Example-01

Configure and grant permission to the specific repositories for deployment:

Example-02 Example-03

Go to the Settings tab of the instance.

Example-04

Add the command pip install -r requirements.txt in the Custom Build Command field:

Example-05

Add the command uvicorn app.main:app --host 0.0.0.0 --port $PORT in the Custom Start Command field:

Example-06

After completing the Railway process, click on Generate Domain within Settings:

Example-07

And your API will be deployed successfully. 🎉🎉

Example-08