# ganzafrica-org/ganzafrica architecture

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

- Interactive diagram: https://gitdiagram.com/ganzafrica-org/ganzafrica
- Repository: https://github.com/ganzafrica-org/ganzafrica

## Overview

##### Project Type & Purpose
- The platform is a full-stack web application dedicated to supporting GanzAfrica’s mission. It features a public-facing website that highlights fellowship programs, projects, and community initiatives, as well as an admin portal used for management tasks including user applications, fellow management, and CRM.
- The README clearly describes two primary domains: the public website (apps/web) and the admin portal (apps/portal), along with a shared backend API (packages/api) that drives business logic and data access.

##### File Structure
- Top-Level Separation:
- “apps/portal” for the administrative portal.
- “apps/web” for the public website.
- “packages/api” which contains all the server-side logic, configuration, and database interaction files using DrizzleORM.
- “packages/ui” holds shared UI components built using shadcn/ui and Tailwind CSS.
- Additional packages like “packages/eslint-config” and “packages/typescript-config” provide project-wide configuration consistency.
- Within each application, files and subdirectories are organized by feature or functionality. For example, in “apps/portal”, the “app/(auth)” directories indicate modular, route-based authentication pages. Similarly, “apps/web” organizes localized pages under subfolders corresponding to different locales.
- The backend API in “packages/api” is modularized into configuration, database, and business logic modules (partials like auth, email, etc.) and also integrates tRPC routers for type-safe API interactions.

##### Identifying Main Components
a. Frontend Components:
- Public Website (“apps/web”): Represents the user-facing website with localized content, static pages, interactive sections, and pages for fellowship programs, events, projects, etc.
- Admin Portal (“apps/portal”): The secured area for administrative tasks including fellow management, application tracking, and CRM functionalities.
b. Backend API (“packages/api”):
- Implements core business logic, authentication (using a custom PASETO-based system), and structured database interactions via DrizzleORM.
- Contains modules for authentication, email services, and database schema management.
c. Shared Components:
- UI Library (“packages/ui”): Contains reusable UI components such as buttons, cards, dialogs, and more that help maintain a consistent look and feel across both applications.
- Configuration Packages: ESLint and TypeScript configurations provided in separate packages to ensure code quality and type safety across the codebase.
d. Data & External Systems:
- Database: PostgreSQL (with migrations and Drizzle ORM configurations).
- Deployment & Infrastructure: Uses Cloudflare Pages for frontend deployments, Cloudflare Workers for backend deployments, Cloudflare R2 for storage, and DigitalOcean for hosting the PostgreSQL database.

##### Relationships & Interactions
- Shared UI components are used in both frontend applications. This can be represented by a central “UI Library” that both “apps/web” and “apps/portal” reference.
- Deployment infrastructure (Cloudflare Workers/Pages, DigitalOcean) can be shown as external systems that host and manage application runtime and data persistence.

##### Architectural Patterns & Technical Details
- Next.js is used consistently across applications—hinting at a server-side rendering and possibly a file-based routing methodology.
- tRPC provides end-to-end type safety for API calls.
- The custom PASETO-based authentication system details are part of the API’s auth module.
- The modular structure (with distinct directories for authentication and database logic) follows separation of concerns, ensuring maintainability.
- The use of Tailwind CSS and shadcn/ui establishes a component-driven styled UI.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Applications
    subgraph "Frontend"
        publicWeb["Public Website (apps/web)"]:::frontend
        adminPortal["Admin Portal (apps/portal)"]:::frontend
    end

    %% Shared Components
    subgraph "Shared Components"
        uiLibrary["Shared UI Components (packages/ui)"]:::shared
    end

    %% Backend and Database
    subgraph "Backend"
        backendAPI["Backend API (packages/api)"]:::backend
        database["Database (PostgreSQL via DrizzleORM)"]:::database
    end

    %% Configurations
    subgraph "Configurations"
        eslint["ESLint Configuration (packages/eslint-config)"]:::config
        tsconfig["TypeScript Configuration (packages/typescript-config)"]:::config
    end

    %% Deployment & External Services
    external["Deployment & External Services\n(Cloudflare Pages, Workers, R2; DigitalOcean)"]:::external

    %% Relationships between Frontend and Backend API
    publicWeb -->|"callsAPI"| backendAPI
    adminPortal -->|"callsAPI"| backendAPI

    %% Backend API interacts with Database
    backendAPI -->|"CRUDOperations"| database

    %% Frontend uses shared UI components
    publicWeb ---|"uses"| uiLibrary
    adminPortal ---|"uses"| uiLibrary

    %% Deployment relationships
    publicWeb -->|"deployedOn"| external
    adminPortal -->|"deployedOn"| external
    backendAPI -->|"deployedOn"| external

    %% Class Definitions for styling
    classDef frontend fill:#FFDD57,stroke:#333,stroke-width:2px;
    classDef backend fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef database fill:#F1948A,stroke:#333,stroke-width:2px;
    classDef shared fill:#A9DFBF,stroke:#333,stroke-width:2px;
    classDef config fill:#D7BDE2,stroke:#333,stroke-width:2px;
    classDef external fill:#FAD7A0,stroke:#333,stroke-width:2px;

    %% Click Events
    click publicWeb "https://github.com/ganzafrica-org/ganzafrica/tree/main/apps/web"
    click adminPortal "https://github.com/ganzafrica-org/ganzafrica/tree/main/apps/portal"
    click backendAPI "https://github.com/ganzafrica-org/ganzafrica/tree/main/packages/api/src"
    click uiLibrary "https://github.com/ganzafrica-org/ganzafrica/tree/main/packages/ui"
    click eslint "https://github.com/ganzafrica-org/ganzafrica/tree/main/packages/eslint-config"
    click tsconfig "https://github.com/ganzafrica-org/ganzafrica/tree/main/packages/typescript-config"
```
