This is the backend of the OnlyBrands platform, just do database stuff so far
- you will need to download and setup postgres locally (look at below)
- create a virtual environment and install the dependencies with
make install
- create a
.env
file in the root of the project with the following content:
MASTER_TOKEN=your_master_token
- run
make reset-db
, this resets the database - run
make run
, this starts the server - you can now access the API at
http://locahost:8000/docs
- you can use the master token to access the API, or create a new user and use the token generated for that user
- todo: tests
- We use Ruff to lint and format
- run
make lint
to lint the code - run
make format
to format the code
Here are some of the main endpoints of the application:
POST /create_bid/
: Create a new bid. RequiresBidCreate
data and thecurrent_user
token.POST /accepted_bid/
: Accept a bid. RequiresBid
data and thecurrent_user
token.POST /complete_bid/
: Complete a bid. RequiresBid
data and thecurrent_user
token.DELETE /delete_bid/
: Delete a bid. RequiresBid
data and thecurrent_user
token.POST /create_influencer/
: Create a new influencer. RequiresInfluencerCreate
data and thecurrent_user
token.DELETE /delete_influencer/
: Delete an influencer. RequiresInfluencer
data and thecurrent_user
token.POST /create_brand/
: Create a new brand. RequiresBrandCreate
data and thecurrent_user
token.DELETE /delete_brand/
: Delete a brand. RequiresBrand
data and thecurrent_user
token.
- id: Integer, Primary Key
- name: String
- email: String
- created_at: DateTime
- id: Integer, Primary Key
- name: String
- email: String
- created_at: DateTime
- id: Integer, Primary Key
- influencer_id: Integer, Foreign Key (Influencer)
- brand_id: Integer, Foreign Key (Brand)
- created_at: DateTime
- status: String
install postgres server dev
sudo apt install postgresql-server-dev-all
you can check the version
psql --version
login to postgres
sudo -u postgres psql postgres
you might have to login to the postgres user first
psql
CREATE USER postgres;
ALTER USER postgres WITH SUPERUSER;
change your password for postgres
\password postgres
(then enter "waffle" twice) or whatever you want the password to be
exit the postgres user
\q
You can avoid having to enter the password for postgres by setting up a default password
echo "localhost:5432:*:postgres:waffle" >> .pgpass
chmod 600 .pgpass
you can then connect to the database like this
psql -h localhost -U postgres
\q
`