A Django Rest Framework (DRF) API for managing investment accounts. Allows users to belong to multiple accounts with different permission levels, including view-only, CRUD, and post-only access. The API also features an admin endpoint for viewing user transactions with a date range filter, nesting their total balance.
- User Permissions: Defines permissions for users on investment accounts, including view-only, full CRUD, and transaction posting.
- Admin Endpoint: Provides detailed transaction information with a nested sum of the user's total balance and a date range filter.
- Unit Tests: Comprehensive unit tests to ensure API functionality.
- GitHub Actions: Automatic execution of unit tests using GitHub Actions.
https://dbdiagram.io/d/GOInvest-66dd50e4eef7e08f0e06a8c7
- Python 3.8+
- Django 4.0+
- Django Rest Framework 3.12+
-
Clone the Repository
git clone https://github.com/Gad-Ongoro/go_invest.git cd server
-
Create and Activate a Virtual Environment
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install Dependencies
pip install -r requirements.txt
-
Apply Migrations
python manage.py migrate
-
Create a Superuser
python manage.py createsuperuser
-
Run the Development Server
python manage.py runserver
-
List Investment Accounts
/api/investment-accounts/
-
Retrieve Investment Account
/api/investment-accounts/{id}/
-
List Create Transactions
/api/investment-accounts/<uuid:account_id>/transactions/
-
Retrieve, Update, Delete Transaction
/api/investment-accounts/<uuid:account_id>/transactions/{id}/
-
User Transactions with Balance
GET /api/admin/users/<uuid:user_id>/transactions/
- Query Parameters:
user_id
: ID of the userstart_date
: Start date of the range (YYYY-MM-DD)end_date
: End date of the range (YYYY-MM-DD)
- Query Parameters:
- Investment Account 1: View-only rights; users cannot make transactions.
- Investment Account 2: Full CRUD permissions.
- Investment Account 3: Can post transactions but cannot view them.
Tests are located in the investment_accounts/tests
directory. To run the tests:
python manage.py test
A GitHub Action is set up to automatically run unit tests on every push and pull request. You can find the configuration in .github/workflows/run-tests.yml
.
-
Fork the Repository
-
Create a Feature Branch
git checkout -b feature/your-feature
-
Commit Your Changes
git commit -m "Add new feature"
-
Push to the Branch
git push origin feature/your-feature
-
Create a Pull Request
Go to the repository on GitHub and create a pull request.