Skip to content

bfabian333/fastorders-api

 
 

fastorders-api


Logo

FastOrders API

FastOrders API
Explore the docs »

Table of Contents
  1. About the Project
  2. Getting Started
  3. Usage
  4. Testing
  5. Contributing
  6. Security
  7. Code of Conduct
  8. License
  9. Contact

About the Project

Project

FastOrders API is a RESTful API that handles order management. This backend project is a FastAPI-based template designed to serve as a robust, reliable, and RESTful API backend. It is crucial for facilitating user authentication, real-time monitoring, data processing, and an advanced alerting system. By leveraging the principles of RESTful architecture, this API ensures standardized communication and a scalable, maintainable infrastructure for the associated mobile application. This project is not only vital for the functionality it provides but also for ensuring the scalability and maintainability of the overall solution.

(back to top)

Built With

This project is built using a suite of modern, powerful technologies and frameworks to ensure high performance, ease of development, and robustness:

Components

The system is composed of the following main components, each playing a crucial role in providing a scalable, maintainable, and robust application:

  • FastAPI Backend: Serves as the core of the RESTful API, handling incoming HTTP requests, processing data, and sending responses. It's designed for high performance and encourages standard API development practices.
  • PostgreSQL: PostgreSQL is used for structured relational data storage.
  • JWT Authentication: Implements secure authentication mechanisms using JSON Web Tokens (JWT), ensuring secure access to the API.

This project adheres to RESTful design principles, ensuring an intuitive and standard approach to API development. This design facilitates easy integration, scalability, and interaction with various clients, including web and mobile applications. The API provides clear, resource-oriented URLs, uses HTTP response codes to indicate API errors, and employs JWT for secure, stateless authentication.

Language & Core Tools

Python Pydantic Starlette Uvicorn Beanie Beanie HTML5 CSS3 Pytest

Development & Code Quality

Ruff MyPy pre-commit-shield GitHub Actions Dependabot Git GitHub License: MIT Docker

đŸ›¢Database & Persistence

PostgreSQL MongoDB JWT

Environment & IDE

Visual Studio Code PyCharm Markdown Swagger UI

(back to top)

Getting started

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/jpcadena/fastorders-api.git
  2. Change the directory to root project

    cd fastorders-api
  3. Create a virtual environment named .venv in the working directory

    uv venv
  4. Activate environment in Windows

    .\venv\Scripts\activate
  5. Activate environment in macOS or Linux

    source venv/bin/activate
  6. Update project's environment by syncing all of its dependencies and installing them

    uv sync

(back to top)

Usage

  1. Execute with console

    python main.py

(back to top)

Testing

  1. Running tests:

    To run all tests, you can run the following command in the root directory of the project:

    pytest .
    pytest tests/ --cov=src --cov-report=term-missing
  2. Running a specific test:

    If you want to run a specific test, you can do so by specifying the file and test name. For example, the following command will only run the test_get_users test in the test_main.py file:

    pytest tests/test_main.py::test_get_users
  3. Understanding test results:

    Pytest will provide a summary of the test results in the console. It will tell you how many tests passed and how many failed. For each failed test, Pytest will provide a detailed error message that can help you identify what went wrong.

  4. Writing new tests:

    When you add new features to the application, you should also write corresponding test cases. Each test case should be a function that starts with the word 'test.' Inside the function, you can use assert statements to check that your code is working as expected. For example:

    from src.infrastructure.models import User
    from src.infrastructure.services.user_service import add_user
    
    
    def test_add_user():
        user: User = add_user("testuser", "testpass")
        assert user.name == "testuser"
        assert user.password == "testpass"

    This function tests that the add_user function correctly creates a new user with the given name and password.

Remember to update your tests whenever you update your code. Maintaining a comprehensive test suite will help ensure the reliability and robustness of your application.

(back to top)

Contributing

GitHub

Please read our contributing guide for details on our code of conduct, and the process for submitting pull requests to us.

(back to top)

Security

For security considerations and best practices, please refer to our Security Guide for a detailed guide.

(back to top)

Code of Conduct

We enforce a code of conduct for all maintainers and contributors. Please read our Code of Conduct to understand the expectations before making any contributions.

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Contact

  • LinkedIn

  • Outlook

(back to top)

About

The RESTful API for orders management using FastAPI

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 95.7%
  • HTML 1.4%
  • Dockerfile 1.3%
  • CSS 1.2%
  • Makefile 0.4%