# crcrr-charity13/ims architecture

> Architecture diagram of the GitHub repository crcrr-charity13/ims, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/crcrr-charity13/ims
- Repository: https://github.com/crcrr-charity13/ims

## Overview

##### Main Components

a) Frontend Layer (gik-dashboard):
- React-based web application
- Key modules:
- Authentication (Login/Register components)
- Dashboard components (Inventory, Transactions, Analytics)
- Client/Donor Management
- Scanner Interface

b) Backend Layer (gik-api):
- Golang-based API server
- Core components:
- Router System
- Authentication Middleware
- Database Interface
- Business Logic Controllers

c) Database Layer:
- SQLite database (as indicated by .sqlite files)
- Stores:
- Inventory data
- User information
- Transaction records
- Client/Donor data

##### Component Relationships

- Frontend → Backend: REST API calls through defined routes
- Backend → Database: Data persistence and retrieval
- Middleware flow: Authentication → CORS → Logging
- Business logic flow: Request → Middleware → Router → Controller → Database

##### Specific Implementation Details

Architectural patterns:
- MVC-like pattern in the backend (routers → controllers → data types)
- Component-based architecture in React frontend
- Middleware chain pattern for request processing
- Type-driven development (extensive types/ directory in both frontend and backend)

**[Client Layer]**
- Web Browser
- React Components (Dashboard, Inventory, Transactions)

**[Frontend Services]**
- Authentication
- State Management
- UI Components

**[API Gateway]**
- REST Endpoints
- Middleware (Auth, CORS, Logging)

**[Backend Services]**
- Item Management
- Location Management
- Transaction Processing
- User Management

**[Data Layer]**
- SQLite Database
- File Storage (assets)

##### Additional Elements

Include:
- Environment configuration flow
- API endpoint groupings
- Data type relationships

Remember to:
- Keep the main flows clear and visible
- Related components together
- Clear boundaries between services
- Notes for important architectural decisions

The level of detail should be sufficient to understand the system architecture without getting lost in implementation specifics, focusing on the key features mentioned in the README: item management, location management, transaction processing, and security.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
        Scanner["Scanner Interface"]:::frontend
    end

    subgraph "Frontend Layer"
        Auth["Authentication Components"]:::frontend
        Dashboard["Dashboard Components"]:::frontend
        ClientDonor["Client/Donor Management"]:::frontend
        Analytics["Analytics UI"]:::frontend
        StateManagement["State Management"]:::frontend
    end

    subgraph "API Gateway"
        REST["REST API Endpoints"]:::api
        AuthMW["Authentication Middleware"]:::middleware
        CORS["CORS Middleware"]:::middleware
        Logging["Logging Middleware"]:::middleware
    end

    subgraph "Backend Services"
        ItemService["Item Management"]:::backend
        LocationService["Location Management"]:::backend
        TransactionService["Transaction Processing"]:::backend
        UserService["User Management"]:::backend
        AnalyticsService["Analytics Service"]:::backend
    end

    subgraph "Data Layer"
        DB[(SQLite Database)]:::database
        FileStorage["Asset Storage"]:::storage
    end

    Browser --> Auth
    Browser --> Dashboard
    Scanner --> Dashboard
    
    Auth --> REST
    Dashboard --> REST
    ClientDonor --> REST
    Analytics --> REST
    
    REST --> AuthMW
    AuthMW --> CORS
    CORS --> Logging
    
    Logging --> ItemService
    Logging --> LocationService
    Logging --> TransactionService
    Logging --> UserService
    Logging --> AnalyticsService
    
    ItemService --> DB
    LocationService --> DB
    TransactionService --> DB
    UserService --> DB
    AnalyticsService --> DB
    
    ItemService --> FileStorage
    
    classDef frontend fill:#3498db
    classDef backend fill:#2ecc71
    classDef middleware fill:#f1c40f
    classDef database fill:#e74c3c
    classDef storage fill:#9b59b6
    classDef api fill:#34495e
    
    click Auth "https://github.com/CRCRR-CharITy13/IMS/blob/main/gik-dashboard/src/routes/Login.tsx"
    click Scanner "https://github.com/CRCRR-CharITy13/IMS/blob/main/gik-dashboard/src/components/dashboard/Scanner.tsx"
    click Dashboard "https://github.com/CRCRR-CharITy13/IMS/tree/main/gik-dashboard/src/components/dashboard/"
    click ClientDonor "https://github.com/CRCRR-CharITy13/IMS/blob/main/gik-dashboard/src/components/dashboard/ClientsDonors.tsx"
    click Analytics "https://github.com/CRCRR-CharITy13/IMS/blob/main/gik-dashboard/src/components/dashboard/Analytics.tsx"
    click AuthMW "https://github.com/CRCRR-CharITy13/IMS/blob/main/gik-api/src/middleware/auth.go"
    click ItemService "https://github.com/CRCRR-CharITy13/IMS/tree/main/gik-api/src/routers/items/"
    click LocationService "https://github.com/CRCRR-CharITy13/IMS/blob/main/gik-api/src/routers_old/location/location.go"
    click TransactionService "https://github.com/CRCRR-CharITy13/IMS/tree/main/gik-api/src/routers_old/transaction/"
    click DB "https://github.com/CRCRR-CharITy13/IMS/blob/main/gik-api/assets/gik-ims-localdb.sqlite"

    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Service"]:::backend
        Middleware["Middleware"]:::middleware
        Database["Database"]:::database
        Storage["Storage"]:::storage
        APIGateway["API Gateway"]:::api
    end
```
