How meeeee6623/fortis works
• Frontend (Next.js Application) – This includes components, pages, and layout files found in folders such as “app”, “pages”, and “components”. Note that there are styling resources (e.g., globals.css, tailwind configuration) and specific pages (e.g., login.jsx, profile pages, etc.).
• API Gateway/Rewrite Layer – Represent the role of next.config.js where all requests to “/api/*” are rewritten to target the Flask API server (running locally on 127.0.0.1:5328 or as serverless functions on Vercel in production).
• Backend (Flask API Server) – Capture both “flask-api/index.py” and “flask-api/main.py” that implement the Python/Flask server logic. This server processes API calls (routed through the Next.js rewrite) and contains the business logic and data processing.
• Database (PostgreSQL Server) – Show the connection from the Flask backend to the PostgreSQL database, as described in the README. Also note the SQL queries stored in the “queries” directory (e.g., user, workout, exercise queries) that manage data fetching and updates.
• Authentication Service – Although integrated within the frontend (see Auth0 setup instructions and pages/api/auth files), it is a distinct element handling user authentication and authorization.
• External Tools and Services – Include Vercel’s serverless functions and deployment setup (for hosting both Next.js and Python functions) and DataGrip (as a recommended tool for connecting to PostgreSQL).
Relationships and Data Flow
• Users access the Next.js frontend (displayed via pages and components).
• When an API call is needed (e.g., to fetch workout data, process friend requests, search activities), the request is routed through the Next.js rewrite layer (defined in next.config.js) to the Flask API.
• The Flask API makes the necessary queries/updates on the PostgreSQL database. SQL scripts in the “queries” folder and test data in “test_data” illustrate how SQL queries structure the data operations.
• Responses from the Flask API are passed back to the Next.js app, which then renders the updated state for the user.
• Authentication routes under pages/api/auth facilitate user login, logout, and session management via Auth0 and cookie-based sessions.
• Notice that some API endpoints are also defined under pages/api (for example, for friend requests); these might also interact with the same PostgreSQL backend, creating a slight hybrid API model that is still unified via Next.js.
Architectural Patterns and Important Technologies
• This system employs a separation of concerns between the UI (Next.js) and the business logic (Flask API). The rewrite mechanism abstracts the backend processing from the front end.
• An API Gateway (rewrites) pattern is applied for routing API calls.
• The toolchain includes Next.js for SSR and component-based UI, Flask as a lightweight Python-based API server, and PostgreSQL as the relational database.
• External authentication via Auth0 and support libraries like pg, react-select, and cookie-next are part of the overall architecture.