A simple Todo API with user authentication built using FastAPI and SQLAlchemy.
- Installation
- Configuration
- Database Setup
- Running the Application
- API Documentation
- Project Structure
-
Clone the repository:
git clone https://github.com/TomasDmArg/rn1-back/ cd rn1-back -
Create a virtual environment:
python -m venv venv -
Activate the virtual environment:
- On Windows:
venv\Scripts\activate - On macOS and Linux:
source venv/bin/activate
- On Windows:
-
Install the required packages:
pip install -r requirements.txt
- Create a
.envfile in the root directory of the project. - Add the following environment variables to the
.envfile:DB_HOST=your_database_host DB_NAME=your_database_name DB_USER=your_database_user DB_PASSWORD=your_database_password SECRET_KEY=your_secret_key_for_jwt
- Connect to your MySQL server.
- Create a new database:
CREATE DATABASE your_database_name;
- Use the provided SQL script to create the necessary tables:
mysql -u your_username -p your_database_name < /app/utils/create_tables.sql
- Ensure your virtual environment is activated.
- Start the FastAPI server:
uvicorn app.main:app --reload - The API will be available at
http://localhost:8000
- Swagger UI (interactive documentation):
http://localhost:8000/docs - ReDoc (alternative documentation):
http://localhost:8000/redoc - OpenAPI JSON:
http://localhost:8000/openapi.json
todo-api/
├── app/
│ ├── auth/
│ │ └── jwt_handler.py
│ ├── crud/
│ │ ├── todo.py
│ │ └── user.py
│ ├── models/
│ │ ├── todo.py
│ │ └── user.py
│ ├── routes/
│ │ ├── todo.py
│ │ └── user.py
│ ├── schemas/
│ │ ├── todo.py
│ │ └── user.py
│ ├── utils/
│ │ └── create_tables.sql
│ ├── database.py
│ └── main.py
├── requirements.txt
└── README.md
This project is licensed under the MIT License - see the LICENSE.md file for details.