# mohamedsaid5/fci-graduation-renting-system-api architecture

> Architecture diagram of the GitHub repository mohamedsaid5/fci-graduation-renting-system-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohamedsaid5/fci-graduation-renting-system-api
- Repository: https://github.com/mohamedsaid5/fci-graduation-renting-system-api

## Overview

##### Project Type and Purpose
- This is a full-stack apartment rental platform with:
- A Django REST Framework backend (in the `RentingSystem/`, `accounts/`, `apartments/` directories)
- A React single-page frontend (in `Renting-System-Frontend/`)
- A lightweight SQLite database (in `db.sqlite3`) for development
- Media storage for user avatars and apartment photos
- Optional mobile client integration (Flutter demo)

##### File Structure Analysis
- Top‐level directories:
- `accounts/` – Custom user model, authentication endpoints, tokens, password reset
- `apartments/` – Apartment CRUD, photo uploads, filters, saved apartments
- `RentingSystem/` – Django settings (`settings.py`), URL routing, WSGI/ASGI
- `Renting-System-Frontend/` – React app with components, context, hooks, assets
- `media/` – Uploaded files (avatars, apartment_photos)
- `locale/` – Translation files (Arabic/English)
- Config & scripts:
- `requirements.txt` – Python dependencies
- `package.json` (backend and frontend) – npm dependencies
- `manage.py` – Django CLI entry point
- `server.js` – Local Express server to serve React assets (if used)

##### README‐Derived Insights
- REST API documented via Swagger/ReDoc at `/api/docs/`
- Token‐based auth for all protected endpoints
- CORS enabled for mobile and web clients
- Multilingual support using Django’s i18n

a. Main Components:
1. React Frontend (SPA)
2. Django REST API Backend
3. Relational Database (SQLite in dev / pluggable to Postgres for production)
4. Media Storage (file system or S3 in production)
5. External Services:
– Email provider for password resets
– (Optionally) CDN for static assets
– Third‐party map or payment APIs (if extended)
6. Mobile Client (Flutter) – optional

b. Relationships & Data Flows:
– The React SPA interacts with the Django API over HTTPS (HTTP calls to `/api/*`).
– The API reads/writes to the database and saves media files to disk or external object storage.
– The API uses token‐based authentication; tokens are stored in the React app’s localStorage.
– Email service is invoked by the API (e.g., for password reset).
– CORS configuration allows both web and mobile origins.

c. Architectural Patterns & Principles:
– Separation of Concerns: UI layer (React) vs. business/data layer (Django).
– MVC-ish layering in Django (Models in `models.py`, Serializers, Views, URLs).
– Context & hooks for global state in React (`src/context/Auth.jsx`, `src/hooks/useAuth.jsx`).
– RESTful resource design: `/api/auth/`, `/api/apartments/`, `/api/profile/`, etc.
– Pagination, filtering, internationalization built into DRF.
– Token‐based stateless authentication.

d. Technology Stack Callouts:
– Frontend: React, React Router (public/private routes), Context API, Fetch helpers
– Backend: Django 5.0, Django REST Framework, Django translations, DRF auto-docs
– Database: SQLite (dev), swappable to Postgres in production
– Media: Django `MEDIA_ROOT` for avatars & photos
– Build & Deployment: `npm`/`yarn` for frontend, `python manage.py` for backend

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        React["React SPA"]:::frontend
        subgraph "Global State & Hooks"
            AuthCTX["Auth Context"]:::frontend
            UseAuth["useAuth Hook"]:::frontend
        end
        subgraph "Routing"
            Public["PublicRoute"]:::frontend
            Private["PrivateRoute"]:::frontend
        end
    end

    %% Server Side
    subgraph "Server Side"
        API["Django REST API"]:::backend
        subgraph "Core"
            MP["manage.py"]:::backend
            Settings["settings.py"]:::backend
            URLs["urls.py"]:::backend
            ASGI["asgi.py"]:::backend
            WSGI["wsgi.py"]:::backend
        end
        subgraph "Authentication Module"
            AMODEL["accounts/models.py"]:::backend
            ASERIAL["accounts/serializers.py"]:::backend
            AVIEW["accounts/views.py"]:::backend
            AURL["accounts/urls.py"]:::backend
            ATOK["accounts/tokens.py"]:::backend
            AUTILS["accounts/utils.py"]:::backend
        end
        subgraph "Apartments Module"
            AptMODEL["apartments/models.py"]:::backend
            AptSER["apartments/serializers.py"]:::backend
            AptVIEW["apartments/views.py"]:::backend
            AptURL["apartments/urls.py"]:::backend
            AptFILT["apartments/filters.py"]:::backend
            AptTOK["apartments/token.py"]:::backend
            AptTRANS["apartments/translation.py"]:::backend
        end
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        DB["SQLite (db.sqlite3)"]:::database
        Media["Media Store"]:::storage
        Locale["i18n Locale Files"]:::persistence
    end

    %% External Services
    subgraph "External Services"
        Email["Email Service"]:::external
        CDN["CDN (Optional)"]:::external
        Mobile["Flutter Mobile Client"]:::external
    end

    %% Relationships
    React -->|"HTTPS /api/*"| API
    React ---|"CORS"| API
    API -->|"ORM Queries"| DB
    API -->|"Read/Write Files"| Media
    API -->|"Load Translations"| Locale
    API -->|"SMTP Calls"| Email
    API -->|"Serve Static"| CDN
    Mobile ---|"HTTPS /api/*"| API

    %% Click Events
    click React "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/tree/main/Renting-System-Frontend/"
    click AuthCTX "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/Renting-System-Frontend/src/context/Auth.jsx"
    click UseAuth "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/Renting-System-Frontend/src/hooks/useAuth.jsx"
    click Public "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/Renting-System-Frontend/src/componant/PublicRoute/index.jsx"
    click Private "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/Renting-System-Frontend/src/componant/PrivateRoute/index.jsx"
    click MP "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/manage.py"
    click Settings "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/RentingSystem/settings.py"
    click URLs "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/RentingSystem/urls.py"
    click ASGI "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/RentingSystem/asgi.py"
    click WSGI "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/RentingSystem/wsgi.py"
    click AMODEL "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/accounts/models.py"
    click ASERIAL "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/accounts/serializers.py"
    click AVIEW "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/accounts/views.py"
    click AURL "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/accounts/urls.py"
    click ATOK "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/accounts/tokens.py"
    click AUTILS "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/accounts/utils.py"
    click AptMODEL "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/apartments/models.py"
    click AptSER "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/apartments/serializers.py"
    click AptVIEW "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/apartments/views.py"
    click AptURL "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/apartments/urls.py"
    click AptFILT "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/apartments/filters.py"
    click AptTOK "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/apartments/token.py"
    click AptTRANS "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/apartments/translation.py"
    click DB "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/db.sqlite3"
    click Media "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/tree/main/media/"
    click Locale "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/tree/main/locale/"
    click Mobile "https://github.com/mohamedsaid5/fci-graduation-renting-system-api/blob/main/mobile-app-demo.mp4"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef backend fill:#D6F5D6,stroke:#333,stroke-width:1px
    classDef persistence fill:#FFE4B5,stroke:#333,stroke-width:1px
    classDef external fill:#E8E8E8,stroke:#333,stroke-width:1px
    classDef database fill:#FFD700,stroke:#333,stroke-width:1px
    classDef storage fill:#FFA500,stroke:#333,stroke-width:1px
```
