Skip to content

yousefsaad12/FinFlex-Api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FinFlex API

FinFlex_Api πŸ’» (1)

GitHub last commit GitHub language count

Description

FinFlex API is a comprehensive RESTful web API built with ASP.NET Core that provides backend services for stock portfolio management and investment tracking. This robust API enables users to manage their stock investments, create personalized portfolios, and engage with a community through stock comments and reviews.

The API is designed for financial applications, investment platforms, and portfolio management systems that require reliable stock data management, user authentication, and social features for investment discussions.

Table of Contents

Features

The FinFlex API offers the following features:

  • πŸ“ˆ Stock Management: Complete CRUD operations for stock data including symbol, company name, purchase price, dividends, industry, and market cap
  • πŸ’Ό Portfolio Tracking: Personal portfolio management allowing users to add/remove stocks and track their investments
  • πŸ’¬ Community Comments: Social features enabling users to share insights, reviews, and experiences about specific stocks
  • πŸ” JWT Authentication: Secure user authentication and authorization using JSON Web Tokens
  • πŸ“š API Documentation: Interactive Swagger UI documentation for easy API exploration and testing
  • πŸ” Advanced Filtering: Support for filtering and pagination on stock listings
  • πŸ‘€ User Management: Complete user registration and login system

Tech Stack

  • Framework: ASP.NET Core 7.0
  • Database: SQL Server with Entity Framework Core
  • Authentication: JWT (JSON Web Tokens)
  • Documentation: Swagger/OpenAPI
  • Serialization: Newtonsoft.Json
  • Architecture: RESTful API with MVC pattern

Prerequisites

Before running this application, make sure you have the following installed:

Installation

To run the FinFlex API locally, follow these steps:

  1. Clone this repository:

    git clone https://github.com/yousefsaad12/FinFlex-Api.git
  2. Navigate to the project directory:

    cd FinFlex-Api
  3. Navigate to the API project directory:

    cd api
  4. Restore NuGet packages:

    dotnet restore
  5. Update the database connection string in appsettings.json if needed

  6. Apply database migrations:

    dotnet ef database update
  7. Start the server:

    dotnet watch run

The server will start running at https://localhost:7xxx (HTTPS) or http://localhost:5xxx (HTTP) by default. The exact ports will be displayed in the console.

Usage

To use the FinFlex API, follow these guidelines:

  1. Access Swagger Documentation: Navigate to https://localhost:7xxx/swagger to view interactive API documentation
  2. Authentication: Register a new account or login using existing credentials to obtain a JWT token
  3. Authorization: Include the JWT token in the Authorization header as Bearer {your-token} for protected endpoints
  4. Stock Management: Use stock endpoints to create, read, update, and delete stock information
  5. Portfolio Management: Build and manage your personal stock portfolio
  6. Community Engagement: Add comments and reviews for stocks to share insights with other users

API Endpoints

Authentication

  • POST /api/Account/register

    • Description: Register a new user account and generate a JWT token for accessing protected endpoints.
    • Request Body:
      {
          "userName": "string",
          "email": "[email protected]",
          "password": "string"
      }
    • Response:
      { 
          "UserName": "userexample",
          "Email": "[email protected]",
          "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
      }
  • POST /api/Account/login

    • Description: Authenticate a user and generate a JWT token for accessing protected endpoints.
    • Request Body:
      {
          "email": "[email protected]",
          "password": "password123"
      }
    • Response:
      { 
          "UserName": "userexample",
          "Email": "[email protected]",
          "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
      }

Stocks

  • GET /api/Stocks

    • Description: Retrieve all stocks with optional filtering and pagination support.
    • Authorization: Bearer Token (JWT)
    • Response:
      [
        {
          "id": 1,
          "symbol": "TSLA",
          "companyName": "TESLA",
          "purchase": 1000000000,
          "lastDiv": 100,
          "industry": "string",
          "marketCap": 5000000000,
          "comments": [
              {
                  "id": 1,
                  "title": "Good Stock",
                  "content": "string",
                  "createdOn": "2024-02-01T16:47:17.435881",
                  "createdBy": "User1",
                  "stockId": 1
              }
      ]
        },
        {
          "id": 2,
          "symbol": "PLTR",
          "companyName": "Palantir Technologies",
          "purchase": 15000000,
          "lastDiv": 100,
          "industry": "string",
          "marketCap": 190000000,
          "comments": []
        }
      ]
  • POST /api/Stock

    • Description: Create a new stock entry.
    • Authorization: Bearer Token (JWT)
    • Request Body:
      {
          "symbol": "string",
          "companyName": "string",
          "purchase": 1000000000,
          "lastDiv": 100,
          "industry": "string",
          "marketCap": 5000000000
      }
    • Response:
      {   
          "Id": "1"
          "symbol": "string",
          "companyName": "string",
          "purchase": 1000000000,
          "lastDiv": 100,
          "industry": "string",
          "marketCap": 5000000000
      }
  • PUT /api/Stock/:id

    • Description: Update an existing Stock by ID.
    • Authorization: Bearer Token (JWT)
    • Request Body:
      {
          "symbol": "string",
          "companyName": "string",
          "purchase": 1000000000,
          "lastDiv": 100,
          "industry": "string",
          "marketCap": 5000000000
      }
    • Response:
      {
          "id": "1",
          "symbol": "string",
          "companyName": "string",
          "purchase": 1000000000,
          "lastDiv": 100,
          "industry": "string",
          "marketCap": 5000000000
      }
  • GET /api/Stock/:id

    • Description: Get a Stock by ID.
    • Authorization: Bearer Token (JWT)
    • Response:
      {
          "id": "1",
          "symbol": "string",
          "companyName": "string",
          "purchase": 1000000000,
          "lastDiv": 100,
          "industry": "string",
          "marketCap": 5000000000
      }
  • DELETE /api/Stock/:id

    • Description: Delete a Stock by ID.
    • Authorization: Bearer Token (JWT)
    • Response: No Content

Comments

  • GET /api/Comment

    • Description: Retrieve all comments.
    • Authorization: Bearer Token (JWT)
    • Response:
      [
        {
          "id": 1,
          "title": "Good Stock",
          "content": "string",
          "createdOn": "2024-02-01T16:47:17.435881",
          "createdBy": "User1",
          "stockId": 1
        },
        
      ]
  • GET /api/Comment/:id

    • Description: Retrieve a specific comment by ID.
    • Authorization: Bearer Token (JWT)
    • Response:
      [
        {
          "id": 1,
          "title": "Good Stock",
          "content": "string",
          "createdOn": "2024-02-01T16:47:17.435881",
          "createdBy": "User1",
          "stockId": 1
        },
        
      ]
  • POST /api/Comment/:stockId

    • Description: Create a new comment for a specific stock.
    • Authorization: Bearer Token (JWT)
    • Request Body:
      {
          "title": "string",
          "content": "string"
      }
    • Response:
      {
          "id": 1,
          "title": "Good Stock",
          "content": "string",
          "createdOn": "2024-02-01T16:47:17.435881",
          "createdBy": "User1",
          "stockId": 1
      }
  • PUT /api/Comment/:id

    • Description: Update an existing Comment by ID.
    • Authorization: Bearer Token (JWT)
    • Request Body:
      {
          "title": "string",
          "content": "string"
      }
    • Response:
      {
          "id": 1,
          "title": "Good Stock",
          "content": "string",
          "createdOn": "2024-02-01T16:47:17.435881",
          "createdBy": "User1",
          "stockId": 1
      }
  • DELETE /api/Comment/:id

    • Description: Delete a Comment by ID.
    • Authorization: Bearer Token (JWT)
    • Response:
      {
          "id": 1,
          "title": "Good Stock",
          "content": "string",
          "createdOn": "2024-02-01T16:47:17.435881",
          "createdBy": "User1",
          "stockId": 1
      }

Portfolio

  • GET /api/Portfolio

    • Description: Retrieve all portfolio stocks for the authenticated user.
    • Authorization: Bearer Token (JWT)
    • Response:
      [
         {
           "id": 1,
           "symbol": "TSLA",
           "companyName": "TESLA",
           "purchase": 1000000000,
           "lastDiv": 100,
           "industry": "string",
           "marketCap": 5000000000,
           "comments": [],
           "portfolios": []
          },
          {
          "id": 2,
          "symbol": "PLTR",
          "companyName": "Palantir Technologies",
          "purchase": 15000000,
          "lastDiv": 100,
          "industry": "string",
          "marketCap": 190000000,
          "comments": [],
          "portfolios": []
          }
      ]
  • POST /api/Portfolio/:StockSymbol

    • Description: Add a stock to the authenticated user's portfolio by stock symbol.
    • Authorization: Bearer Token (JWT)
    • Response:
      {
          "message": "Stock has been added"
      }
  • DELETE /api/Portfolio/:StockSymbol

    • Description: Remove a stock from the authenticated user's portfolio by stock symbol.
    • Authorization: Bearer Token (JWT)

Contributing

Contributions are welcome! If you have any suggestions, feature requests, or bug reports, please open an issue or submit a pull request.

How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.


Built with ❀️ by yousefsaad12

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages