Capivara API backend python
Find a file
Jonatas Oliveira 257aad6920
All checks were successful
ci/woodpecker/push/pipeline/1 Pipeline was successful
ci/woodpecker/push/pipeline/2 Pipeline was successful
ci/woodpecker/cron/pipeline/1 Pipeline was successful
ci/woodpecker/cron/pipeline/2 Pipeline was successful
feat: add goal and list. mail smtp configure. cielo client configured
2026-01-07 17:01:41 +01:00
.woodpecker build: add cron event 2026-01-01 17:03:04 +01:00
app feat: add goal and list. mail smtp configure. cielo client configured 2026-01-07 17:01:41 +01:00
changelog.d feat: improve user api and settings api 2025-12-10 09:21:20 +01:00
contrib feat: integrate with correiosbr api (#1080) 2023-09-13 12:04:00 +02:00
email-templates fix: reset email message 2025-10-07 12:13:18 +02:00
hurl_tests refactor: optimize queries and add username-email to login option 2026-01-06 15:23:53 +01:00
legacy tests: fix woodpecker steps and fix broken tests 2025-12-23 07:34:57 +01:00
migrations feat: add goal and list. mail smtp configure. cielo client configured 2026-01-07 17:01:41 +01:00
scripts feat: add goal and list. mail smtp configure. cielo client configured 2026-01-07 17:01:41 +01:00
static chore: move app to root 2023-06-20 19:12:19 +02:00
tests feat: add goal and list. mail smtp configure. cielo client configured 2026-01-07 17:01:41 +01:00
.gitignore feat: add user management improve 2025-12-15 16:28:39 +01:00
.pre-commit-config.yaml feat: add goal and list. mail smtp configure. cielo client configured 2026-01-07 17:01:41 +01:00
.pyup.yml fix pyup 2020-11-09 16:22:14 -03:00
.safety-project.ini tests: improvement tests and lint 2025-12-08 08:30:34 +01:00
__init__.py chore: move app to root 2023-06-20 19:12:19 +02:00
alembic.ini feat: refactor settings table (#1163) 2024-09-26 14:20:34 +02:00
app.json feat: add update order task 2025-06-05 08:59:48 +02:00
CHANGELOG.md build: package version 0.4.0 2025-11-18 15:33:44 +01:00
config.py feat: add goal and list. mail smtp configure. cielo client configured 2026-01-07 17:01:41 +01:00
Dockerfile feat: add mailjet provider and refactor send_mail function 2025-06-12 10:09:11 +02:00
LICENSE Initial commit 2020-05-31 20:28:48 -03:00
lint_output.txt tests: improvement tests completition 2025-12-23 19:02:28 +01:00
main.py feat: add goal and list. mail smtp configure. cielo client configured 2026-01-07 17:01:41 +01:00
Makefile refactor: refactor uow and bootstrap 2025-12-28 14:49:47 +01:00
nixpacks.toml Master (#1067) 2023-08-25 14:58:00 +02:00
Procfile feat: add update order task 2025-06-05 08:59:48 +02:00
pyproject.toml refactor: refactor uow and bootstrap 2025-12-28 14:49:47 +01:00
README.md tests: improvement tests completition 2025-12-23 14:17:33 +01:00
settings.toml tests: refactor tests with pytest-mock 2025-12-27 17:23:36 +01:00
setup_test_users.py feat: add goal and list. mail smtp configure. cielo client configured 2026-01-07 17:01:41 +01:00
sonar-project.properties build: add exception in test for sonarcloud 2025-06-11 16:48:12 +02:00
test_error.txt tests: improvement tests completition 2025-12-23 19:02:28 +01:00
test_error_2.txt tests: improvement tests completition 2025-12-23 19:02:28 +01:00
test_error_3.txt tests: improvement tests completition 2025-12-23 19:02:28 +01:00
test_output.txt feat: add goal and list. mail smtp configure. cielo client configured 2026-01-07 17:01:41 +01:00
uv.lock feat: improve user api and settings api 2025-12-10 09:21:20 +01:00

Quality Gate Status Coverage status-badge

Capicart Backend

Pre-requirements Install Technologies

Pre-requirements

  • Docker and docker-compose
  • Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
  • Repository clone
git clone https://github.com/jonatasoli/fast-ecommerce-back.git
cd fast-ecommerce-back
docker-compose up -d
  • Virtualenv with uv
uv python install

Create Virtualenv and install requirements

uv sync

Required Environment Variables

Before starting the project, configure the following environment variables in the .secrets.toml file:

Minimum Required Configuration

[default]
# Database (required)
DATABASE_URL="postgresql+psycopg://user:password@localhost/database_name"
DATABASE_URI="postgresql+asyncpg://user:password@localhost/database_name"

# Security (required)
SECRET_KEY="your_random_secret_key_here"  # Use a strong random key
CONFIRMATION_KEY="your_random_confirmation_key_here"  # Use a strong random key
CAPI_SECRET="your_base64_encryption_key_here"  # Generate with: python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"

# Redis (required if using cache/sessions)
REDIS_URL="redis://:@localhost:6379"
REDIS_DB=0

# Message Broker (required if using queues)
BROKER_URL="amqp://guest:guest@localhost:5672//"

# Environment
ENVIRONMENT="development"  # or "production", "testing"

Additional Configuration (Optional)

The following variables can be configured later or left with default values:

  • Upload/Storage: ENDPOINT_UPLOAD_CLIENT, BUCKET_NAME, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
  • Payments: STRIPE_SECRET_KEY, MERCADO_PAGO_ACCESS_TOKEN, PAYMENT_GATEWAY
  • Logistics: CORREIOSBR_USER, CORREIOSBR_PASS, CORREIOSBR_API_SECRET
  • Notifications: SENDGRID_API_KEY, EMAIL_FROM
  • reCAPTCHA: RECAPTCHA_PROJECT_ID, RECAPTCHA_SITE_KEY, RECAPTCHA_SCORE_THRESHOLD
  • Frontend/CORS: FRONTEND_URL, CORS_ORIGINS

Note

: The system has fallback to environment variables when it doesn't find configurations in the database. Configurations can be managed via the admin panel after the first initialization.

Install

alembic upgrade head
or
make upgrade

Run project

uvicorn main:app --reload --host 0.0.0.0 --port 8001
or
make run

Tests

  • Create postgres database "test"
  • Enter in app directory
  • Run tests
make test

Domains

  • User: Handles all user management operations, such as user registration, login, and profile management.
  • Direct Sales: Manages operations related to selling a product directly, bypassing any intermediary.
  • Payment: Handles all payment-related operations, including processing payments through various methods such as credit cards, PIX, boleto, and installment plans.
  • Freight: Responsible for managing operations related to shipping, delivery, and logistics.
  • Order: Manages operations related to processing and fulfilling customer orders, including order creation, tracking, and status updates.
  • Notification: Handles operations related to user notifications, including sending out notifications for order updates, promotions, and other relevant information.
  • Product: Manages all aspects related to products, including product creation, editing, categorization, and attributes.
  • Catalog: Handles the listing and presentation of products, providing features such as search, filtering, and sorting for users to browse and explore.
  • Cart: Deals with operations related to the shopping cart, allowing users to add, remove, and modify items before proceeding to checkout.
  • Inventory: Manages the control and tracking of product inventory, including stock levels, replenishment, and availability.
  • Reviews: Handles customer reviews, comments, and ratings for products, allowing users to share their experiences and opinions.
  • Coupons: Manages promotional campaigns, discounts, and coupon codes to attract and incentivize customers.
  • Reports: Provides reporting and analytics capabilities, allowing stakeholders to gain insights into sales, customer behavior, and other relevant metrics.
  • Sales: Handles integrations with sales tools and platforms, facilitating processes such as order synchronization, inventory management, and sales data analysis.
  • Campaign: Manages integrations with marketing tools and platforms, enabling targeted marketing campaigns, customer segmentation, and automation.
  • Crowdfunding: Manages crowdfunding projects, tiers, contributions, goals, and leaderboards. Handles project creation, backer contributions, payment processing, and project statistics tracking.
  • Settings: Manages system-wide configuration settings stored in the database, including payment gateways, CDN, logistics, notifications, mail, and bucket configurations. Provides admin interface for dynamic settings management with encryption for sensitive data.

Getting Started

  • Create Roles in database |id|status|role| |1|active|ADMIN| |2|active|USER| |3|active|AFFIALIATE|

  • Create user with route -> /user/signup

  • Enter in database and change role_id from 2 to 1

  • Create credit card config with route -> /create-config

[!info] Credit card config need tax installment fee, min and max installments

  • Create product with route -> create_product suggest test product
{
  "name": "Test",
  "uri": "/test",
  "price": 10000,
  "direct_sales": 0,
  "description": {"content": "Teste", "composition": "test composition", "how_to_use": "test how to use"},
  "image_path": "https://i.pinimg.com/originals/e4/34/2a/e4342a4e0e968344b75cf50cf1936c09.jpg",
  "installments_config": 1,
  "category_id": 1,
  "discount": 100,
  "sku": "sku0"
}

Integrations

  • Sendgrid
  • Pagarme
  • Mercado Pago
  • Stripe
  • Correios
  • Tallos

API Structure

  • app -- infra -- db -- enpoints -- schemas -- redis -- gateways -- payment -- mail -- whatsapp -- workers -- entities -> Business rules -- user -- service -> application orchestration -- repository -> queries -- direct_sales -- payment -- order -- freight -- infra -- infra -- notification -- product -- catalog -- cart -- inventory -- coupons -- reports -- sales -- campaign
  • tests

Technologies