How fahmudul/apartment-construction-expense-management-system works
1. This is a desktop CRUD application built with C# Windows Forms on .NET 10. The runtime boundary is entirely local on the user’s machine: UI forms call application services, which talk directly to SQL Server via Microsoft.Data.SqlClient.
2. The codebase is organized in a classic WinForms layering:
- Forms/ contains the screens and all UI workflows.
- Services/ contains business logic and database operations.
- Models/ contains simple data objects for User, Category, and Expense.
- Helpers/ contains cross-cutting utilities such as database connection setup and UI theming.
- Controls/ contains reusable UI components like the custom sidebar button.
3. Application startup is centered in Program.cs, which launches the WinForms shell and routes the user into the authentication flow. From there, the login/registration screens decide which main dashboard to open based on role and status.
4. Authentication and approval are a major subsystem. AuthService supports login, registration, and session-related decisions. New users register into a Pending status, then PendingApprovalForm communicates that they must wait for admin approval before login is allowed. This creates a clear boundary between self-service registration and admin-controlled access.
5. Role-based UI is split into admin and user experiences. Admin screens include AdminDashboardForm, AdminUsersForm, AdminCategoriesForm, and AdminExpensesForm. User screens include UserDashboardForm, UserExpensesForm, AddExpenseForm, and UserDetailsForm. The dashboards are separate, not just filtered views, which matters for diagramming the app’s navigation structure.
6. User management is handled by UserService and the admin user forms. The system supports approving, rejecting, blocking, and unblocking accounts, with actions depending on both role and current status. This makes user state a first-class domain concept rather than just a login flag.
7. Category management is isolated in CategoryService plus the admin category forms. Categories are stored as shared master data and are used as lookup values when creating expenses. The presence of EditCategoryForm indicates a dedicated edit workflow rather than inline editing.
8. Expense handling is the main transactional subsystem. ExpenseService manages create, read, and delete operations, and is used by both admin and user screens. Users can add and delete their own expenses through AddExpenseForm and UserExpensesForm, while admins can view all expenses in AdminExpensesForm.
9. The data model is straightforward and relational. Users is the identity and access table, Categories is the lookup/master table, and Expenses references both Users and Categories. The schema in DatabaseSetup.sql enforces the primary relationships: each expense belongs to exactly one user and one category.
10. Helpers/DatabaseHelper.cs is an important infrastructure boundary. It centralizes database connection creation and reads environment-specific settings from .env, allowing local development settings to differ from other environments. This is paired with DotNetEnv support mentioned in the README, so configuration is externalized rather than hardcoded.
11. The UI layer uses Windows Forms designer/code-behind pairs throughout. Each .Designer.cs file defines layout, while the corresponding .cs file holds event handling and form logic. This separation is important for understanding where presentation ends and behavior begins.
12. Helpers/UITheme.cs and Controls/SidebarButton.cs indicate a shared visual system. UITheme standardizes colors, fonts, and likely control styling across forms, while the sidebar button provides reusable navigation behavior in the admin/user shell.
13. The repository also includes SQL scripts (DatabaseSetup.sql and Helpers/SQLQuery1.sql) and screenshots under docs/screenshots, which support setup and documentation but are not part of runtime behavior. For an architecture diagram, the key runtime path is: WinForms UI → service layer → SQL Server database, with shared helpers and models in between.
Main entry points: ExpenseService.cs ExpenseService · AuthService.cs AuthService · AdminDashboardForm.cs Admin Dashboard · UserDashboardForm.cs User Dashboard
Components 23
Authentication UI
Login and registration boundary
Admin UI
Role-based admin workflows
- Admin Dashboard · Primary admin navigation and overview
Forms/AdminDashboardForm.cs - Users · Approve, reject, block, and unblock accounts
Forms/AdminUsersForm.cs - Categories · Manage shared expense categories
Forms/AdminCategoriesForm.cs - Expenses · View all expenses across users
Forms/AdminExpensesForm.cs
User UI
Role-based user workflows
- User Dashboard · Primary user navigation and overview
Forms/UserDashboardForm.cs - My Expenses · View and delete owned expenses
Forms/UserExpensesForm.cs - Add Expense · Create a new expense record
Forms/AddExpenseForm.cs - Profile · View personal account details
Forms/UserDetailsForm.cs
Services
Business logic and persistence
- AuthService · Login, registration, and session decisions
Services/AuthService.cs - UserService · Account state transitions and user management
Services/UserService.cs - CategoryService · Category lookup and maintenance
Services/CategoryService.cs - ExpenseService · Create, read, and delete expenses
Services/ExpenseService.cs
Domain Models
Shared data objects
Infrastructure
Database and shared UI utilities
- DatabaseHelper · Centralized connection creation and .env-based config
Helpers/DatabaseHelper.cs - UITheme · Shared colors, fonts, and control styling
Helpers/UITheme.cs - SidebarButton · Reusable navigation button control
Controls/SidebarButton.cs - SQL Server · Local relational datastore for users, categories, and expenses
Connections 33
- Program → Login: launches · Startup opens the authentication flow
- Login → AuthService: authenticates via · Login screen delegates credentials to service layer
- Register → AuthService: registers via · Registration creates pending accounts
- Pending → Login: returns to · Users wait until approval allows login
- AuthService → UserService: checks state · Authentication depends on account status and role
- AuthService → Admin Dashboard: opens · Approved admin users enter admin shell
- AuthService → User Dashboard: opens · Approved standard users enter user shell
- Admin Dashboard → Users: navigates · Admin shell routes to user management
- Admin Dashboard → Categories: navigates · Admin shell routes to category management
- Admin Dashboard → Expenses: navigates · Admin shell routes to expense review
- User Dashboard → My Expenses: navigates · User shell routes to owned expenses
- User Dashboard → Add Expense: navigates · User shell routes to expense creation
- User Dashboard → Profile: navigates · User shell routes to profile details
- Users → UserService: manages · Approve, reject, block, and unblock accounts
- Categories → CategoryService: manages · Category workflows use service layer
- Expenses → ExpenseService: reads via · Admin views all expenses through service layer
- My Expenses → ExpenseService: reads/deletes via · Users load and delete their own expenses
- Add Expense → ExpenseService: creates via · Expense entry persists through service layer
- ExpenseService → User: uses · Expense operations reference user identity
- ExpenseService → Category: uses · Expense operations reference category lookup
- ExpenseService → Expense: maps · Expense service works with transaction entities
- UserService → User: maps · User service works with account entities
- CategoryService → Category: maps · Category service works with master data entities
- AuthService → DatabaseHelper: connects through · Authentication relies on centralized database access
- UserService → DatabaseHelper: connects through · User management uses shared connection setup
- CategoryService → DatabaseHelper: connects through · Category management uses shared connection setup
- ExpenseService → DatabaseHelper: connects through · Expense persistence uses shared connection setup
- DatabaseHelper → SQL Server: connects to · Centralized SQL Server connectivity boundary
- UITheme → Login: styles · Shared theming supports WinForms screens
- UITheme → Admin Dashboard: styles · Shared theming supports admin screens
- UITheme → User Dashboard: styles · Shared theming supports user screens
- SidebarButton → Admin Dashboard: used by · Reusable navigation control in shells
- SidebarButton → User Dashboard: used by · Reusable navigation control in shells