This is the official backend service for THE 404 AI. It is a high-performance API built with Python and FastAPI that handles all server-side logic, including user authentication (registration and login), database interactions, and providing data to the frontend application.
- Python (v3.10 or newer recommended)
pippackage managervirtualenvfor creating isolated Python environments (highly recommended)
Follow these steps to get the backend server running on your local machine.
This step creates an isolated environment for the project's dependencies.
Create the virtual environment python -m venv venv
Activate the environment (command differs by OS/shell) On Windows (PowerShell): .\venv\Scripts\activate
On Windows (Command Prompt): .\venv\Scripts\activate.bat
On macOS and Linux: source venv/bin/activate
First, ensure you have a requirements.txt file by running pip freeze > requirements.txt inside your activated virtual environment. Then, install all the required Python packages.
pip install -r requirements.txt
Start the FastAPI server using uvicorn. The --reload flag enables hot-reloading, which automatically restarts the server when you make code changes.
By default, the API will be available at http://127.0.0.1:8000.
- CORS Configuration: If you change the port or domain of your frontend application, remember to update the
originslist in theCORSMiddlewareconfiguration insidemain.py. - Database: This project uses a local
404_ai.dbSQLite database file, which is automatically created when the server first runs. This file is excluded from Git via.gitignore. - Password Hashing: Passwords are securely hashed using
bcrypt. Due to a known limitation of thebcryptalgorithm, passwords are truncated to 72 bytes before hashing.