Skip to content

finShark is a web API focused on the stock market. It provides endpoints for managing stocks, comments on stocks, and user portfolios. The API uses JWT for authentication and SQL for the database. Swagger is used for API documentation.

Notifications You must be signed in to change notification settings

YeabTesfaye/FinShark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

finShark Web API

finShark is a web API focused on the stock market. It provides endpoints for managing stocks, comments on stocks, and user portfolios. The API uses JWT for authentication and SQL for the database. Swagger is used for API documentation.

Table of Contents

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/finShark.git
    cd finShark
    
  2. Install dependencies:

dotnet restore 
  1. Set up the database: Ensure you have a SQL Server instance running and update the connection string in appsetings.json.

  2. Apply migrations:

dotnet ef database update

Configuration

Configure your database connection string and other settings in the appsettings.json file.

Usage

To run the application:

  1. Apply migrations:
dotnet ef database update

2. Start the application using:

   ```bash
   dotnet run

Start the application using dotnet run and navigate to https://localhost:5001/swagger to view the Swagger API documentation.
## Models

### Comment

- **CommentId**: `int` - The unique identifier for the comment.
- **Title**: `string` - The title of the comment.
- **Content**: `string` - The content of the comment.
- **CreatedOn**: `DateTime` - The date and time when the comment was created.
- **StockId**: `int` - The ID of the stock the comment is associated with.
- **Stock**: `Stock` - The stock entity associated with the comment.
- **AppUserId**: `string` - The ID of the user who made the comment.
- **AppUser**: `AppUser` - The user entity associated with the comment.

### Portfolio

- **AppUserId**: `string` - The ID of the user who owns the portfolio.
- **StockId**: `int` - The ID of the stock in the portfolio.
- **AppUser**: `AppUser` - The user entity associated with the portfolio.
- **Stock**: `Stock` - The stock entity associated with the portfolio.

### Stock

- **StockId**: `int` - The unique identifier for the stock.
- **Symbol**: `string` - The stock symbol.
- **CompanyName**: `string` - The name of the company.
- **Purchase**: `decimal` - The purchase price of the stock.
- **LastDiv**: `decimal` - The last dividend of the stock.
- **Industry**: `string` - The industry the stock belongs to.
- **MarketCap**: `long` - The market capitalization of the stock.
- **Comments**: `List<Comment>` - The list of comments associated with the stock.
- **Portfolios**: `List<Portfolio>` - The list of portfolios that include the stock.

## Endpoints

### Authentication

- **Register**: `POST /api/auth/register`  
  Registers a new user.

- **Login**: `POST /api/auth/login`  
  Logs in an existing user and returns a JWT token.

### Stocks

- **Get all stocks**: `GET /api/stocks`  
  Retrieves a list of all stocks.

- **Get stock by ID**: `GET /api/stocks/{id}`  
  Retrieves a stock by its unique identifier.

- **Create stock**: `POST /api/stocks`  
  Creates a new stock.

- **Update stock**: `PUT /api/stocks/{id}`  
  Updates an existing stock by its unique identifier.

- **Delete stock**: `DELETE /api/stocks/{id}`  
  Deletes a stock by its unique identifier.

### Comments

- **Get comments for stock**: `GET /api/stocks/{stockId}/comments`  
  Retrieves a list of comments associated with a specific stock.

- **Add comment to stock**: `POST /api/stocks/{stockId}/comments`  
  Adds a new comment to a specific stock.

- **Update comment**: `PUT /api/comments/{id}`  
  Updates an existing comment by its unique identifier.

- **Delete comment**: `DELETE /api/comments/{id}`  
  Deletes a comment by its unique identifier.

### Portfolios

- **Get portfolio for user**: `GET /api/portfolios/{userId}`  
  Retrieves the portfolio of a specific user.

- **Add stock to portfolio**: `POST /api/portfolios`  
  Adds a stock to the user's portfolio.

- **Remove stock from portfolio**: `DELETE /api/portfolios/{userId}/{stockId}`  
  Removes a stock from the user's portfolio.


## Authentication

This API uses JWT (JSON Web Tokens) for authentication. Include the token in the `Authorization` header with the `Bearer` scheme for protected endpoints.

### Example

```http
Authorization: Bearer your_jwt_token

## Swagger UI

Below is a screenshot of the Swagger UI for the finShark Web API:

![Swagger UI](api/img/img.png)


<img src="./api/img/img.png" alt="Swagger UI">

![Screenshot 2024-07-30 115221](https://github.com/user-attachments/assets/6f272bc8-9eec-4779-b641-08d6ef28ff45)
![Screenshot 2024-07-30 115221](https://github.com/user-attachments/assets/e999f6f8-9090-4132-a8f4-913f3ca2e55b)
![Screenshot 2024-07-30 115203](https://github.com/user-attachments/assets/5035f7e0-1c37-4808-8449-829a68c62e38)

About

finShark is a web API focused on the stock market. It provides endpoints for managing stocks, comments on stocks, and user portfolios. The API uses JWT for authentication and SQL for the database. Swagger is used for API documentation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages