This is a FastAPI-based REST API for a Prolog Editor. It provides functionalities for user authentication, managing user history, and logging.
- User Authentication (Registration, Login)
- User History Management (SQLite)
- Prolog Query Execution
- Backend: FastAPI
- Database: SQLite (for history, logs, users)
- ORM: SQLAlchemy
- Migrations: Alembic
- Authentication: JWT
- Prolog Execution: SWI-Prolog
Ensure you have Docker and Docker Compose installed.
docker-compose build
docker-compose upThis will build the Docker image, install SWI-Prolog and Python dependencies, and start the FastAPI application.
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 headThe API will be accessible at http://localhost:8000. You can access the API documentation (Swagger UI) at http://localhost:8000/api/v1/docs.
Copy the .env.example file to .env and set your secret key:
cp .env.example .envExample .env content:
SECRET_KEY="your_super_secret_key_here"
DATABASE_URL="sqlite:///./sql_app.db"
-
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).