Skip to content

aliowx/sucide_analysis

Repository files navigation

🚀 FastAPI Machine Learning API

This project is a FastAPI-based machine learning API that provides endpoints for model inference. The setup uses Poetry for dependency management and Alembic for database migrations.

🔧 Setup Project

📦 Install Poetry

curl -sSL https://install.python-poetry.org | python3 -

If you are using Bash, add the following to your ~/.profile or ~/.bashrc:

export PATH="$HOME/.local/bin:$PATH"

If you are using Fish, run:

fish_add_path $HOME/.local/bin

📂 Create Project Directory

cd backend

⚙️ Project Setup

🏗️ Create a New Project

poetry new app

📌 Install Dependencies

pip3 install uvicorn gunicorn fastapi
cd backend/app
poetry add fastapi uvicorn gunicorn pydantic numpy pandas scikit-learn joblib alembic sqlalchemy psycopg2

🔄 Initializing a Pre-existing Project

cd backend/app
poetry shell
poetry install

🗄️ Database Migration

📜 Create Migration File

alembic revision --autogenerate -m "Initial migration"

📥 Apply Migration

alembic upgrade head

🌍 Environment Variables

Create a .env file in backend/app and fill it with values from .env.example.

🔑 Create Superuser

Set user email and password in .env:

FIRST_SUPERUSER=
FIRST_SUPERUSER_PASSWORD=

Then, create the first superuser:

python3 initial_data.py
# or
poetry run python3 initial_data.py

🛰️ Test WebSocket

To test WebSocket, use the following endpoint:

ws://ip:port/api/v1/utils/echo-client/

Paste the response in an HTML file and open it in a browser.

🚀 Running the Project

To start the FastAPI server, run:

uvicorn app.main:app --reload

📑 Access API Documentation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors