Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
ea6873d
Updating refactor of markets handler.
pwdel Oct 20, 2025
b33a775
Adding working markets.
pwdel Oct 21, 2025
89b90bf
Updating internal.
pwdel Oct 21, 2025
56f7a05
Updating service
pwdel Oct 21, 2025
c2ee2b6
Updating and moving createmarket and responses.
pwdel Oct 21, 2025
884c65c
Fixed tests.
pwdel Oct 21, 2025
3649043
Refactoring listmarkets.go
pwdel Oct 21, 2025
8dfb453
Updating listmarketsbystatus.go
pwdel Oct 21, 2025
4b283db
All tests passing.
pwdel Oct 22, 2025
39966ba
Updating, refactoring all market operations as service with service i…
pwdel Oct 22, 2025
7865d74
Merge branch 'main' into fix/checkpoint20251020-80
pwdel Oct 22, 2025
b7740fc
Refactoring further.
pwdel Oct 22, 2025
2138f26
Update, attempting further fixes.
pwdel Oct 24, 2025
a153a1d
Merge branch 'main' into fix/checkpoint20251020-80
pwdel Oct 25, 2025
c4f4e8b
Update tests passing.
pwdel Oct 25, 2025
54da04e
Adding test coverage for user functions.
pwdel Oct 25, 2025
ecdc99c
Adding container test.
pwdel Oct 25, 2025
5728747
Updating further migrations.
pwdel Oct 27, 2025
1d0043b
Updating.
pwdel Oct 28, 2025
4861e02
Merge branch 'main' into fix/checkpoint20251020-80
pwdel Oct 28, 2025
3630676
Migrating users to service domain
pwdel Oct 28, 2025
e4e8262
Updating middleware, handlers, math directory and auth directory.
pwdel Oct 30, 2025
55d9f67
Update.
pwdel Oct 30, 2025
c55725c
Migrating bets
pwdel Oct 31, 2025
10b2819
Updating math domain positions, market models, container, position test.
pwdel Nov 3, 2025
b80d828
Update.
pwdel Nov 3, 2025
5531bf8
Refactoring position math so that it no longer touches GORM, using in…
pwdel Nov 5, 2025
731e88b
Updating
pwdel Nov 5, 2025
c2aee41
Updating per codeql recommendations.
pwdel Nov 5, 2025
24eb55f
Adding OpenAPI spec and starting to test payloads
pwdel Nov 7, 2025
d3378a7
Adjusting openapi to describe payload for /v0/markets/{id} more corre…
pwdel Nov 7, 2025
54647dd
Fixing market display page.
pwdel Nov 9, 2025
cffcea2
Fixing initial user balance.
pwdel Nov 10, 2025
399ee24
Updaitng buyshares to fit with openAPI layout.
pwdel Nov 10, 2025
0b53958
Taking non-needed logging out of the frontend.
pwdel Nov 10, 2025
6e913a8
Adding positions back in after reformatting.
pwdel Nov 10, 2025
9c8211e
Updating to fix leaderboards.
pwdel Nov 10, 2025
9364f70
Updating, fixing selling shares.
pwdel Nov 10, 2025
9eb132e
Update API camelCase
pwdel Nov 10, 2025
8778905
Updating, attempting to fix search
pwdel Nov 11, 2025
6d2e3ad
Bringing openapi up to date with what has been updated.
pwdel Nov 11, 2025
614ac21
Updating.
pwdel Nov 13, 2025
b7a2ec4
Updating and fixing search.
pwdel Nov 13, 2025
c6f5a57
Updating, attempting to resolve.
pwdel Nov 13, 2025
05c2a48
Adjusting status sigfigs to 2
pwdel Nov 13, 2025
7df41fe
Update with GIF
pwdel Nov 15, 2025
94dbfc1
Reverting back.
pwdel Nov 15, 2025
663b137
Merge branch 'main' into fix/checkpoint20251020-80
pwdel Nov 17, 2025
c8731cc
Attempting reduction in cyclomatic complexity.
pwdel Dec 2, 2025
4f7514c
Merge branch 'main' into fix/checkpoint20251020-80
astrosnat Dec 4, 2025
4f6869c
Single responsibility improvement of calculate metrics.
pwdel Dec 5, 2025
57dcc5d
Single responsibility fix.
pwdel Dec 5, 2025
73ba81c
added /v0/market/status as a shim over /v0/market/status/{status}, se…
raisch Dec 8, 2025
7e283cf
updated per code
raisch Dec 8, 2025
e27b685
added /v0/openapi.yaml to serve spec
raisch Dec 8, 2025
1e56d91
embedded swagger in backend; updated docs; still more to do there tho.
raisch Dec 8, 2025
58c90fa
removed comments
raisch Dec 8, 2025
af21cd8
fix 500 resp when market resolution time is too short.
raisch Dec 8, 2025
02a42f9
added analysis of API, updated openapi.yaml
raisch Dec 9, 2025
b93f490
updated
raisch Dec 9, 2025
91bdaf0
Attempted refactor system metrics towards OCP
pwdel Dec 10, 2025
e2196cf
Updating per no inverted dependencies principle
pwdel Dec 10, 2025
89917fc
Reducing cyclomatic complexity within security sanitizer
pwdel Dec 14, 2025
fff1225
Updating, targeting lower OCP on SearchMarketsHandler.
pwdel Dec 14, 2025
0b9fc59
Updating handler, service for cyclomatic complexity reduction.
pwdel Dec 14, 2025
88c8822
Adding gocache dir to gitignore to prevent super long git operations.
pwdel Dec 14, 2025
0260316
Updating for cyclomatic complexity.
pwdel Dec 14, 2025
e9e7b32
Lowering all non-test functions to cyclomatic complexity less than 8
pwdel Dec 15, 2025
29fd1eb
Reducing cyclomatic complexity.
pwdel Dec 15, 2025
f6224c1
Refactored bets/service.go to make each function a single concern, si…
pwdel Dec 15, 2025
1f69090
Adding focused unit tests to bets service domain.
pwdel Dec 16, 2025
3c259f7
initial redesign draft for /users/service.go (#603)
astrosnat Dec 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,11 @@ tmp/

# Apple Silicon Docker Compose Override
docker-compose.override.yml


# vs code
.vscode/

# Node modules
/frontend/node_modules/
node_modules/
59 changes: 54 additions & 5 deletions README/BACKEND/API/API-DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

SocialPredict is a prediction market platform where users can create markets, place bets on outcomes, and track their performance. The API provides endpoints for user management, market operations, betting, and administrative functions.

**Version**: 1.0.0
**License**: MIT
**Version**: 1.0.0
**License**: MIT
**Contact**: [SocialPredict Team](https://github.com/raisch/socialpredict)

## Authentication
Expand All @@ -34,13 +34,14 @@ Most endpoints require authentication using JWT Bearer tokens. To authenticate:

1. Obtain a JWT token by calling the `/v0/login` endpoint
2. Include the token in the `Authorization` header of subsequent requests:
```

```code
Authorization: Bearer <your-jwt-token>
```

## Base URL

```
```code
http://localhost:8080
```

Expand All @@ -60,6 +61,7 @@ Error responses follow this format:
```

Common HTTP status codes:

- **200**: Success
- **201**: Created
- **400**: Bad Request
Expand All @@ -81,6 +83,7 @@ These endpoints do not require authentication.
Get home page data and verify API connectivity.

**Response**:

```json
{
"message": "Data From the Backend!"
Expand All @@ -96,6 +99,7 @@ Get home page data and verify API connectivity.
Authenticate user and receive JWT token.

**Request Body**:

```json
{
"username": "string", // Required, 3-30 characters
Expand All @@ -104,6 +108,7 @@ Authenticate user and receive JWT token.
```

**Response** (200):

```json
{
"token": "jwt-token-string",
Expand All @@ -114,6 +119,7 @@ Authenticate user and receive JWT token.
```

**Error Response** (401):

```json
{
"error": "unauthorized",
Expand All @@ -130,6 +136,7 @@ Authenticate user and receive JWT token.
Get application setup and economics configuration.

**Response** (200):

```json
{
"marketcreation": {
Expand Down Expand Up @@ -168,6 +175,7 @@ Get application setup and economics configuration.
Get general application statistics.

**Response** (200):

```json
{
// Statistics object (structure varies)
Expand All @@ -179,6 +187,7 @@ Get general application statistics.
Get system performance and health metrics.

**Response** (200):

```json
{
// System metrics object (structure varies)
Expand All @@ -190,6 +199,7 @@ Get system performance and health metrics.
Get the global user leaderboard.

**Response** (200):

```json
{
// Global leaderboard object (structure varies)
Expand All @@ -205,6 +215,7 @@ Get the global user leaderboard.
List all markets (random selection, up to 100).

**Response** (200):

```json
{
"markets": [
Expand Down Expand Up @@ -241,6 +252,7 @@ List all markets (random selection, up to 100).
Search for markets based on query parameters.

**Query Parameters**:

- `q` (string): Search query

**Response**: Same format as `/v0/markets`
Expand Down Expand Up @@ -268,9 +280,11 @@ List all resolved markets.
Get detailed information about a specific market.

**Path Parameters**:

- `marketId` (integer): Market ID

**Response** (200):

```json
{
"id": 1,
Expand All @@ -292,11 +306,13 @@ Get detailed information about a specific market.
Calculate the new probability if a bet of specified amount and outcome were placed.

**Path Parameters**:

- `marketId` (integer): Market ID
- `amount` (integer): Bet amount
- `outcome` (string): Bet outcome

**Response** (200):

```json
{
"newProbability": 0.68
Expand All @@ -308,9 +324,11 @@ Calculate the new probability if a bet of specified amount and outcome were plac
Get all bets for a specific market.

**Path Parameters**:

- `marketId` (integer): Market ID

**Response** (200):

```json
[
{
Expand All @@ -330,9 +348,11 @@ Get all bets for a specific market.
Get all positions for a specific market.

**Path Parameters**:

- `marketId` (integer): Market ID

**Response** (200):

```json
{
// Market positions object (structure varies)
Expand All @@ -344,10 +364,12 @@ Get all positions for a specific market.
Get a specific user's positions in a market.

**Path Parameters**:

- `marketId` (integer): Market ID
- `username` (string): Username

**Response** (200):

```json
{
// User positions in market (structure varies)
Expand All @@ -359,9 +381,11 @@ Get a specific user's positions in a market.
Get the leaderboard for a specific market.

**Path Parameters**:

- `marketId` (integer): Market ID

**Response** (200):

```json
{
// Market leaderboard object (structure varies)
Expand All @@ -377,9 +401,11 @@ Get the leaderboard for a specific market.
Get public information about a user.

**Path Parameters**:

- `username` (string): Username

**Response** (200):

```json
{
"username": "trader1",
Expand All @@ -401,9 +427,11 @@ Get public information about a user.
Get user credit/balance information.

**Path Parameters**:

- `username` (string): Username

**Response** (200):

```json
{
"accountBalance": 9500
Expand All @@ -415,9 +443,11 @@ Get user credit/balance information.
Get a user's investment portfolio.

**Path Parameters**:

- `username` (string): Username

**Response** (200):

```json
{
// User portfolio object (structure varies)
Expand All @@ -429,9 +459,11 @@ Get a user's investment portfolio.
Get financial information for a user.

**Path Parameters**:

- `username` (string): Username

**Response** (200):

```json
{
// User financial information (structure varies)
Expand All @@ -449,6 +481,7 @@ These endpoints require authentication and operate on the authenticated user's p
Get private profile information for the authenticated user.

**Response** (200):

```json
{
"username": "trader1",
Expand All @@ -472,6 +505,7 @@ Get private profile information for the authenticated user.
Change the authenticated user's password.

**Request Body**:

```json
{
"currentPassword": "oldpassword", // Optional
Expand All @@ -486,6 +520,7 @@ Change the authenticated user's password.
Change the authenticated user's display name.

**Request Body**:

```json
{
"displayName": "New Display Name"
Expand All @@ -499,6 +534,7 @@ Change the authenticated user's display name.
Change the authenticated user's personal emoji.

**Request Body**:

```json
{
"emoji": "🚀"
Expand All @@ -512,6 +548,7 @@ Change the authenticated user's personal emoji.
Change the authenticated user's profile description.

**Request Body**:

```json
{
"description": "New profile description"
Expand All @@ -525,6 +562,7 @@ Change the authenticated user's profile description.
Change the authenticated user's personal links.

**Request Body**:

```json
{
"personalLink1": "https://twitter.com/user",
Expand All @@ -545,6 +583,7 @@ Change the authenticated user's personal links.
Place a bet on a market outcome.

**Request Body**:

```json
{
"marketId": 1, // Required
Expand All @@ -554,6 +593,7 @@ Place a bet on a market outcome.
```

**Response** (201):

```json
{
"id": 123,
Expand All @@ -571,9 +611,11 @@ Place a bet on a market outcome.
Get the authenticated user's position in a specific market.

**Path Parameters**:

- `marketId` (integer): Market ID

**Response** (200):

```json
{
// User position in market (structure varies)
Expand All @@ -585,6 +627,7 @@ Get the authenticated user's position in a specific market.
Sell shares in a market position.

**Request Body**:

```json
{
"marketId": 1,
Expand All @@ -604,6 +647,7 @@ Sell shares in a market position.
Create a new prediction market.

**Request Body**:

```json
{
"questionTitle": "Will it snow next week?", // Required
Expand All @@ -616,6 +660,7 @@ Create a new prediction market.
```

**Response** (201):

```json
{
"id": 2,
Expand All @@ -637,9 +682,11 @@ Create a new prediction market.
Resolve a market with the final outcome.

**Path Parameters**:

- `marketId` (integer): Market ID

**Request Body**:

```json
{
"resolutionResult": "yes" // Required
Expand All @@ -659,6 +706,7 @@ These endpoints require admin privileges.
Create a new user account (admin only).

**Request Body**:

```json
{
"username": "newuser", // Required
Expand All @@ -670,6 +718,7 @@ Create a new user account (admin only).
```

**Response** (201):

```json
{
"id": 456,
Expand Down Expand Up @@ -843,4 +892,4 @@ Application economics configuration:
- Market resolution results depend on outcome type (e.g., "yes"/"no" for binary)
- JWT tokens expire after 24 hours
- Rate limiting may apply to certain endpoints
- Some response structures may vary based on the specific implementation details
- Some response structures may vary based on the specific implementation details
Loading
Loading