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.
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
- 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
Before running this application, make sure you have the following installed:
- .NET 7.0 SDK
- SQL Server (LocalDB, Express, or full version)
- Visual Studio 2022 or Visual Studio Code (optional but recommended)
To run the FinFlex API locally, follow these steps:
-
Clone this repository:
git clone https://github.com/yousefsaad12/FinFlex-Api.git
-
Navigate to the project directory:
cd FinFlex-Api -
Navigate to the API project directory:
cd api -
Restore NuGet packages:
dotnet restore
-
Update the database connection string in
appsettings.jsonif needed -
Apply database migrations:
dotnet ef database update
-
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.
To use the FinFlex API, follow these guidelines:
- Access Swagger Documentation: Navigate to
https://localhost:7xxx/swaggerto view interactive API documentation - Authentication: Register a new account or login using existing credentials to obtain a JWT token
- Authorization: Include the JWT token in the Authorization header as
Bearer {your-token}for protected endpoints - Stock Management: Use stock endpoints to create, read, update, and delete stock information
- Portfolio Management: Build and manage your personal stock portfolio
- Community Engagement: Add comments and reviews for stocks to share insights with other users
-
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..." }
-
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
-
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 }
-
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)
Contributions are welcome! If you have any suggestions, feature requests, or bug reports, please open an issue or submit a pull request.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ by yousefsaad12
