A scalable, testable CRM system with JWT-based authentication, Redis caching, PostgreSQL storage, and clean DDD practices — all orchestrated with Docker. Built for real-world scenarios like customer tracking, lead generation, deal flow, and analytics aggregation service.
-
✅ Full CRUD Operations
Manage Customers, Leads, and Opportunities through clean, RESTful endpoints. -
📊 Analytics Endpoint (Aggregation Service)
Summarizes key metrics like active leads, top sales reps, inactive customers, and won deals this month. -
🧠 Real Business Logic
Includes domain-specific rules: lead assignment, opportunity stages, customer activity tracking. -
🚀 Batch POST Support (Postman-ready)
Easily seed demo data via bulkPOSTrequests for Customers, Leads, and Opportunities. Ideal for analytics and testing. -
🧪 Mock Mode for Testing
ToggleUseInMemoryDatabase = trueto test full functionality using in-memory data (with Redis caching enabled). -
🕒 Redis Caching
CachesCustomerrecords for 30 minutes to reduce DB load and improve response times. -
🔄 Switchable Persistence Layer
Configure between In-Memory + Redis or full PostgreSQL using a simple config flag.
👉 Jump to config section -
🔐 JWT-Based Authentication
Secure endpoints using JSON Web Tokens (JWT). Supports login +X-Authorizationheaders for testing. -
🧪 xUnit Test Coverage
Unit tests included for business logic and API endpoints to ensure reliability and maintainability. -
📦 Docker-Ready Setup
Run the entire stack (API + PostgreSQL + Redis) with a singledocker-compose up -dcommand.
| Technology | Purpose |
|---|---|
| PostgreSQL (Dockerized) | Relational DB in a container for easy setup and scalability. |
| Redis | In-memory caching for faster performance and reduced DB load. |
| Entity Framework Core | ORM to manage PostgreSQL via strongly-typed C# entities. |
| AutoMapper | DTO ↔ Entity mapping for clean separation of concerns. |
| ASP.NET Core Web API | Powers secure REST endpoints with JWT authentication. |
| Docker Compose | Spins up the API, Redis, and PostgreSQL in one command. |
| Domain-Driven Design | Code is modeled around real business rules for maintainability. |
| Clean Architecture | Layered structure for testability, scalability, and separation of concerns. |
- Login with:
- Username:
admin - Password:
Admin2025!
- Username:
- On success, a JWT token is returned.
- Include the token in every request using the custom header:
X-Authorization: {your-token}
- ✅ Full CRUD support for Customers, Leads, Opportunities
- 🧠 Real business logic: Analytics, Status handling, Deal stage tracking
- 🔄 Mock testing mode with in-memory data for isolated testing
- 🕒 Redis caching for
Customerdata (30 min expiration) - 🔧 Switch between In-Memory & PostgreSQL via config
- 🧪 xUnit tests for key endpoints
You can test the entire API using the bundled collection:
👉 Import on Postman the file named : CRM CRUD Test Custom APIs & CRM_Batch_Seeding.postman_collection located at : MyApiProject.API
POST /api/address
Headers:
X-Authorization: {your-jwt}
X-RequestId: mock
Body:
{
"internalId": "int1",
"externalId": "ext1",
"addressId": "1"
}navigate cmd/PowerShell/Bash on \MyApiProject\MyApiProject.API and run
docker-compose up -d- PostgreSQL:
localhost:5432 - Redis:
localhost:6379
In Program.cs, uncomment:
// var jwtSettings = builder.Configuration.GetSection("JwtSettings").Get<JwtSettings>();Then run:
dotnet user-secrets init --project "Path\To\YourProject.csproj"
dotnet user-secrets set "JwtSettings:Issuer" "test.gr"
dotnet user-secrets set "JwtSettings:Audience" "test"
dotnet user-secrets set "JwtSettings:Key" "justADummyTokenKeyForDummyTest2025!"
dotnet user-secrets set "JwtSettings:ExpiryMinutes" "60"In Program.cs, uncomment the env variable block. Then in PowerShell:
[System.Environment]::SetEnvironmentVariable("JWT_ISSUER", "test.gr", "User")
[System.Environment]::SetEnvironmentVariable("JWT_AUDIENCE", "test", "User")
[System.Environment]::SetEnvironmentVariable("JWT_KEY", "justADummyTokenKeyForDummyTest2025!", "User")
[System.Environment]::SetEnvironmentVariable("JWT_EXPIRY_MINUTES", "60", "User")Edit appsettings.json:
"UseInMemoryDatabase": true // or falsetrue: Enables mock data with Redis Cache.false: Uses actual PostgreSQL DB.
- ⏳ More advanced domain validation rules
- 🧪 More xUnit test coverage (services + API layers)
- 📈 Add Swagger docs for easy endpoint discovery
🏷️ Tech Tags:
dotnet-corewebapiclean-architecturedomain-driven-designredispostgresqljwt-authenticationcrm-backenddocker-compose