Skip to content

global-torque/practical-example

Repository files navigation

Torque Practical Example

Tiny aiohttp API example for fund customization. This service is intentionally an unauthenticated demo: requests do not require auth headers, users, groups, permissions, tenants, or site scoping.

The app follows the local aiohttp_boilerplate structure used by the fund manager API: environment defaults live in app/config.py, routes are registered from app/routes.py, app/models.py defines the funds model, and views use the boilerplate app/DB pool conventions.

Endpoints

  • GET /v1.0/funds
  • POST /v1.0/funds
  • GET /v1.0/funds/export
  • GET /v1.0/funds/{slug}

Local Setup

Create a local PostgreSQL database:

createdb torque_practical_example

Install dependencies:

python -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txt -r requirements-dev.txt
cp .env.example .env

Run the API. Database settings use the same DB_* environment names as the fund manager API: DB_DATABASE, DB_USER, DB_PASSWORD, DB_HOST, and DB_PORT. Defaults point at local PostgreSQL database torque_practical_example with user/password postgres. make.sh sources .env before running commands.

./make.sh run-dev

Run tests and lint:

./make.sh test
./make.sh lint

Example Requests

curl http://localhost:8080/v1.0/funds
curl 'http://localhost:8080/v1.0/funds?search=income&limit=1&offset=0'
curl -OJ http://localhost:8080/v1.0/funds/export
curl http://localhost:8080/v1.0/funds/torque-income-fund

Create a fund:

curl -X POST http://localhost:8080/v1.0/funds \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Torque Opportunity Fund",
    "slug": "torque-opportunity-fund",
    "description": "Example opportunistic fund.",
    "status": "open",
    "targetRaise": 2500000,
    "capacityLimit": 5000000,
    "currentNav": 10.75,
    "totalShares": 250000,
    "showOnDashboard": true
  }'

Docker Compose

docker compose up --build

The API will be available at http://localhost:8080.

TODO Before Production

  • Add authentication and authorization.
  • Add tenant or site scoping if the product needs it.
  • Replace the demo schema loader with real migration management.
  • Add production observability, backup, and operational controls.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors