How saylogfake/simpos works
1. System shape
- The repository is a two-part SaaS point-of-sale system:
- backend/: ASP.NET Core Web API in C#.
- saas-pos/: Next.js + React + TypeScript frontend.
- The frontend is the user-facing application; the backend owns business logic and persistence.
2. Primary boundary between tiers
- All domain operations appear to flow from the frontend through saas-pos/lib/api.ts into backend controllers.
- The backend exposes resource-oriented endpoints for authentication, users/roles, tenants, products, inventory, sales, cash, customers, debt, notifications, and seeding.
3. Backend API layer
- Controllers are separated by business domain: AuthController, UsersController, RolesController, TenantsController, ProductsController, InventoryController, SalesController, CashController, CustomersController, DebtController, NotificationsController, and SeedController.
- This suggests the API is organized as a modular monolith, with each controller handling a bounded functional area rather than a generic CRUD layer.
4. Backend application services
- Business rules are extracted into services under backend/Services:
- CashService
- DebtService
- InventoryService
- FactPyService
- The controllers likely orchestrate requests while these services contain transactional logic, especially for stock movements, cash sessions, and debt handling.
5. Data and persistence
- AppDbContext and EF Core migrations show the backend uses Entity Framework Core as the ORM.
- The presence of InitialSQLite migrations strongly indicates SQLite as the default or local development database.
- The model layer is in backend/Models/Entities.cs, with DTOs such as RoleDtos.cs for API payload shaping.
6. Multi-tenant architecture
- TenantsController plus a dedicated migration to add tenants indicate the system supports tenant separation.
- The presence of RolesController, UsersController, and AuthController suggests tenant-scoped access control, likely with role-based permissions layered on top of tenancy.
7. Frontend application structure
- The frontend uses the Next.js App Router with route groups:
- (auth) for login
- (dashboard) for operational back-office screens
- (pos) for point-of-sale flows
- This separation is important: POS workflows are isolated from administrative dashboard workflows.
8. Frontend state and interaction model
- app/context/UserContext.tsx likely provides authenticated user/session state across pages.
- Most user interactions are implemented through modal components in components/, which suggests a highly interactive SPA-like experience for tasks such as editing products, cash operations, returns, discounts, waste, and restocking.
9. Domain-oriented UI composition
- UI components are grouped by function:
- components/pos: checkout, returns, quick waste
- components/cash: open/close sessions, movement details
- components/customers: customer details
- components/inventory: kardex, waste, categories, product tabs
- This mirrors the backend domain boundaries and is a good cue for an architecture diagram: UI modules map closely to API modules.
10. Operational flows
- Typical flows likely look like:
- Login/authentication via AuthController
- User loads dashboard or POS page
- Frontend calls API through lib/api.ts
- Backend services execute business rules
- EF Core persists changes to the database
- High-value transactional flows include sales checkout, inventory adjustments, cash opening/closing, debt tracking, and customer management.
11. Notifications and automation
- NotificationsController and the frontend NotificationsPanel.tsx indicate push/pull notification support inside the app.
- SeedController suggests bootstrapping of reference data or initial tenant/admin setup, which is important in a fresh deployment or demo environment.
12. Deployment and environment
- The repo includes Docker support for both backend and frontend, plus docker-compose.yml at the root.
- Railway deployment files and multiple backend environment configs (Development, Staging, Production) indicate the system is designed for containerized hosting with environment-specific settings.
- .env.example implies runtime configuration is externalized, likely for API URLs, database connection, and auth-related settings.
13. Architecture summary for diagramming
- Draw the backend as an ASP.NET Core API with domain controllers, service layer, and EF Core persistence beneath it.
- Draw the frontend as a Next.js app with auth/dashboard/POS route groups, shared context, and modal-heavy domain components.
- Connect them with a single API boundary; then show the database beneath the backend and deployment/containerization around both tiers.
Main entry points: Controllers Controllers · AppDbContext.cs DbContext · docker-compose.yml Compose Stack · Program.cs Program
Components 19
Frontend
Next.js + React POS and dashboard UI
- App Router · Route groups for auth, dashboard, and POS flows
saas-pos/app - User Context · Authenticated user/session state for the UI
saas-pos/app/context/UserContext.tsx - API Client · Shared frontend gateway for backend calls
saas-pos/lib/api.ts - POS UI · Checkout and point-of-sale interaction screens
saas-pos/components/pos - Dashboard UI · Administrative screens for cash, inventory, customers, roles, and superadmin
saas-pos/app/(dashboard) - Domain Modals · Modal-driven workflows for inventory, cash, customers, discounts, and notifications
saas-pos/components
Backend
ASP.NET Core API and domain services
- Controllers · Domain-oriented REST controllers
backend/Controllers - Auth Users · Authentication, users, roles, and tenant access
backend/Controllers/AuthController.cs - Business APIs · Products, inventory, sales, cash, customers, debt, notifications, and seed
backend/Controllers - Services · Transactional domain logic for cash, debt, inventory, and external factoring
backend/Services - DbContext · Entity Framework Core persistence gateway
backend/Data/AppDbContext.cs - Entities & DTOs · Database entities and API payload shapes
backend/Models/Entities.cs - Migrations · EF Core migrations including SQLite bootstrap and tenants
backend/Migrations - Program · Application composition and host startup
backend/Program.cs - SQLite DB · Default local persistence target implied by migrations
Operations
Containerization and deployment files
- Backend Docker · Backend container image definition
backend/Dockerfile - Frontend Docker · Frontend container image definition
saas-pos/Dockerfile - Compose Stack · Root multi-service container orchestration
docker-compose.yml - Railway Config · Hosting configuration for deployed environments
railway.json
Connections 22
- App Router → User Context: uses session · Pages consume authenticated user state
- App Router → API Client: calls API · Routes invoke backend operations through the shared client
- POS UI → Domain Modals: opens · POS flows are composed from modal interactions
- Dashboard UI → Domain Modals: uses · Operational screens reuse modal components
- User Context → API Client: auth headers · Session state informs request identity
- API Client → Controllers: http · Frontend communicates with the backend controllers
- Controllers → Auth Users: identity · Auth, users, roles, and tenancy endpoints
- Controllers → Business APIs: domain · Business controllers for core POS workflows
- Business APIs → Services: orchestrates · Controllers delegate transactional rules to services
- Services → DbContext: persists via · Services use the EF Core context for data access
- DbContext → Entities & DTOs: maps · Context is built over entities and DTO-shaping models
- Migrations → DbContext: evolves schema · Migrations define the database shape used by the context
- Program → Controllers: registers · Startup wires controllers into the host
- Program → Services: injects · Startup configures domain services for DI
- Program → DbContext: configures · Startup sets up persistence and database access
- DbContext → SQLite DB: stores · The context writes to the SQLite-backed database
- Compose Stack → Backend Docker: builds · Compose includes the backend image
- Compose Stack → Frontend Docker: builds · Compose includes the frontend image
- Railway Config → Backend Docker: deploys · Railway config supports backend hosting
- Railway Config → Frontend Docker: deploys · Railway config supports frontend hosting
- Compose Stack → Controllers: runs · Local orchestration starts the API service
- Compose Stack → App Router: runs · Local orchestration starts the web app