# diego-mostro-dev/gim-saas architecture

> Architecture diagram of the GitHub repository diego-mostro-dev/gim-saas, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/diego-mostro-dev/gim-saas
- Repository: https://github.com/diego-mostro-dev/gim-saas

## Overview

1. **Overall shape**
   - This is a two-tier gym management SaaS: a **Django REST backend** and a **React/Vite frontend**.
   - The backend owns business data and CRUD operations; the frontend is a separate SPA that consumes the API.

2. **Backend entry point and platform layer**
   - `backend/manage.py`, `config/asgi.py`, `config/wsgi.py`, `config/settings.py`, and `config/urls.py` form the Django application shell.
   - `config` is the composition root: it wires Django apps, URL routing, environment-based settings, and deployment interfaces.

3. **Domain modules in the backend**
   - The backend is split into three core business apps:
     - `members` for gym member records
     - `plans` for membership plan definitions
     - `subscriptions` for the relationship between a member and a plan
   - Each app has its own `models.py`, `serializers.py`, `views.py`, `urls.py`, `admin.py`, and migrations, which makes the domain boundaries explicit.

4. **Data model boundaries**
   - `members` represents people/customers.
   - `plans` represents pricing/duration offerings such as weekly, monthly, or premium plans.
   - `subscriptions` links a member to a plan and adds operational fields like payment status and expiration dates.
   - The architecture suggests the subscription layer is the main transactional entity, while members and plans are supporting reference entities.

5. **API composition**
   - Backend endpoints are likely exposed through Django REST Framework view/serializer pairs under each app’s `urls.py`.
   - There are also dedicated API modules in `config/api/` for `health.py` and `dashboard.py`, implying cross-domain endpoints that aggregate data rather than serving a single model.

6. **Operational and cross-cutting backend concerns**
   - The README mentions **PostgreSQL on Neon** as the database target.
   - `django-filter` is part of the stack and the README explicitly calls out filtering support, so list endpoints likely support query-based filtering.
   - Django Admin is enabled for direct operational management of the same domain models.

7. **Backend data flow**
   - Client requests hit Django URLs, are handled by DRF views, serialized/deserialized by app serializers, and persisted via Django models to PostgreSQL.
   - Dashboard-style endpoints likely read across multiple models to compute aggregates such as active members, expiring subscriptions, and revenue.

8. **Frontend application shell**
   - The frontend is a **React SPA built with Vite** (`frontend/src/main.jsx`, `App.jsx`, `vite.config.js`).
   - `index.html` is the browser entry, and the app is organized around pages plus reusable components.

9. **Frontend feature boundaries**
   - `src/pages/` contains the main route-level screens: `Dashboard`, `Members`, and `Subscriptions`.
   - `src/components/dashboard/` and `src/components/subscriptions/` contain UI building blocks for those screens.
   - This separation suggests pages compose domain-specific widgets rather than embedding all logic in route components.

10. **Frontend data access layer**
   - `src/services/` contains API client modules for `members`, `plans`, `subscriptions`, and `dashboard`.
   - These service modules are the boundary between UI and backend, so the frontend does not appear to talk to the database directly or share backend models.

11. **Frontend state and behavior**
   - Custom hooks in `src/hooks/` encapsulate subscription-related logic such as fetching data, filtering, form state, and stats calculation.
   - This indicates a thin component layer with logic extracted into reusable hooks, likely improving separation between presentation and data orchestration.

12. **User-facing flow**
   - The primary UI flow appears to be:
     - manage members
     - define plans
     - create and monitor subscriptions
     - view dashboard analytics
   - That maps directly to the backend’s domain apps and the planned dashboard summaries.

13. **Important architectural boundary**
   - The repo is currently organized as a **monorepo with a clear client/server split**.
   - The backend owns persistence, validation, and business rules; the frontend owns presentation, client-side interaction, and API orchestration.

14. **MVP emphasis**
   - The README indicates the backend MVP is in progress, while the frontend is just starting.
   - So the architecture should be drawn with a stronger emphasis on backend domain services and API endpoints, with the frontend shown as an API consumer that is still being fleshed out.

Main entry points: [`backend/config/urls.py`](https://github.com/diego-mostro-dev/gim-saas/blob/main/backend/config/urls.py) (URL routing), [`frontend/src/pages`](https://github.com/diego-mostro-dev/gim-saas/tree/main/frontend/src/pages) (Pages), [`backend/members`](https://github.com/diego-mostro-dev/gim-saas/tree/main/backend/members) (Members), [`backend/plans`](https://github.com/diego-mostro-dev/gim-saas/tree/main/backend/plans) (Plans)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Backend"]
  node_backend_manage["manage.py<br/>Django entry<br/>[manage.py]"]
  node_backend_config["config<br/>Django shell"]
  node_backend_api["API endpoints<br/>Cross-domain API"]
  node_backend_members["Members<br/>Domain app"]
  node_backend_plans["Plans<br/>Domain app"]
  node_backend_subscriptions["Subscriptions<br/>Domain app"]
  node_backend_models[("Data models<br/>ORM layer")]
  node_backend_serializers["Serializers<br/>DRF layer"]
  node_backend_views["Views<br/>DRF handlers"]
  node_backend_urls["URL routing<br/>Routing layer<br/>[urls.py]"]
  node_backend_db[("PostgreSQL<br/>Data store")]
end

subgraph group_frontend["Frontend"]
  node_frontend_shell["React app<br/>SPA shell"]
  node_frontend_pages["Pages<br/>Route views"]
  node_frontend_dashboard_ui["Dashboard UI<br/>UI modules"]
  node_frontend_sub_ui["Subscription UI<br/>UI modules"]
  node_frontend_services["API services<br/>Client layer"]
  node_frontend_hooks{{"Hooks<br/>State logic"}}
end

node_backend_manage -->|"boots"| node_backend_config
node_backend_config -->|"wires"| node_backend_urls
node_backend_config -->|"exposes"| node_backend_api
node_backend_urls -->|"routes"| node_backend_members
node_backend_urls -->|"routes"| node_backend_plans
node_backend_urls -->|"routes"| node_backend_subscriptions
node_backend_urls -->|"routes"| node_backend_api
node_backend_members -->|"uses"| node_backend_models
node_backend_plans -->|"uses"| node_backend_models
node_backend_subscriptions -->|"uses"| node_backend_models
node_backend_members -->|"serializes"| node_backend_serializers
node_backend_plans -->|"serializes"| node_backend_serializers
node_backend_subscriptions -->|"serializes"| node_backend_serializers
node_backend_members -->|"handles"| node_backend_views
node_backend_plans -->|"handles"| node_backend_views
node_backend_subscriptions -->|"handles"| node_backend_views
node_backend_views -->|"persists"| node_backend_db
node_backend_api -->|"aggregates"| node_backend_db
node_frontend_shell -->|"renders"| node_frontend_pages
node_frontend_pages -->|"composes"| node_frontend_dashboard_ui
node_frontend_pages -->|"composes"| node_frontend_sub_ui
node_frontend_pages -->|"fetches"| node_frontend_services
node_frontend_pages -->|"orchestrates"| node_frontend_hooks
node_frontend_services -.->|"calls"| node_backend_urls
node_frontend_hooks -->|"uses"| node_frontend_services

click node_backend_manage "https://github.com/diego-mostro-dev/gim-saas/blob/main/backend/manage.py"
click node_backend_config "https://github.com/diego-mostro-dev/gim-saas/tree/main/backend/config"
click node_backend_api "https://github.com/diego-mostro-dev/gim-saas/tree/main/backend/config/api"
click node_backend_members "https://github.com/diego-mostro-dev/gim-saas/tree/main/backend/members"
click node_backend_plans "https://github.com/diego-mostro-dev/gim-saas/tree/main/backend/plans"
click node_backend_subscriptions "https://github.com/diego-mostro-dev/gim-saas/tree/main/backend/subscriptions"
click node_backend_urls "https://github.com/diego-mostro-dev/gim-saas/blob/main/backend/config/urls.py"
click node_frontend_shell "https://github.com/diego-mostro-dev/gim-saas/tree/main/frontend/src"
click node_frontend_pages "https://github.com/diego-mostro-dev/gim-saas/tree/main/frontend/src/pages"
click node_frontend_dashboard_ui "https://github.com/diego-mostro-dev/gim-saas/tree/main/frontend/src/components/dashboard"
click node_frontend_sub_ui "https://github.com/diego-mostro-dev/gim-saas/tree/main/frontend/src/components/subscriptions"
click node_frontend_services "https://github.com/diego-mostro-dev/gim-saas/tree/main/frontend/src/services"
click node_frontend_hooks "https://github.com/diego-mostro-dev/gim-saas/tree/main/frontend/src/hooks"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_backend_manage,node_backend_config,node_backend_api,node_backend_members,node_backend_plans,node_backend_subscriptions,node_backend_models,node_backend_serializers,node_backend_views,node_backend_urls,node_backend_db toneBlue
class node_frontend_shell,node_frontend_pages,node_frontend_dashboard_ui,node_frontend_sub_ui,node_frontend_services,node_frontend_hooks toneAmber
```

## Components

### Backend

Django REST API, domain apps, and deployment shell

- [manage.py](https://github.com/diego-mostro-dev/gim-saas/blob/main/backend/manage.py): Django entry · Django command entry point for local management tasks · `backend/manage.py`
- [config](https://github.com/diego-mostro-dev/gim-saas/tree/main/backend/config): Django shell · Composition root for settings, routing, and deployment interfaces · `backend/config`
- [API endpoints](https://github.com/diego-mostro-dev/gim-saas/tree/main/backend/config/api): Cross-domain API · Health and dashboard endpoints that aggregate data across models · `backend/config/api`
- [Members](https://github.com/diego-mostro-dev/gim-saas/tree/main/backend/members): Domain app · Member records and CRUD API boundary · `backend/members`
- [Plans](https://github.com/diego-mostro-dev/gim-saas/tree/main/backend/plans): Domain app · Membership plan definitions and CRUD API boundary · `backend/plans`
- [Subscriptions](https://github.com/diego-mostro-dev/gim-saas/tree/main/backend/subscriptions): Domain app · Member-to-plan subscriptions with operational state · `backend/subscriptions`
- **Data models**: ORM layer · Persistent business entities across the domain apps
- **Serializers**: DRF layer · Request and response shape for API resources
- **Views**: DRF handlers · HTTP handlers for CRUD and aggregated endpoints
- [URL routing](https://github.com/diego-mostro-dev/gim-saas/blob/main/backend/config/urls.py): Routing layer · Dispatches requests into app and API view handlers · `backend/config/urls.py`
- **PostgreSQL**: Data store · Neon-hosted persistence for the gym domain

### Frontend

React SPA and client-side feature modules

- [React app](https://github.com/diego-mostro-dev/gim-saas/tree/main/frontend/src): SPA shell · Vite-powered browser application entry and root component · `frontend/src`
- [Pages](https://github.com/diego-mostro-dev/gim-saas/tree/main/frontend/src/pages): Route views · Dashboard, members, and subscriptions screens · `frontend/src/pages`
- [Dashboard UI](https://github.com/diego-mostro-dev/gim-saas/tree/main/frontend/src/components/dashboard): UI modules · Widgets for charts, stats, activity, and actions · `frontend/src/components/dashboard`
- [Subscription UI](https://github.com/diego-mostro-dev/gim-saas/tree/main/frontend/src/components/subscriptions): UI modules · Forms, filters, cards, and stats for subscription workflows · `frontend/src/components/subscriptions`
- [API services](https://github.com/diego-mostro-dev/gim-saas/tree/main/frontend/src/services): Client layer · Frontend service modules that call backend endpoints · `frontend/src/services`
- [Hooks](https://github.com/diego-mostro-dev/gim-saas/tree/main/frontend/src/hooks): State logic · Reusable subscription fetching, filtering, form, and stats logic · `frontend/src/hooks`

## Connections

- manage.py → config: boots · Management commands load the Django project configuration
- config → URL routing: wires · Settings and app composition feed URL routing
- config → API endpoints: exposes · Config includes cross-domain API modules
- URL routing → Members: routes · Member endpoints are mounted through Django URLs
- URL routing → Plans: routes · Plan endpoints are mounted through Django URLs
- URL routing → Subscriptions: routes · Subscription endpoints are mounted through Django URLs
- URL routing → API endpoints: routes · Health and dashboard endpoints are exposed at the API layer
- Members → Data models: uses · Member app persists through Django models
- Plans → Data models: uses · Plan app persists through Django models
- Subscriptions → Data models: uses · Subscription app persists through Django models
- Members → Serializers: serializes · Member resources are shaped for DRF responses
- Plans → Serializers: serializes · Plan resources are shaped for DRF responses
- Subscriptions → Serializers: serializes · Subscription resources are shaped for DRF responses
- Members → Views: handles · CRUD views serve the member domain
- Plans → Views: handles · CRUD views serve the plan domain
- Subscriptions → Views: handles · CRUD views serve the subscription domain
- Views → PostgreSQL: persists · Views read and write the PostgreSQL data store
- API endpoints → PostgreSQL: aggregates · Dashboard and health endpoints can read across persisted domain data
- React app → Pages: renders · The app shell composes route-level screens
- Pages → Dashboard UI: composes · Dashboard page assembles dashboard widgets
- Pages → Subscription UI: composes · Subscriptions page assembles subscription widgets
- Pages → API services: fetches · Pages load data through API service modules
- Pages → Hooks: orchestrates · Pages use hooks for subscription state and derived data
- API services → URL routing: calls · Frontend services consume the Django API surface
- Hooks → API services: uses · Hooks build on API service calls
