Note
Ubuntu (click here)
sudo apt install docker-compose
Windows (click here)
choco install docker-compose
Mac (click here)
brew install docker-compose
docker-compose up -d
This command will launch a postgres container configured to run the application database.
Ubuntu (click here)
sudo apt install python3.12-venv
python3 -m venv .venv
source .venv/bin/activate
npm i
pip install -r requirements.txt
Windows
pip install virtualenv
python -m venv .venv
.\.venv\Scripts\Activate
npm i
pip install -r requirementsWindows.txt
Mac
brew install python@3.12
python3 -m venv .venv
source .venv/bin/activate
npm i
pip install -r requirements.txt
Important
To configure other requirements and dependencies run this:
npm install
alembic init alembic
sqlalchemy.url = postgresql://postgres:password@localhost/neurahive
Important
After you set alembic, go to the alembic directory and paste in the file env.py this:
from logging.config import fileConfig
from sqlalchemy import engine_from_config
from sqlalchemy import pool
from alembic import context
from dotenv import load_dotenv
import os
from src.database.models import Base
load_dotenv()
#Configure environment variables
database_url = os.getenv('DATABASE_URL')
print(database_url)
if not database_url:
raise ValueError("DATABASE_URL nΓ£o encontrada no arquivo .env")
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
config.set_main_option("sqlalchemy.url", database_url)
# Interpret the config file for Python logging.
# This line sets up loggers basically.
if config.config_file_name is not None:
fileConfig(config.config_file_name)
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = Base.metadata
# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.
def run_migrations_offline() -> None:
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url,
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online() -> None:
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
connectable = engine_from_config(
config.get_section(config.config_ini_section, {}),
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
with connectable.connect() as connection:
context.configure(
connection=connection, target_metadata=target_metadata
)
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
alembic revision --autogenerate
alembic upgrade head
Important
If you need to delete database and create again run this command:
alembic stamp head --purge
export $(grep -v '^#' .env | xargs)
cd src
fastapi dev main.py --host 0.0.0.0
# Ubuntu
sudo apt install python3.12-venv
docker-compose up -d
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
export $(grep -v '^#' .env | xargs)
# Windows
pip install virtualenv
python -m venv .venv
.\.venv\Scripts\Activate
pip install -r requirements.txt
export $(grep -v '^#' .env | xargs)
# Mac
brew install python@3.12
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
export $(grep -v '^#' .env | xargs)
alembic init alembic
alembic revision --autogenerate
alembic upgrade head
alembic stamp head --purge
Directory | Description |
---|---|
π src/ | Main project directory, containing dependencies, source code, and media files. |
π src/auth | Authentication-related files. |
π src/database | Database-related code. |
π src/modules | All project modules and communication with external services. |
π src/routers | Service requests (backend server and API) via GET, POST, DELETE, and UPDATE methods. |
π src/schemas | Project schemas and data models. |
π src/tests | Project tests. |
π .env.example | Example environment variables file. |
π .gitignore | Specifies files and directories to be ignored by Git. |
π alembic.ini | Configuration file for Alembic migrations. |
π changelog-template.hbs | Template file for generating changelogs. |
π CHANGELOG.md | File containing the project's change history. |
π commitlint.config.cjs | Configuration file for commit message linting. |
π docker-compose.yml | Docker Compose configuration file. |
π package.json | Contains project dependencies and scripts for package management. |
π pyproject.toml | Configuration file for Python dependencies and tools. |
π README.md | Main documentation file for the project. |
π requirements.txt | List of dependencies required to run the project. |
π requirementsWindows.txt | List of dependencies for running the project on Windows. |
π version.json | File containing versioning information for the project. |