Skip to content

xcaim04/prolog-editor

Repository files navigation

Prolog Editor API

This is a FastAPI-based REST API for a Prolog Editor. It provides functionalities for user authentication, managing user history, and logging.

Features:

  • User Authentication (Registration, Login)
  • User History Management (SQLite)
  • Prolog Query Execution

Technologies:

  • Backend: FastAPI
  • Database: SQLite (for history, logs, users)
  • ORM: SQLAlchemy
  • Migrations: Alembic
  • Authentication: JWT
  • Prolog Execution: SWI-Prolog

Setup:

1. Build and run with Docker Compose:

Ensure you have Docker and Docker Compose installed.

docker-compose build
docker-compose up

This will build the Docker image, install SWI-Prolog and Python dependencies, and start the FastAPI application.

2. Database Migrations (inside the running container):

Before running migrations, you might need to execute alembic revision --autogenerate -m "Initial database setup" if this is the first time you are setting up the database. Otherwise, you can just apply existing migrations.

To run alembic commands, you need to execute them inside the api container:

docker-compose exec api alembic upgrade head

Accessing the API:

The API will be accessible at http://localhost:8000. You can access the API documentation (Swagger UI) at http://localhost:8000/api/v1/docs.

Environment Variables:

Copy the .env.example file to .env and set your secret key:

cp .env.example .env

Example .env content:

SECRET_KEY="your_super_secret_key_here"
DATABASE_URL="sqlite:///./sql_app.db"

API Endpoints:

  • Authentication (/api/v1/auth):

    • /token: Obtain JWT token for authentication.
  • Users (/api/v1/users):

    • /: Register a new user.
    • /{user_id}: Get user details.
  • Prolog (/api/v1/prolog):

    • /execute: Execute a Prolog query and save to history (requires authentication).
    • /history: Get user's Prolog query history (requires authentication).

Releases

No releases published

Packages

 
 
 

Contributors