This guide walks you through running Agrotech locally from source.
| Requirement | Minimum version | Notes |
|---|---|---|
| .NET SDK | 8.0 | dotnet --version to verify |
| PostgreSQL | 15 | Or use Docker Compose (see below) |
| Docker | any recent | Optional — only needed for Docker-based PostgreSQL |
| Node.js | 18+ | Required only if you develop the React frontend |
git clone https://github.com/barach6662001-bit/AgroPlatform.git
cd AgroPlatformdocker-compose up -dThe Compose file starts a single postgres:16-alpine container with:
| Setting | Value |
|---|---|
| Database | agroplatform_db |
| User | agroplatform |
| Password | agroplatform_dev |
| Port | 5432 |
Create a database and a user manually:
CREATE USER agroplatform WITH PASSWORD 'agroplatform_dev';
CREATE DATABASE agroplatform_db OWNER agroplatform;Copy the example settings file and adjust if needed:
cp src/AgroPlatform.Api/appsettings.Development.example.json \
src/AgroPlatform.Api/appsettings.Development.jsonThe default values in appsettings.json already match the Docker Compose database.
Edit appsettings.Development.json only if your credentials differ.
Key settings:
Never commit real secrets. Use environment variables or user-secrets in production.
Any configuration value can be overridden with an environment variable using double-underscore (__) as a separator:
export ConnectionStrings__DefaultConnection="Host=..."
export JwtSettings__Key="..."
export Swagger__Enabled=truedotnet ef database update \
--project src/AgroPlatform.Infrastructure \
--startup-project src/AgroPlatform.ApiIf dotnet-ef is not installed:
dotnet tool install --global dotnet-efdotnet run --project src/AgroPlatform.ApiThe API starts at http://localhost:5224 (see Properties/launchSettings.json).
Navigate to http://localhost:5224/swagger in your browser.
You will see all API endpoints grouped by module:
- Auth — register and log in
- Warehouses — stock management
- Fields — field and crop management
- AgroOperations — agricultural operation planning
- Machinery — fleet management
- Economics — cost tracking
- Analytics — dashboards and reports
To authenticate:
- Call
POST /api/auth/loginwith your credentials. - Copy the
tokenvalue from the response. - Click Authorize (🔒) in Swagger UI.
- Paste the token (without
Bearerprefix) and click Authorize.
Every request to protected endpoints must include:
X-Tenant-Id: <your-tenant-uuid>
See tenancy.md for details on multi-tenancy.
cd frontend
npm install
npm run dev # http://localhost:3000The Vite dev server proxies /api requests to http://localhost:5224.
# All tests
dotnet test
# Unit tests only
dotnet test tests/AgroPlatform.UnitTests
# Integration tests only (requires Docker for Testcontainers)
dotnet test tests/AgroPlatform.IntegrationTestsSee the project README for more details.
When running inside a GitHub Codespace, the simplest approach is:
# 1. Start docker-compose
docker-compose up --build -d
# 2. Add Codespaces CORS origin to .env (one-time)
echo "CODESPACES_URL=https://${CODESPACE_NAME}-3000.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}" >> .env
docker-compose up -d api # restart API to pick up new CORS
# 3. Open the forwarded port 3000 in your browserThe frontend URL is displayed in the Ports panel of VS Code.
Why CODESPACES_URL is needed: when running inside Codespaces with docker-compose, the browser Origin is
https://your-codespace-3000.app.github.dev, nothttp://localhost:3000. The API must have that origin in its CORS allowed list.
{ "ConnectionStrings": { // PostgreSQL connection string "DefaultConnection": "Host=localhost;Port=5432;Database=agroplatform_db;Username=agroplatform;Password=agroplatform_dev" }, "JwtSettings": { // Must be at least 32 characters "Key": "super-secret-key-for-development-minimum-32-characters-long!!" }, "Swagger": { // Set to true to expose Swagger UI in non-Development environments "Enabled": true } }