Skip to content

DevPeter1454/Alpha-Eye-Final-Repo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alpha Eye BE

To view Backend Deployment Repo

Blue Rocket with FastAPI Logo as its window. There is a word FAST written

Python FastAPI Pydantic PostgreSQL Redis Docker NGINX

0. About

Alpha-Eye-BE makes use of an extendable async API using FastAPI, Pydantic V2, SQLAlchemy 2.0 and PostgreSQL:

  • FastAPI: modern Python web framework for building APIs
  • Pydantic V2: the most widely used data Python validation library, rewritten in Rust (5x-50x faster)
  • SQLAlchemy 2.0: Python SQL toolkit and Object Relational Mapper
  • PostgreSQL: The World's Most Advanced Open Source Relational Database
  • Redis: Open source, in-memory data store used by millions as a cache, message broker and more.
  • Docker Compose With a single command, create and start all the services from your configuration.

1. Features

  • ⚡️ Fully async
  • 🚀 Pydantic V2 and SQLAlchemy 2.0
  • 🔐 User authentication with JWT
  • 🍪 Cookie based refresh token
  • 🏬 Easy redis caching
  • 👜 Easy client-side caching
  • 👮 FastAPI docs behind authentication and hidden based on the environment
  • 🦾 Easily extendable
  • 🤸‍♂️ Flexible
  • 🚚 Easy running with docker compose

2. Contents

  1. About
  2. Features
    1. To Do
  3. Contents
  4. Prerequisites
    1. Environment Variables (.env)
    2. Docker Compose
    3. From Scratch
  5. Usage
    1. Docker Compose
    2. From Scratch
      1. Packages
      2. Running PostgreSQL With Docker
      3. Running Redis with Docker
      4. Running the API
    3. Creating the first superuser
    4. Database Migrations
  6. Extending
    1. Project Structure
    2. Database Model
    3. SQLAlchemy Models
    4. Pydantic Schemas
    5. Alembic Migrations
    6. CRUD
    7. Routes
      1. Paginated Responses
      2. HTTP Exceptions
    8. Caching
    9. More Advanced Caching
    10. ARQ Job Queues
    11. Rate Limiting
    12. JWT Authentication
    13. Running
    14. Create Application
  7. Running in Production
    1. Uvicorn Workers with Gunicorn
    2. Running With NGINX
      1. One Server
      2. Multiple Servers
  8. Testing
  9. Contributing
  10. References
  11. License
  12. Contact

3. Prerequisites

3.0 Start

Start by using the template, and naming the repository to what you want.

To access all backend codes


cd Backend

clicking use this template button, then create a new repository option

Then clone the repository to your local machine:

Warning

Do not forget to place docker-compose.yml and Dockerfile in the root folder, while .env should be in the src folder.

3.1 Environment Variables (.env)

ENVIRONMENT can be one of local, staging and production, defaults to local, and changes the behavior of api docs endpoints:

  • local: /docs, /redoc and /openapi.json available
  • staging: /docs, /redoc and /openapi.json available for superusers
  • production: /docs, /redoc and /openapi.json not available

3.2 Docker Compose (preferred)

To do it using docker compose, ensure you have docker and docker compose installed, then: While in the base project directory (FastAPI-boilerplate here), run:

docker compose up

You should have a web container, postgres container, a worker container and a redis container running. Then head to http://127.0.0.1:8000/docs.

3.3 From Scratch

Test using poetry Install poetry:

pip install poetry

Install dependencies:

poetry-add-requirements. txt

Test using venv

python -m venv venv
source venv/bin/activate
```sh
```sh
pip install -r requirements.txt

To run

uvicorn app.main:app --reload

4. Usage

4.1 Docker Compose

If you used docker compose, your setup is done. You just need to ensure that when you run (while in the base folder):

docker compose up

So you may skip to 5. Extending.

4.2 From Scratch

4.2.1. Running the API

While in the root folder, run to start the application with uvicorn server:

poetry run uvicorn src.app.main:app --reload

Tip

The --reload flag enables auto-reload once you change (and save) something in the project

5.2 Database Model

Create the new entities and relationships and add them to the model

5.2.1 Token Blacklist

Note that this table is used to blacklist the JWT tokens (it's how you log a user out)

5.3 SQLAlchemy Models

Warning

Note that since it inherits from Base, the new model is mapped as a python dataclass, so optional attributes (arguments with a default value) should be defined after required attributes.

5.4 Running

If you are using docker compose, just running the following command should ensure everything is working:

docker compose up

If you are doing it from scratch, ensure your postgres and your redis are running, then while in the root folder, run to start the application with uvicorn server:

poetry run uvicorn src.app.main:app --reload

Frontend codes

React + Vite


React.js + Vite + Tailwind CSS Web App

This project is a web application built with React.js, Vite, and Tailwind CSS. It provides a fast and efficient development environment for building modern web applications with a focus on performance and developer experience.

Features

  • React.js: A JavaScript library for building user interfaces.
  • Vite: A build tool that focuses on speed and development experience for web projects.
  • Tailwind CSS: A utility-first CSS framework for rapidly building custom designs.

Getting Started

Prerequisites

Before running the project, make sure you have Node.js and npm installed on your machine.

Installation

  1. Clone the repository:
 git clone 
  1. Navigate into the project directory:
cd Frontend
  1. Install dependencies:
 npm install

Development

To start the development server, run:

bash npm run dev

This will start the Vite development server and open your default web browser to display the web application. The development server supports hot module replacement for fast development iteration.

Building for Production

To build the project for production, run:

bash npm run build

This command will build the project optimized for production deployment. The output will be generated in the dist directory.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvement, feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements


Currently, two official plugins are available:

Mobile The mobile application is developed with Flutter and is located in the mobile directory. To run the mobile app, navigate to the mobile directory and fetch the dependencies:

To run the mobile app

cd Mobile

to get all dependencies

flutter pub get

to run the application

flutter run

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors