A .NET 8 application built with Clean Architecture principles to calculate fundable amounts for companies based on SEC EDGAR financial data.
This application imports company financial data from the SEC EDGAR API and calculates two types of fundable amounts based on specific business rules.
Data Requirements:
- Company must have income data for all years between 2018 and 2022
- Company must have positive income in both 2021 and 2022
- If these conditions are not met, fundable amounts are $0
Standard Fundable Amount Calculation:
Using the highest income between 2018 and 2022:
- If income β₯ $10B: 12.33% of income
- If income < $10B: 21.51% of income
Special Fundable Amount Calculation:
Starts with the Standard Fundable Amount, then applies modifiers:
- If company name starts with a vowel (A, E, I, O, U): +15% to standard amount
- If 2022 income < 2021 income: -25% from standard amount
Company A (High Income, starts with 'A', decreasing income):
- Highest income 2018-2022: $15B
- Standard: $15B Γ 12.33% = $1,849,500,000
- Special: $1,849,500,000 Γ 1.15 (vowel) Γ 0.75 (decrease) = $1,597,687,500
Company B (Low Income, starts with 'B', increasing income):
- Highest income 2018-2022: $5B
- Standard: $5B Γ 21.51% = $1,075,500,000
- Special: $1,075,500,000 (no modifiers) = $1,075,500,000
Built following Clean Architecture and Domain-Driven Design (DDD) principles:
βββ ForaProject.Domain # Core business logic and entities
βββ ForaProject.Application # Application services and use cases
βββ ForaProject.Infrastructure # Data persistence and external services
βββ ForaProject.API # REST API controllers and HTTP layer
- β SOLID Principles
- β DRY (Don't Repeat Yourself)
- β KISS (Keep It Simple, Stupid)
- β Repository Pattern
- β Unit of Work Pattern
- β Value Objects
- β Aggregates
Option 1: Docker (Recommended)
Option 2: Local Development
- .NET 8 SDK
- SQL Server (LocalDB, Express, or Full)
- Visual Studio 2022 or VS Code
-
Clone the repository
git clone https://github.com/PedrodeAlmeidaFreitas/ForaProject.git cd ForaProject -
Set up environment variables
# Quick setup with default values ./setup-env.sh # Or manually copy and edit cp .env.example .env # Edit .env and update SA_PASSWORD with a strong password
-
Start the application with Docker Compose
docker compose up --build
This will:
- Start SQL Server 2022 container on port 1433
- Build and start the API container on port 5000
- Create the database and run migrations automatically
- Set up a bridge network between containers
- Use environment variables from
.envfile
-
Access the API
- Swagger UI: http://localhost:5000/swagger
- API Base URL: http://localhost:5000/api/v1
-
Stop the application
docker compose down
-
Stop and remove volumes (clean slate)
docker compose down -v
-
Clone the repository
git clone https://github.com/PedrodeAlmeidaFreitas/ForaProject.git cd ForaProject -
Update Connection String
Edit
src/ForaProject.API/appsettings.json:{ "ConnectionStrings": { "DefaultConnection": "Server=localhost;Database=ForaProjectDb;Trusted_Connection=True;TrustServerCertificate=True;" } } -
Run Database Migrations
dotnet ef database update --project src/ForaProject.Infrastructure --startup-project src/ForaProject.API
-
Build the Solution
dotnet build
-
Run the API
cd src/ForaProject.API dotnet run -
Access Swagger UI
Open your browser and navigate to:
https://localhost:5001/swagger
GET /api/v1/companies- Get all companiesGET /api/v1/companies/cik/{cik}- Get company by CIKGET /api/v1/companies/{id}- Get company by IDPOST /api/v1/companies- Create company manuallyPOST /api/v1/companies/import- Import from SEC EDGARPOST /api/v1/companies/import/batch- Batch importDELETE /api/v1/companies/{id}- Delete company
GET /api/v1/fundableamounts- Get all fundable companiesGET /api/v1/fundableamounts/letter/{letter}- Filter by starting letterPOST /api/v1/fundableamounts/calculate/{cik}- Calculate for one companyPOST /api/v1/fundableamounts/calculate/all- Calculate for all companies
curl -X POST https://localhost:5001/api/v1/companies/import \
-H "Content-Type: application/json" \
-d '{"cik": 320193}'- Apple Inc.: 320193
- Microsoft Corp: 789019
- Alphabet Inc.: 1652044
- Amazon.com Inc: 1018724
- Meta Platforms Inc.: 1326801
- .NET 8 - Framework
- Entity Framework Core 8 - ORM
- SQL Server 2022 - Database
- Docker & Docker Compose - Containerization
- AutoMapper - Object mapping
- FluentValidation - Input validation
- Swagger/OpenAPI - API documentation
-
sqlserver: SQL Server 2022 Developer Edition
- Port: 1433
- Volume:
sqlserver_datafor data persistence - Health check enabled
-
api: ForaProject.API
- Port: 5000 (HTTP)
- Multi-stage build for optimized image size
- Waits for SQL Server health check before starting
The application uses a .env file for configuration. Available variables:
| Variable | Description | Default |
|---|---|---|
SA_PASSWORD |
SQL Server SA password | YourStrong!Passw0rd123 |
MSSQL_PID |
SQL Server edition | Developer |
DB_SERVER |
Database server name | sqlserver |
DB_NAME |
Database name | ForaProjectDb |
DB_USER |
Database user | sa |
ASPNETCORE_ENVIRONMENT |
ASP.NET Core environment | Development |
ASPNETCORE_URLS |
API URLs | http://+:80 |
API_PORT |
Host port for API | 5000 |
Setup:
# Use setup script (recommended)
./setup-env.sh
# Or manually
cp .env.example .env
nano .env # Update SA_PASSWORD and other valuesSecurity: The .env file is ignored by git. Never commit it to version control!
# Build and start all services
docker compose up --build
# Start services in detached mode
docker compose up -d
# View logs
docker compose logs -f
# Stop all services
docker compose down
# Stop and remove volumes
docker compose down -v
# Rebuild specific service
docker compose build apiForaProject/
βββ .github/
β βββ workflows/ # GitHub Actions CI/CD pipelines
β βββ ISSUE_TEMPLATE/ # Issue templates
β βββ CICD.md # CI/CD documentation
β βββ PIPELINE.md # Pipeline overview
β βββ PULL_REQUEST_TEMPLATE.md # PR template
βββ src/
β βββ ForaProject.Domain/ # Business logic, entities, value objects
β βββ ForaProject.Application/ # Services, DTOs, validators
β βββ ForaProject.Infrastructure/# EF Core, repositories, migrations
β βββ ForaProject.API/ # Controllers, middleware, filters
βββ tests/
β βββ ForaProject.Domain.Tests/
β βββ ForaProject.Application.Tests/
β βββ ForaProject.API.Tests/
β βββ ForaProject.IntegrationTests/
βββ docker-compose.yml # Multi-container configuration
βββ Dockerfile # API container image
βββ coverlet.runsettings # Code coverage settings
βββ validate-ci.sh # Local CI validation script
βββ CHANGELOG.md # Version history
βββ ForaProject.sln # Solution file
This project uses GitHub Actions for automated CI/CD:
- β Continuous Integration: Automated builds, tests, and code coverage
- π³ Docker Images: Multi-platform builds pushed to GitHub Container Registry
- π Security Scanning: CodeQL analysis and dependency audits
- π Code Coverage: 80% minimum threshold with automatic PR comments
- π Automated Deployments: Staging and production deployments
# Run all CI checks locally before pushing
./validate-ci.sh
# View detailed CI/CD documentation
cat .github/PIPELINE.mdLearn more:
- Pipeline Overview - Quick reference guide
- Detailed CI/CD Docs - Complete documentation
- Contributing Guide - Contribution workflow
We welcome contributions! Please follow these steps:
git clone https://github.com/PedrodeAlmeidaFreitas/ForaProject.git
cd ForaProjectgit checkout -b feat/your-feature-nameUse conventional commit prefixes: feat, fix, docs, test, refactor, perf, ci, chore
- Follow Clean Architecture guidelines
- Write tests for new functionality
- Maintain or improve code coverage (80% minimum)
- Follow SOLID principles and DDD patterns
./validate-ci.shThis runs:
- Build verification
- All test suites
- Code coverage check
- Code formatting validation
- Security audit
git commit -m "feat(domain): add new entity for X"
git commit -m "fix(api): correct validation in Y controller"
git commit -m "docs(readme): update installation instructions"git push origin feat/your-feature-nameThen create a Pull Request using the PR template
- β All CI checks must pass
- β Code coverage threshold met (80%)
- β At least one approval required
- β Conventional commit format
- β No security vulnerabilities
Use the appropriate issue template:
- Be respectful and inclusive
- Follow the project's coding standards
- Write clear commit messages and PR descriptions
- Keep PRs focused and reasonably sized
- Workflow Status Guide - Understand GitHub Actions workflows and expected behavior
- Workflow Fixes - Quick fixes for common CI/CD failures
- Quickstart Guide - Get started quickly with development
- CIK Import Guide - Import company data from SEC EDGAR
- Coverage Report - Code coverage metrics and goals
- Changelog - Version history and changes
MIT License