aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 4921d358504ae896e72ce801d2b87462293cad07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Virtual Energy Trading App

## (Questionable) Design Decisions

This is just a section to state that I am aware these design decisions are questionable and not good practices. These decisions were made for the sake of simplicity and ease of development.

### Authentication

There is no real-authentication implemented. There is a dummy user in the database, and all the bids are attached to this user. On the web-interface, there is no login functionality. All bids are submitted as if they were made by the dummy user.

In production, rather than specifying the user ID as part of the bid, the backend should authenticate the user and associate the bid with the authenticated user's ID.

### Caching

In production, rather than calling the gridstatus API to get the market data, the backend should cache the data locally and update it periodically.

Also, rather than using the simple in-memory cache, the backend should use a more robust caching mechanism such as Redis or Memcached.

### Bid Management

Currently there is a cron job running every hour to check the bids in the database and then process them. In this process the market data is fetched in real-time from the gridstatus API. Ideally, the database is updated with the latest market data before processing the bids. That way the cron job can simply process the bids.

## Project Structure

```
/client         # React Frontend
/server         # Python Backend
/tests          # Tests if I ever get to them
```

## Backend

### FastAPI Server

#### Market Data Service

* Fetch from GridStatus API
    * Real-time prices
    * Day-ahead market prices
    * Load/demand data
* API Endpoints
    * `GET /market/day-ahead`
    * `GET /market/real-time`
    * `GET /market/load`

#### Bid Management

* API Endpoints
    * `POST /bids`
    * `GET /bids`
    * `DELETE /bids/{bid_id}`

#### Profit et Loss Simulation

* API Endpoints
    * `GET /trader/pnl`