Source code for aleonard.us API
Welcome to the aleonard.us-api repository! This project provides a robust and scalable API for managing users, built with FastAPI and SQLAlchemy. The API supports user creation, retrieval, updating, and deletion with comprehensive validation and error handling.
- User Management: Create, retrieve, update, and delete users.
- Authentication: Secure endpoints with JWT-based authentication.
- Data Validation: Ensure data integrity with Pydantic models.
- Testing: Comprehensive test suite using pytest.
- Documentation: Automatic API documentation with Swagger UI.
- Backend Framework: FastAPI
- ORM: SQLAlchemy
- Database: PostgreSQL (or another as specified)
- Authentication: JWT (JSON Web Tokens)
- Testing: pytest
- Others: Pydantic, Alembic for migrations, etc.
- Python: 3.13 or higher
- pip: Package installer for Python
- virtualenv: (optional but recommended)
-
Clone the Repository
git clone https://github.com/ALeonard9/aleonard.us-api.git cd aleonard.us-api
-
Create Virtual Environment
python -m venv .venv source .venv/bin/activate
-
Install Dependencies
pip install -r requirements/base.txt
pip install -r requirements/dev.txt
pip install -r requirements/test.txt
-
Set Environment Variables
Create a
.env
file in the root directory and add the following:LZ=<your landing zone> ENV=dev LOG_LEVEL=INFO JWT_SECRET_KEY=<your secret key> ADMIN_DISPLAY_NAME=<your display name> ADMIN_PASSWORD=<your api password> ADMIN_EMAIL=<your email> COMPOSE_PROJECT_NAME=phoenix_dev POSTGRES_USER=functional_data_api_dev POSTGRES_PASSWORD=<your database password> POSTGRES_HOST=m3_phoenix_db_dev POSTGRES_DB=phoenix POSTGRES_EXPOSED_PORT=5430 POSTGRES_PORT=5432 POSTGRES_CONNECTION_PORT=5432 LOKI_URL=http://loki:3100
-
Run Migrations
Apply database migrations using Alembic to set up the database schema:
alembic upgrade head
-
Run the Application
Start the FastAPI application:
uvicorn app.main:app --reload
The API will be available at
http://localhost:8000
. -
Access the API Documnentation
Open your browser and go to
http://localhost:8000/docs
to view the Swagger UI documentation.
Ensure that you have a test database set up in your .env
file. The test database should have the same schema as the development database.
Run the following command to execute the test suite:
pytest
This repository uses pre-commit hooks to automatically enforce code quality:
- Linting and Styling: Tools like
pylint
andblack
ensure consistent styling. - Consistency Checks: Configuration checks help maintain best practices.
Our CI pipeline leverages GitHub Actions to ensure code quality and security:
- Testing: Automated tests are run on every push and pull request.
- Security Scans:
- Snyk SCA Scan: Scans for vulnerabilities in dependencies.
- Snyk SAST Scan: Scans for vulnerabilities in the codebase.
- CodeQL: Provides secret scanning and vulnerability detection.
Contributions are welcome. Please fork the repository and submit a pull request.
This project is open source and available under the GNU General Public License v3.0. See the LICENSE file for more information.